    ____ _   _    _  _____    _        _
  / ___| | | |  / \|_   _|__| |_ __ _| |_ ___
 | |   | |_| | / _ \ | |/ __| __/ _` | __/ __|
 | |___|  _  |/ ___ \| |\__ \ || (_| | |_\__ \
  \____|_| |_/_/   \_\_||___/\__\__,_|\__|___/
              3.1.1 by Baerchen, December 2001
                  for eggdrop 1.4.x+ & TCL 8.3
                     baerchen@germany-chat.net
       latest versions @ home.dal.net/baerchen

DESCRIPTION
*********************************************************************

The script gathers a bunch of info aboutb a channel and creates some
sort of statistics. In detail it monitors:

- amount of joins
- words and lines users speak
- user's online times
- user's idle times
- amount of bans (active/passive)
- amount of kicks (active/passive)
- channel peaks and peak times

The script then creates overall stats and rankings for each of the
data, e.g.

Personal stats for baerchen on #germany-chat 
Joins: 30   Time spent: 22h:25m    Idle: 20h:23m   -> Active chatting: 2h:2m
TopTalkers: Rank 9 - 1949 words/146 lines (avg 13.3). Lutz_MMI is 428 words ahead
AllStars: Rank 18 - 1020 words/228 lines (avg 4.4). torkel is 217 words ahead
Kicks: 0   Bans: 1   Got kicked: 0   Got banned: 0

and much more.

Counting user's spoken words often leads to competition among some of
them. At a point, when there seem to be no more changes on the top
of the ranking, +nC|C flagged users can do a cycle. I.e. the current
TopTalkers ranking will be reset to 0 and their wordcount shoved to
some kind of eternal ranking (AllStars).

A lot of information about the channel (topic, current users etc.)
and the bot (partyline users etc.) can be dumped to HTML files which
then can be uploaded to an FTP server or moved locally. The
webpages created don't base on in-script HTML any longer but instead
on templates, which means you can use your own HTML code. Therefore
you decide about the HTML design and which information goes into the
webpages. If you don't want to bother with this, use the supplied
templates and go right away.

The distinction of the configuration in global and channel-specific
settings gives CHATstats full multi-channel capabilities.

See "http://www.germany-chat.net -> Bettenauslastung" to get an idea
of how it could look like (using the supplied templates).

NOTE: CHATstats' v3.x database is incompatible with earlier versions.
      Although there is a converting script, I highly recommended to
      start from the scratch. (Read more in the INSTALLATION file).

COMMANDS
*********************************************************************

PUB, -|-
--------
show <..>              Shitload of options what stats to show

PUB, nC|C
---------
change <options>       Manipulates users word balances. Two options
merge <source> <dest>  Merges two users in one
delete <nick>          Deletes <nick>'s account for that channel
cyclestats             Cycles TopTalkers
freeze <nick>          Freezes <nick>'s account
unfreeze <nick>        Unfreezes <nick>'s account

DCC, -|-
---------
(only available if helpfile is installed)
help chatstats         Shows all CHATstats related commands
help <command>         Shows help on a specific CHATstats command

DCC, C|C
--------
go <channel>            Enables CHATstats for <channel>
stop <channel>          Disables CHATstats for <channel>
chatstats               Shows the most important configuration info

DCC, n|-
--------
update [channel]        Creates webpages immediately
trim <limit>            Trims the database manually if necessary
wipechan <channel>      Deletes a channel from the databases
back-up                 Makes a backup of the .dat file
recover                 Reads the .backup file to memory

For detailled info, install the supplied chatstats.help.

NOTES & TRICKS
*********************************************************************

- CHATstats automatically ignores all 'Guest' nicks.
- Don't forget to .stop and .wipechan when the bot leaves a channel.
- Exclude other channel bots from being counted by adding them as
  bots to the userlist or 'freeze' their nicks.

HISTORY
*********************************************************************
3.1.1

Fixed: Another "&" issue: In 3.1.0 I fixed it, but only for one
       occurence of & in a topic or channelname. Two or more
       occurences made the webpage creation procedure cause an error.
Fixed: Related to the first fix: when two "%%" occured in the channel
       topic, webpage creation procedure caused an error.
Fixed: List processing problem in cs:html - changed the way the
       templates are parsed from list to string processing.
Fixed: Glitch introduced in 3.1.0: in 'show stats', TopTalker's rank
       was always 0.
Changed: Permissions for command 'chatstats' from n|- to nC|C.
Changed: Duration of online-time and idle-time in '.show' is now
         shown the same way as on the webpages.
Changed: Minor things, such as wording, grammar, bla.
Added: PUB Commands 'freeze'/'unfreeze' make CHATstats temporarily
       ignore/unignore a user.
Added: Per-channel-listing of all frozen accounts to command
       'chatstats'
Added: Botnet map (similar to '.bottree') to botstats.global.template
       Some of you might think there's redundant information now, but
       it's ok for demonstration purposes. Remember, you can change
       the templates as you like. Thanks to Wcc for idea and code.
       Used with friendly permission.
Added: Variable 'rankrange': until now, 'show <whatever>' returned
       the first ten ranks of each category. With 'rankrange' you
       can determine individually how many ranks are returned.
Added: In 3.1.0, I've added the new listing 'topactiveusers' for
       the webpages. Consequently, I had to add the option
       'actives' to the 'show' command.

3.1.0
- Introduced new listing for templates: topactiveusers, which returns
  users' onlinetime minus idletime, sorted. %%TOTALACTIVE returns
  the total active chatting time of all users.
- Introduced variable cs(dont): a space delimited list of words,
  which when spoken, prevents CHATstats from counting.
  highly recommended.
- Three variables weren't available although built-in (TOTALWORDS & 
  TOTALLINES & TOTALRATIO).
- Added variable !!FLAGS to the chanusers listings (if user is
  recognized by bot, it returns his flags)
- .dat file was holding data of channels that weren't enabled
  (wasn't checking for enabled channels in cs:rawpart and 
  cs:rawjoin). This bug didn't affect anything except the size of
  the .dat file. After rehashing, you can .wipechan those channels.
- 'wipechan' now understands more than one argument:
  wipechan #channel1 #channel2 #channel3 ..
- cs(trim) went to the global variables. Each channel can be trimmed
  with different values
- Fixed biggie: 'cyclestats' cycled all channels. Duh.
- When script was stopped, %%TIMENEXTUPDATE still returned a value.
- Fixed %%CHANNEL returning bs when channel name contained the
  character '&', e.g. #wine&dine (same for %%CHANTOPIC). 
- Fixed 'update' - under certain circumstances it was not possible
  to add a channel and have .update generate the websites - though
  normal ("scheduled") updating worked fine.
- Fixed non-latin language based bug: if a nick used non-latin 
  characters, an error in cs:update was raised stating the nick
  can't be found on the channel. Since this has nothing to do with
  the script itself but the way eggdrop and TCL work together,
  a quick workaround was to simply exclude that nick from further
  processing.
- Updated and changed command 'chatstats' slightly.
- Updated helpfile (corrections, additions).
- Gained speed improvements in regard to array operations.
- Added sanity checks to some commands.
- Cleaned up code and improved legibility of the script.

3.0.0 (major rewrite in order to implement new features)
- CHATstats now monitors joins, kicks, bans, online times, idle
  times, channel peaks, users' spoken words and lines. The
  distinction between TopTalkers and Allstars has been kept
- Introduced templates. Make your own HTML output
- Introduced division of configuration in global and channel-specific
  settings, giving CHATstats full multi-channel capabilities
- Added advertizing system. Make CHATstats advertize your website for
  info purposes
- Reintroduced .back-up and .recover
- Userlist for the channel-stats is now returned in mIRC-style
  (ops A-z, voices A-z, others A-z)
- URLs in topics are now hyperlinked
- Once again, changed commands and their syntax to match new features
- Once again, changed variable names for better understanding
- Took out some unneccessary settings (who cares for the names of
  the cachefiles ;-))

2.11
- Fixed bugs of two non-existing variables that occured under certain
  circumstances when updating .htm pages. Thanks to LangerT of
  langersoft.de for heavy debugging ;-)
- Fixed two other bugs regarding the creation of the AllStars page.
- Fixed bug that after .wipechan'ing a channel, it was not deleted
  from the configuration array, therefore causing .chatstatus to
  output inaccurate information.
- Fixed rare variable declaration bug in .go
- Fixed very rare bug that if the bot was on two channels of which
  names start equal but end different (e.g. #test and #test1), the
  AllStars of #test1 were mixed up. Except for this one, integrity
  of data was _not_ affected by all of the above mentioned bugs.
- Rewrote .chatstatus, now more accurate & informative. By doing so,
  the [lsort] error (see below) was eliminated.
- Minor changes to html code
- Added DCC commands for go and stop

2.1
- Fixed bug that after cycling stats, TopTalkers were not saved when
  the array was empty. If no word was spoken until a crash, rehash
  or restart occured, the Toptalkers had the same wordcount as
  before cycling
- Fixed bug in activity.htm when $timezone and $offset are not set
- Cleaned code; some speed and efficacy improvements
- Introduced cs(botlogo) and cs(timefactor). See README
- Introduced cs(interval): Changed method of updating htmls from a
  bind to a timer, which means that you can set the intervals more
  flexible (.restart is highly recommended)
- Introduced cs(trigger): you can now define the trigger character
  for the public commands (.restart is highly recommended)
- Fixed nasty bugs that occured when using TCL version < v8.3. There
  is still one error due to using an [lsort] option that has been
  implemented in 8.3. However, it's not vital to the script and
  affects .chatstatus only. I decided to live with this one ;-)

2.0
- Added DCC commands .chatstatus .wipechan and .update
- Added configuration of colors and font for HTMLs. Now you can adapt
  the appearance of the HTMLs to your liking
- Added some coloured bar.gifs
- Added started/stopped/last reset information to .topten .topstars
  and HTMLs
- Upon request, changed commands for .topten and .topstars to
  .toptalkers and .allstars (makes sense even ;-)
- Upon request, chanstats, toptalkers, botstats and activitystats
  now update simultaneously every hour
- Configuration wasn't saved in regular intervals - fixed
- Minor changes to the layout of the HTMLs (merged tables and stuff)
- Removed link to activity.htm on chanstats.htm
- Deleted .backup and .rollback. Who needs that anyway ;-)
- Cosmetic changes to the code. Changed cs(visitwebsite) to
  cs(nochaninfo) for better understanding
- Changed README. A.o., added chapter "POSSIBLE PROBLEMS" - Thanks
  to |Starman| on this one
      
1.02
- cs(allowhtml) was not stringtolower'ed - if channels were entered
  with uppercase letters, it caused the TopTalkers.htm not to show
  the wordcount.

1.01
- Trying to unbind an unexisting bind caused bot not to start.
- Limited host length in chanstats.htm to max. 50 chars in order
  not to mess up the table when using long hostnames.
- After starting, TopStars array was read too early, therefore
  causing an error. Delayed 10 secs now.

1.0
- First public release