## Basic design by Einride, - The Elite Scripting Team
## Based on ideas picked from fluxlearn.tcl by Reflux and WDOG.MRC by Genesis
##
#
# NotePod is a channel definition script, similar in many respects to
# explain and fluxlearn and others. It has many additional features however,
# including but not limited to:
# - configurable channel triggers
# - command specific access flags
# - fallback to users channel status when user is not on bot
# - only user who set a definition can replace it (except for master)
# - only configured script_owners (defined in script config) can forget
# or replace defs LOCKED by any script_owner listed
# lock is set by preceeding def with ":"
# this supports multiple handles in $owner
# - will not repeat a def within configurable number of mins.
# - configurable usage limit (default is 5 defs in 3 mins) prevents
# over-eager users from lagging the bot.
# - puts non-users who try to use NotePod commands and those who exceed
# usage limit on ignore for configurable number of mins.
# - special commands for masters
# - command to replace a definition
# - backup bot automatically takes over when primary leaves channel
# - botnet commands to sync definitions for two bots
# - configure once for both bots
# - dcc commands to get various internal files
# - dcc commands to show, learn, forget and replace definitions
# - dcc and channel commands to do wildcard matches of nick and body of
# definitions
# - automatically sorts defs
#
#
## Channel commands:
# command trigger
#
# help <configuable> - user level specific help
# trigger example "?? ??"
#
# explain <configurable> - show a definition
# trigger example "?? someword"
#
# scan <configurable> - show definition matchs for a wildcard
# - will match to word* in def name or body
# trigger example "??? someword"
#
# scannick <configurable> - show definition matches set by nick
# trigger example "?!? somenick"
#
# scanbody <configurable> - show wildcard match in body of definitions
# will match to *word* in body of def
# trigger example "??! someword"
#
# learn <trigger>learn - learn a new definition
# - learn will strip tcl {}[] characters from
# - definitions.
# - mIRC attributes and color codes may be used
# - in body of def.
# trigger example "?!learn someword and its definition"
#
# - if def is set by a user listed in $script_owners and is
# preceeded with a ":", this definiton may only be changed
# by one of the $script_owners
# (applies to forget and replace as well)
#
# forget <trigger>forget - forget a definition
# trigger example "!forget someword"
#
# replace <trigger>replace - replace a definition
# trigger example "!replace someword with a new def"
#
# Only the user who set a definition may replace or forget it.
# The NP_Remove_any and NP_Replace_any variables define the level of
# a user who can forget or replace ANY definiton. This is usually set
# to M (master).
#
# whoset <trigger>whoset - show who set a definition
# trigger example "!whoset someword"
#
# As a configured NotePOD OWNER, (configuration option script_owners)
# you can LOCK a definition by prepending : (colon) when using the learn
# or replace commands.
# The following commands allow you to lock or unlock a pre-existing definition. puthelp "PRIVMSG $nick :\00313$NP_trigger_Lockdef <def>\003 - lock a current definition."
# lockdef <word>
# unlockdef <word>
#
## DCC +m commands:
#
#
# .np learn , forget, replace, whoset same as for channel commands
#
# .np show - dcc equivalent of explain,
# - this is raw mode showing whoset also
# .np wshow - dcc equivalent of scan
# .np bshow - dcc equivalent of scanbody
# .np nshow - dcc equivalent of scannick
#
# .np getlist - send definition list
# .np gethist - send definition change history
# .np getsync - send definition sync file
#
# .np forcesync - force def list sync on target bot
# .np killsync - delete pending def resync list
#
# .np update - update def list on target bot
# - bot DCC sends list to target bot
#
# .np move <sync|list> - install new synclist or deflist
# - that was DCCed to bot by owner
# .np sort - sort the def list
#
#
## Definition Sorting:
#
# Definition list is sorted on restart, rehash and via dcc command.
# A backup file is made.
#
#
## Definition Syncing:
#
# When operated on two bots, NotePOD tries to keep the definition files in
# sync on both. It accompishes this via the botnet link, issuing putbot
# commands as required.
#
# Both bots execute learn, replace and forget, but only the primary NotePod bot
# will reply to channel explain and scan commands.
# When the primary goes offline/channel, the secondary takes over
# public/msged replies. Both bots store all changes made in a sync file
# while the other is offline.
# If bots are linked but on split channels, def sync is done via botnet.
# When a bot relinks, the other will update it via the botnet.
# If synclist is greater that 1k, sync is not done and a note will be sent
# to the bot OWNER. IN this case, the owner must use the .np update command
# to update the other bot.
# If synclist is 51 bytes, this indicates bot has a default list and it
# will automatically request, via the botnet, the current def list from the
# other bot. A note will be sent to OWNER.
#
# Both bots MUST have x flag for each other, and you should have an inbound
# directory defined and created on each. They need to be botlinked also :)
#
# IF both go offline/channel, yer screwed, don't bug me.