G6Stats v4.20 by EsKiMo
http://www.tranceambient.com

G6Stats is an extremely customizable TCL script for Eggdrop bots that will allow for an IRC
sitebot to be run with a G6FTP server. The configuration is a simple, so making it fit your
exact preferences is a breeze. In general, G6Stats has the capability to:
- Display statistics (in approved channels) for your server over the past day, week, month,
or for all-time, including top uploaders, top downloaders, total uploads, total downloads,
and average speeds.
- Include anywhere from 1 to 25 users in the statistics
- Automatically announce new uploads to approved channels
- Greet people with instructions as they enter an approved channel
- Catch incorrect commands and help user to use the correct commmands
- Display any range of uploads for the current day
- Nuke unwanted uploads at the command of authorized administrators
- Display all the nukes for the current day
- Display the total number of uploads for the current day
- Create a datestamped folder every night at midnight
- Notify infinite number of user-specified people via IRC and/or ICQ WWP in the event
of a detected hack attempt on the bot (eg, unauthorized nuke attempts, failed
authorizations)
- Archive the authorization log, nuke log, upload load, and hack attempt log
- Reset all the daily activity logs at the command of an authorized admin

INSTALLATION INSTRUCTIONS

1: Be sure to change all the variables to match your configuration/preferences
BEFORE you start up this script!  There are detailed instructions in the g6stats.tcl
for how to configure each variable.

2: Place the supplied .mdl files in the root of your G6FTP server

3: Create a new folder in /eggdrop/scripts called "g6stats"

4: Place the supplied g6stats.tcl and newup.bat in your
/eggdrop/scripts/g6stats folder

5: Open G6FTP and go to SETUP-->MAIN-->STAT GENERATOR and enable the Stat Generator.

6: Open G6FTP and go to SETUP-->EVENTS MANAGER-->ONDIRCREATED
Put a check in the 'Execute' box, select START HIDDEN, and add the following line:
"C:\eggdrop\scripts\g6stats\newup.bat" "%DIR" %CLIENTLOGIN %CLIENTGROUP
NOTE: The %CLIENTGROUP variables is ONLY available to G6FTP v2.0 RC1 and later!
NOTE: Edit the path to the g6stats files as it is found on your system
NOTE: Some users have had problems with %CLIENTLOGIN. If you have trouble, try using
%CLIENTNAME. It appears that this problem only occurs in G6FTP v2.0 beta 6 and earlier.
NOTE: Some of you were not using %DIR in the old versions because of personal preference.
Please make sure you change your Event Manager to use %DIR for this version, otherwise
your upload announcements might not be formatted correctly.

7: Open the newup.bat and edit the path to reflect the path to your /eggdrop/scripts/g6stats
folder.

8: If you wish to edit the .mdl files, open your G6FTP and go to 'HELP-->MANUAL/HELP-->
GENERAL-->INTERFACE-->MAIN SETUP-->STAT GENERATOR' for information on how the tags work.
If you come up with some cool .mdl templates, feel free to send them to me via email at
g6stats@tranceambient.com. If they are good, I will include them in future releases of
G6Stats!

9. If you wish to edit the way in which the EVENTS MANAGER reacts to a new upload, open
your G6FTP and go to 'HELP-->MANUAL/HELP-->GENERAL-->INTERFACE-->EVENTS MANAGER' for
information on what variables are available for output. Please not that you will have
to edit the newup.bat accordingly (or whatever you choose to name it). Please note that
many statistical variables are available to the event manager as of G6FTP v2.0 RC1. The statistics
tags are in the MESSAGE FILES section of the G6FTP user manual.

10: When you have completed the configuration, add the following line to the 'Source Scripts'
section your Eggdrop configuration file (it's near the bottom usually):
source scripts/g6stats/g6stats.tcl

VERSIONS

New in v4.20
- Added support to display users group in new upload announcements (for G6FTP v2.0 RC1 and later)
- Added option to display requests to either in a private message or to the channel
- Minor adjustments to instructions to help clear up some confusion
- Moved the INSTALLATION INSTRUCTIONS to the top of the eskimo.nfo so people might actually read it

New in v4.16
- Added the information about the new IRC channel (#G6Stats) on NewNet (irc.bootsector.org:6667)

New in v4.15
- Changed the log_cycle routine to append to archived logs if they already exist (which
would happen if the resetlogs command was used multiple times in a day)
- Added a feature to make reseting the authlog optional
- Changed the upload log to be ordered from oldest to newest. I did this because it is much
faster to do it this way, and since the user has the ability to list any range of uploads
he wants, there is no real reason to list from newest to oldest. PLEASE NOTE that this
change is in the newup.bat, thus you must update this file with the new one.
- Updated the FAQ to include the guide to help people who can't figure out how to get their
bots to announce uploads, which is by far the most frequently asked question. (Thanks
ABCDE for helping me compile this guide)
- Made a couple cosmetic changes in the display
- Optimized several sections of the code

New in v4.10
- Fixed bug that would not allow the UPLOAD LOG to be reset at midnight if at any time
during the day someone requested the UPLOAD COUNT. (thanks ABCDE for pointing this out)
- Fixed DIE message when the g6stats files cannot be found. (thanks Bill908 for pointing
this out!)
- Added a feature to reset (and archive if enabled) logs by the command of an authorized
admin
- Made the format of the date-stamped folder (the one created at 11:59pm) completely
customizable.

New in v4.05
- Fixed a couple of typo's in the FAQ (thanks ABCDE for pointing this out)
- Changed the way the approved channels list is handled internally to make it so it is not
case-sensitive (channels on IRC aren't case sensitive, so the script shouldn't be either)
- Added a brief request in the TCL to urge G6FTPd users to purchase the software legally

New in v4.04
- Accidentally left my own trigger in the public release of v4.03. Whoops!
- Added a feature where all the approved_chans list will be converted to lower case before
starting the code (in case some people feel like capitalizing their channels)

New in v4.03
- Fixed a bug in the routine that creates the date-stamped folder at midnight. The old variable
was still used.
- Enhanced the abovementioned routine to create the "midnight_dir" if it doesn't already exist.
- Added a CRC Table to the package.

New in v4.02
- Fixed a logic bug in the log cycling routine.
- Added some extra DIE statements to the beginning of the code to help prevent misconfigured
bots from starting.

New in v4.01
- Fixed some inconsitencies in the instructions that were lingering leftovers from old versions
- Added comments to the new code
- Updated the FAQ to try to handle the questions that will arise from the new features.
- Fixed a bug that would have caused the log files (auth, nuke, admin, hack) to not be deleted
at midnight if the user chooses to disable log archiving.
- Fixed a bug where nothing would be reported if a user requested the upload log and there WAS
no upload log to display.
- Changed the URL to the support forum:   http://www.tranceambient.com/g6stats_support.html

New in v4.00
- Changed the newup.bat to also write a log of all the uploads for the day, in order from
newest to oldest
- Added a trigger to display any range of uploads for the current day
- Added a feature where users can authorize as an administrator. All authorizations from
are reset at midnight (ie, you only have to authorize once per day)
- Added capability for authorized administrators to nuke unwanted uploads from within
or beyond the incoming directory. Specifying the reason is optional.
- Added a trigger to display the nukes for the current day.
- Added a feature where you can automatically create a new date-stamped folder at midnight.
(thanks Inferno!)
- Added the capability to notify an infinite number of people over IRC and/or ICQ WWP in
the event of a detected hack attempt.
- Combined the channels that were approved to announce uploads and the channels that were
approved to allow stats commands (there was really no use in having them separate)
- Changed the way the approved channels are specified. It is now much easier to specify as
many or as few channels as you want, all done on a single configuration line (no code editing
needed!)
- Added 'simple' to my list of Special Thanks. Without him this new version would not have been
possible. Thanks a ton bud (your music still sucks though!)
- Identified bug in Eggdrop v1.4.3 that causes the files to be displayed incorrectly when there
are blank spaces and/or null characters in the file. For this reason I am not supporting v1.4.3
anymore. I am now supporting v1.3.27-28 ONLY!
- Optimized MANY algorithms in the code to make it run more efficiently.
- and much much MUCH more! (I can't remember everything I did, but what's listed above is the
important stuff!)

New in v3.25
- Made the method of new-user greeting optional between using a GreetBot, sending a Notice,
or having no greeting at all.
- Added a switch to allow/disallow your bot to be a GreetBot
- Updated the FAQ to include questions concerning the GreetBot

New in v3.20
- Changed the way the new-user greeting was handled. New users will now be greeted
by a central 'greet bot', so users entering channels with several bots running
G6STATS will have a quick and easy way to see all the instructions without receiving
a separate notice or private message from each individual bot.

New in v3.14
- Added instructions to find the support forum under the INFO response

New in v3.13
- Added a FAQ to the eskimo.nfo file.  Hopefully this will keep me from answering the
same question(s) over and over again.
- Opened a G6Stats Support forum on the message board of http://www.tranceambient.com
--> MESSAGE BOARD --> G6STATS SUPPORT FORUM

New in v3.12
- Added two more conditions that must be passed in order for the bot to start.
- Added an automatic DIE to the end of the configuration which must be removed in
order for the bot to start. (this is to help prevent people from starting the bot
without properly configuring the script first)
- Renamed the siteonjoin{} function to greet_onjoin{}. Figured this would make it
more clear as to what the function does
- Removed the quotations around the color definitions. They don't need to be there.

New in v3.11
- Changed the default directory of the G6 FTP Server. Apparently this was causing
some minor confusion. (Thanks Fireman for pointing this out).
- Made a slight cosmetic change to the instructions

New in v3.10
- Added seven error-checking conditions that will be checked when the eggdrop bot
is started.  If all of the conditions are not passed, the bot will not start, and
an error message will be displayed. This is very useful for first-time installers!
Thanks Fireman for the recommendation!
- Added a putlog at the end of the script so you will see that the script loads
correctly in the bot log (and also when you do .rehash). Thanks Fireman!
- Renamed a few variables to help clarify exactly what they are for

New in v3.01
- The package has been changed so G6Stats can be distributed more easily
- Slight rewording in the instructions

New in v3.00
- Added capability to announce uploads to multiple channels
- Completely rewrote the upload-announcing engine
- Removed need of the fcopy.bat (thanks |Infern0|)
- Renamed several variables clarify better what each does
- Added a variable to specify the date that the G6FTP stats were first started
- Removed the need for the 'bot' variable (which specified the bots name)
- Optimized the code to make script run faster
- Enhanced compabitibility with various system configurations
- Changed the EXECUTE action in the G6FTP Events Manager
- Changed the newup.bat file to reflect that changes to the Event Manager
- Changed the instructions given in the g6stats.tcl to help clarify what everything does
- Added comments to the code to explain what each section is doing
- Made some changes to the color scheme to make it more customizable
- Moved the 'Special Thanks' into the 'Info' reply.
- Updated 'Special Thanks' reply
- and more!

New in v2.03
- Changed the path specified in the EVENTS MANAGER instructions. It seems as if you have
to specify the exact path on the output file too. Sorry about that.

New in v2.02
- Updated the Special Thanks reply
- Added some more instructions to help clarify a few points

New In v2.01:
- Removed an unused key (sorry I missed it when I repackaged).

New In v2.00:
- Added capability to announce uploads as they come in
- Fixed bug from previous versions that would not allow blank lines in the .top files.
- Re-wrote the .mdl files
- Added a 'Special Thanks' command
- Made several aesthetic corrections

KNOWN BUGS/ISSUES

1) In order to change the color scheme of the actual stats (if you feel like it)
you'll have to edit the .mdl files directly. This is because TCL language doesn't impose
variables on data read in from files. Sorry!

FAQ

Question: Everything on the bot works except I can't get it to announce uploads!!! HELP!!
Answer: Actually this is the most FAQ so ABCDE and I compiled a thorough guide to help
people get their script to announce uploads. Please read through this carefully
and do EVERYTHING it says before coming for help.

1: Set your bot to join any channels in which you want it to be announcing (and any other channels you want to be in) using
the various configuration necessary for the eggdrop bot (not part of the g6stats.tcl).

2: In your g6stats.tcl set the channels you want your g6stats script to operate in using the 'approved_chans' variable,
as specified in the tcl.

3: Set the varible 'incoming_dir' the highest level in your upload directory. This is used to announce a relative path
to the uploads rather than an absolute path which can be done if the 'incoming_dir' is left blank.
NOTE: The NUKE permissions are given to the incoming_dir and all subfolders

4: Set the variable 'checkdelay'. This variable determines (in seconds) how often your bot will check for a new upload.
NOTE: Be careful not to set this variable too low or too high. If it is too low, your bot might start to eat up more
system resources than you would normally desire. If it is set too high, the bot might not announce some uploads that
come quickly one-after-another. Generally speaking it is a good idea to keep this value above 2 seconds.

5: Open G6FTP and go to SETUP-->EVENTS MANAGER-->ONDIRCREATED
Put a check in the 'Execute' box, select START HIDDEN, and add the following line:
"C:\eggdrop\scripts\g6stats\newup.bat" "%DIR" %CLIENTLOGIN
NOTE: Edit the path to the g6stats files as it is found on your system
NOTE: Some users have had problems with %CLIENTLOGIN. If you have trouble, try using
%CLIENTNAME.
NOTE: Some of you were not using %DIR in the old versions because of personal preference.
Please make sure you change your Event Manager to use %DIR for this version, otherwise
your upload announcements might not be formatted correctly.
NOTE: The path is given in DOS format, so use backslashes instead of forward slashes.
NOTE: Be sure to use the quotations around the path if the path contains spaces.

6: Make sure the newup.bat is in your /eggdrop/scripts/g6stats/ folder. Edit the newup.bat to reflect the path to this
folder. Again, everything in this file is just like DOS, so use backslashes in the path. Be sure to put quotations
around the path if the path contains spaces.

If your bot is STILL not announcing, here are some tips to try to figure out why:

1: Check your window-log in G6FTPd when a new upload comes through. It will tell you if there was an error in the newup.bat

2: Go to your eggdrop/scripts/g6stats/ folder and check to see if it created newup.txt, newup_copy.txt, _uplog.txt, and
old_uplog.txt. If not, do a FIND on your machine for these files to see where they were created. This is a good strategy
for tracking down the problem.
NOTE: The newup_copy.txt will not be created until the 2nd upload.

3: Check to see if the channel you are announcing to is moderated. If so, make sure the bot has at least a +v (voice).

As with all troubleshooting, this requires a little bit of detective work and some common sense. The bot works (many people
have gotten it to work without problems) so don't think that it's not announcing because it's a piece of junk. It will work
if you configure it correctly.

Question: Is is ABSOLUTELY necessary to have an Eggdrop bot going in order to use this script?
Answer: YES! Without a bot, you wouldn't have any way to use the script! Read the description
a bit closer please.

Question: No matter what I do, the bot cannot find the files in my scripts directory or in the
G6 FTP directory! The paths appear to be correct, so what do I do?
Answer: Check to make sure that you put a forward slash at the end of the path definition(s) in
g6stats.tcl

Question: Does this script work with unix/linux?
Answer: No, because G6FTP does not run in unix/linux.

Question: Will this script work on other versions of G6FTP or Eggdrop?
Answer: I have not tried all of the old versions, nor is it possible for
me to predict future versions, so the answer to that question is
simply "I don't know". Try it and find out.

Question: Where can I download the latest version of Eggdrop?
Answer: http://www.eggdrops.net/download.html

Question: I can't get *something unrelated to g6stats script* on my eggdrop bot to work! HELP!
Answer: I don't provide technical support for the Eggdrop bot, so if you need it, start here:
http://www.eggdrops.net/help.html .. Keep in mind that Win32 Eggdrops have very little
support (most eggs are *nix) so you might end up just figuring it out yourself or get
a knowledgeable and willing friend to help you out.

Question: What exactly IS a "GreetBot"
Answer: First let me explain the motivation behind using a GreetBot. When entering a channel where there
are several bots using G6STATS, having several Notices flying at the new user can be quite awkward,
since Notices have no real 'originating channel' therefore they will show up in whatever the new
user's active window is. It gets difficult to read when users are joining several channels at
once (autojoins anyone?). Solution: Have all the greetings come from one single location that is
easy to read, which is exactly what the GreetBot does. I made this feature optional since some users
did not like this method.

Question: The 'Greet Bot' seems to be ignoring my bot when it requests a greeting for a new user! Help!
Answer: Make sure the greet bot's owner has added your bot to it's userfile with at LEAST +hp flags

Question: If someone finds out my admin password, will they be able to delete my folders?
Answer: Not unless they are on your userfile with at least +o (operator) status.

Question: Can you give an example of a "proper" nuke?
Answer: Sure.   !trigger "music/some album/album i don't want" because it SUCKS
This will go into the Incoming Directory and delete the specified sub-path, and
give the reason "because it SUCKS"

Question: What happens if I have multiple incoming folders?
Answer: The script would become MUCH more complex if the capability was added for multiple incoming
folders. I recommend consolidating your uploads into a common directory.

Question: When someone requests to see the statistics, sometimes the script doesn't output lines
that it should. Why?
Answer: This is a bug in Eggdrop v1.4.3 , not G6STATS. Downgrade to v1.3.27-28 to fix this bug, or wait
till they upgrade Eggdrop. Please note that the developmental release of v1.5.2 still has this same bug.

Question: What good is having a date stamped folder created every night at midnight?
Answer: If you don't know, don't worry about it because you don't need it.

Question: Sometimes the ICQ WWP messages don't go through. Why?
Answer: ICQ isn't 100% reliable, especially with the WWP system. I spent 2 weeks on that part of the script
and the inconsistency is not caused by the script. Fortunately, about 90% of messages make it to their
destination. Also, be aware that the ICQ client has the ability to reject WWP messages, so make sure
the people on your list do not have this enabled. And keep in mind that non-Win32 ICQ do not support WWP.
(eg, LICQ)

Question: How exactly does the authorization routine work?
Answer: The person requesting authorization must be an operator on your bot, plus they must provide the correct
password. When these two criteria are verified, the user's nickname and hostmask are written to a file.
When the user attempts to nuke an upload, the script opens that authfile and searches it until either it
finds the users nickname and hostmask, or until it reaches the end of the file. If it finds the information,
the nuke attempt is allowed. If not, it is detected as a hack attempt and appropriate action is taken
(depending on what you have enabled/disabled). The authfile is cycled every night at 11:59pm.

Question: I cannot get %CLIENTLOGIN to work. HELP!
Answer: I have heard this from several people. Apparently G6FTPd v2.0 beta 6 does not support that flag very well.
Users have reported success with using %CLIENTNAME instead, so give that a try.

Question: For some reason the script is not keeping a log of all the uploads!
Answer: More than likely, either you did not update your newup.bat, the path in the newup.bat is incorrect,
or the path given in the Events Manager is incorrect. If the path has spaces in it, be sure to put
quotations around it.

Question: How can I nuke folders with spaces in it?
Answer: Put quotations around the path.

Question: Can anyone reset my activity logs?
Answer: Not unless they have +o on your userfile and have supplied the correct password
for authorization.

Question: The format of the date-stamped folders is not what I intended. Help!
Answer: Refer to this URL if you can't figure out how to format the date:
http://dev.scriptics.com/man/tcl8.2/TclCmd//clock.htm

Question: Where can I find answers to questions not found in the instructions or in this FAQ?
Answer: Go to http://www.tranceambient.com/g6stats_support.html

Question: Is there an IRC channel specifically for G6Stats?
Answer: YES! Go to #G6Stats on NewNet (irc.bootsector.org:6667 or irc.friendlynet.com:6667). This channel is entirely devoted to the
G6Stats script!

-EsKiMo
October 18th, 2000

Requests/Comments/Complaints:
http://www.tranceambient.com/g6stats_support.html

PLEASE NOTE: These instructions were written for G6 FTP Server v2.0 RC1 and Win32 Eggdrop v1.3.27-28