v4.1 revision 2 - by entropy
Channel Guardian Socket Bot is an extremely conprehensive all around mIRC channel guardian and protection bot. It utilizes mIRC's hash tables to store data into memory. The access levels consist of 7 levels. (0)none, (1)avoice, (2)aop, (3)sop, (4)founder, (5)admin, (black)blacklist. There are 88+ channel commands, and 22+ private message commands. This bot can easily fill different primary functions for a channel. You could easily run a large channel with several CGSB's with different purposes, or one single CGSB. CGSB has a fun side. You can run the trivia all day long, with hundreds of users playing. Or, if trivia is not your game, you can play UNO, or scramble. CGSB has a serious side. Effective channel management, via strict access levels and anti-spam. No need to login to CGSB ever. It records your host via a specific mask type. You have complete control. You can keep most if not all of trouble makers out of your channels now for good with CGSB. Every single equasion on IRC has precise code backing it. The best part about all this? It is 100% free! CGSB is equipped with all kinds of goodies to keep you happy day after day. I hope you enjoy this product by entropy.

If you run into problems accessing the files in Vista, disable the UAC!

If you seem to be lagged system resources wise, you might wanna unload the stats mod. i noticed my machine had a 2 sec system lag on some channels with stats loaded.

Working on CGSB is a full time job. If you would like to see a mod made, and dont know how to script, or if you would like to openly make a contribution to the project, paypal: entropy12345@yahoo.com ! all people that donate get listed in the next version's readme file as contributors!

1) Installation
2) Built-in Commands
3) Private Message Commands
4) Explainations
5) Frequently Asked Questions
6) Mods and Modding

Installation
1. Unzip
Im sure your wondering how to use my latest masterpiece. This is a great question, lets get started...
Unzip the contents of the zip file to any directory within the main mIRC directory. (advised: /mkdir bot)

2. Installation
type: /load -rs C:\mirc\bot\cgsb.txt
this loads the core script file.

3. Initialization
Type: /cgsb [N] [server] [port] [bnc email] [bnc password] [bnc server] [bnc vhost],
bnc email, password, server & vhost are optional.
or use the dialog interface.

4. Set all the Settings
Click on the drop down menu in the
cgsb dialog (after you select the active socket).

5. Load Mods
Your bot is connect to irc, and is awaiting commands, now you need to load the mods.
Type: /msg [botnick] loadall

6. Status: Connected
Your bot is connect to irc, set all the settings, loaded all the mods, now im sure your wondering how to get this bot on your channel, very simple...
Type: /msg [botnick] register #channel password
(make sure Allow Registering option is Yes) Thats it. Just message your bot with the words "register #channel password" and he will automatically join that channel and set you as founder. Or, you can identify with the bot as a network admin by typing: /msg [botnick] identify [adminpass]. Pretty simple huh? And if you want to drop a channel, type: /msg [botnick] drop #channel (admins can drop anyones channel).

Built-in Commands
1. Cycle
Channel Syntax: !cycle
Makes the bot leave/join the targetted channel.
Access Required aop(2).

2. Size
Channel Syntax: !size
Returns cgsb size.
Access Required none(0).

3. Networks
Channel Syntax: !networks
Returns all the networks/channels the bot is on.
Access Required admin(5).

4. Randquote
Channel Syntax: !randquote
Displays a random quote from the quotes file.
Access Required none(0).

5. Help
Channel Syntax: !help [keyword]
Displays limit help for the command.
Access Required none(0).

6. Unbanall
Channel Syntax: !unbanall
Unbans all bans on channel.
Access Required aop(2).

7. Voiceall
Channel Syntax: !voiceall
Voices all regulars on channel.
Access Required aop(2).

8. Devoiceall
Channel Syntax: !devoiceall
Devoices all voices on channel.
Access Required aop(2).

9. Ban2black
Channel Syntax: !ban2black [reason]
Adds all channel bans to the black list.
Access Required sop(3).

10. Black2ban
Channel Syntax: !black2ban
Adds all channel black lists to the ban list.
Access Required sop(3).

Private Message Commands
1. help
Syntax: /msg [botnick] help
Displays various commands available via private message.
Access required admin(5).

2. msg
Syntax: /msg [botnick] msg [#channel] text
Bot will message channel with text.
Access required aop(2).

3. action
Syntax: /msg [botnick] action [#channel] text
Bot will do an action on channel.
Access required aop(2).

4. set
Syntax: /msg [botnick] set [variable] [value]
Sets specified variable to value.
Access required admin(5).

5. unset
Syntax: /msg [botnick] unset [variable]
Unsets specified variable.
Access required admin(5).

6. eval
Syntax: /msg [botnick] eval [#channel] [command] [parms]
Bot does a all channel event.
Other eval commands:
eval #chan kickban nick reason - does a kickban combo on a nickname.
eval #chan slap nick - slaps nick with a trout.
eval #chan action is bored - will do the action "is bored".
Access required aop(2).

7. rehash
Syntax: /msg [botnick] rehash
Rehashes and saves all the bot settings.
Access required admin(5).

8. identify
Syntax: /msg [botnick] identify [#channel] [password]
Or: /msg [botnick] identify [adminpassword]
Access required none(0).

9. drop
Syntax: /msg [botnick] drop [#channel] [password]
Drops a registered channel. Password is optional as admin.
Access required founder(4),admin(5).

10. loadall
Syntax: /msg [botnick] loadall
Loads every *.mod file in the bot directory.
Access required admin(5).

11. unloadall
Syntax: /msg [botnick] unloadall
Unloads every loaded mod.
Access required admin(5).

12. mods
Syntax: /msg [botnick] mods
Lists the loaded mods.
Access required admin(5).

13. load
Syntax: /msg [botnick] load [mod]
Loads the specified *.mod file. No need to supply the file extention.
Access Required: admin(5).

14. modlist
Syntax: /msg [botnick] modlist
Admins can list the available mods.
Access Required: admin(5).

15. unload
Syntax: /msg [botnick] unload [mod]
Unloads the loaded mod file.
Access Required: admin(5).

16. list
Syntax: /msg [botnick] list
Lists all personal memos on the network.
Access Required: avoice(1).

17. read
Syntax: /msg [botnick] read [N]
Reads [n] personal memo.
Access Required: avoice(1).

18. send
Syntax: /msg [botnick] send [nick/#channel] msg
Sends a memo to nick/#channel.
Access Required: avoice(1).

19. join
Syntax: /msg [botnick] join [#channel]
Tells the bot to join #channel.
Access Required: aop(2).

20. part
Syntax: /msg [botnick] part [#channel]
Tells the bot to part #channel.
Access Required: aop(2).

21. msg
Syntax: /msg [botnick] msg [#channel] [text]
Tells the bot to msg #channel with text.
Access Required: aop(2).

22. action
Syntax: /msg [botnick] action [#channel] [text]
Tells the bot to do an action on #channel with text.
Access Required: aop(2).

23. global
Syntax: /msg [botnick] global [text]
Tells the bot to do a global message to all the channels
it is on.
Access Required: admin(5).

24. comset
Syntax: /msg [botnick] comset [command] [level: 0-5]
Tells the bot to change the access level for the specific command.
Access Required: admin(5).

25. info
Syntax: /msg [botnick] info [#channel]
Returns information about the given channel.
Access Required: none(0).

26. stats
Syntax: /msg [botnick] stats [#channel]
Returns stats about nicknames, modes, topic etc.
Access Required: none(0).

27. register
Syntax: /msg [botnick] register [#channel] [pass]
Registers channel with the bot, and sets you as founder.
Access Required: none(0).

28. add
Syntax: /msg [botnick] add [#channel] [level] [host]
Adds host to access list with set level.
Access Required: none(0).

29. del
Syntax: /msg [botnick] del [#channel] [level] [host]
Dels host from access list with set level.
Access Required: none(0).

30. wipe
Syntax: /msg [botnick] wipe [#channel] [level]
Wipes level on channel.
Access Required: none(0).

Explanations
Nickname
Primary bot nickname.

Password
Primary nickname password (if applicable).

UID
the nick!blah@host.com "blah" part of the complete host.

Email
Bot's email address (retrievable via finger request).

Name
Bot's real name.

Admin Password
Bot's admin password (/msg [botnick] identify [adminpass]).

Keepalive
Bot reconnects when disconnected, if turned on.

Mask Type (enter just the number)
Default mask type (when using masks).
0 = *!uid@123-456.host.com
1 = *!*uid@123-456.host.com
2 = *!*@123-456.host.com
3 = *!*uid@*.host.com
4 = *!*@*.host.com
5 = nick!uid@123-456.host.com
6 = nick!*uid@123-456.host.com
7 = nick!*@123-456.host.com
8 = nick!*uid@*.host.com
9 = nick!*@*.host.com
10 = *!uid@???-???.host.com
11 = *!*uid@???-???.host.com
12 = *!*@???-???.host.com
13 = *!*uid@???-???.host.com
14 = *!*@???-???.host.com
15 = nick!uid@???-???.host.com
16 = nick!*uid@???-???.host.com
17 = nick!*@???-???.host.com
18 = nick!*uid@???-???.host.com
19 = nick!*@???-???.host.com

Command Prefix
the command prefix to use for commands (eg: ! or , or .).

Op Onjoin
Should the bot op aops/sops/founders/admins when they join the channel?

Voice Onjoin
Should the bot voice avoices when they join the channel?

Access Protection
Should the bot protect aops/sops/founders/admins/avoices from bans, deop and devoice?

Allow Registering
Should the bot respond to /msg [botnick] register #channel [password]?

Sticky Bans
This option if enabled, will re-ban all bot issued bans if unbanned by an op.

Shutdown Bot
Shuts down the bot.

Colors
Sets the bot's message text and background colors (leave blank for no colors).

Connect On Start
Connects to the active server on start of mIRC.

Frequently Asked Questions
"How do i get this thing working?"
Well first thing is to decide what directory you want the bot in (within mIRC dir). Then you need to load it. /load -rs pathtocgsb\cgsb.txt. Then you need to connect it to a server. Then you will need to set the various settings. Then, you will need to load the bot modules you would like to have it use. (You can /msg botnick loadall for all).
Now you are ready to register a channel with the bot.

"How do i auto voice everyone who joins my channel?
Simple. Type: !add 1 *!*@*.

"I registered the bot on my channel(s) and loaded the mods, and he still won't respond to commands"
Well this means you must set the Mask Type option. Right-Click in the bot window, Settings > Mask Type (enter a number 0-19). Walla!

"How do i get the trivia working on my channel?"
I presume you used the /msg [botnick] register #channel password to get the bot there, and now you want to start a game of trivia on your channel. Simple. First load the mod trivia. Then, simply type: !trivia on
If you wish to personalize the game, there are various things you must "set" before you can do this:
!trivia set file [triviafile.txt] - questions and answers file, the zip file contains 2 trivia files for your entertainment: questions.txt and mircquestions.txt.
!trivia set qtimer [secs] - question timer value.
!trivia set htimer [secs] - hint timer value.
!trivia set points [points] - points per correct answer.
!trivia set hints [hints] - hints to give each question.
!trivia set percent [percent] - percent of the answer to show per hint (without the %), can also specify "random".

Reminder: You must have greater than or equal to SOP access on the bot's access list to turn it on/off and to use the "!trivia set" command.

"How do i add people to the bots access list?"
First load the mod access.
!add [1-4] nick!user@host.com - where 1 = avoice, 2 = aop, 3 = sop, 4 = founder.
!add black nick!user@host.com [reason] - reason is required.
!add [1-4] nick

You might want to concider changing the "Mask type" setting in the cgsb dialog. This is the mask type in which the bot will record/ban hostmasks.

Also take into concideration if you are having problems with conflicting hosts in the access lists, make them as detailed as possible, eg: instead of adding a nick like nick!*@*, you would use: nick!user@*.host.com or something similar.

"I set the admin password, now how do i become an admin?"
/msg [botnick] identify [adminpass]

"Why wont the bot join my channel? I get Registering of new channels is not enabled."
In the main dialog, click a cgsb, click the pulldown menu, then select registered and enter "YES".

"I can't get the define/weather/news/dns etc sockets to work. I get errors. What do i do?"
Not much you can do about that, so please dont bug me about it. I'm sorry.

"When i try to connect my bot to the irc server, i get (Open Error)"
Try connecting to the main general server. if you wanna connect to someplace.someircserver.net, Try irc.someircserver.net. And if that doesnt help, try to get a different server to connect to or a new network :/

"I cant get the bot on my channel. I've registered the channel with the bot."
Make sure there are no channel modes affecting an unregistered bot nickname, Or register the bot's nick.

"How to i enable or disable some commands?"
Simply load/unload the corresponding mods.

"How do i make the bot issues channel commands when i am outside the channel?"
Pretty easy. /msg [botnick] eval #channel [command]. Note a notice will be sent to everyone with access on the channel.

"How do i make the bot kick people on bad channels?"
Pretty easy. First you must set "badtokens" (the bad keywords). Type: !badtokens token1 token2 token3. Then: !set badchannels 0 30 (0=warnings,30=seconds ban).

"I get * /sockwrite: socket unavailable. What do i do?"
To the best of my knowledge this means you are running XP Pro SP2, and you have not patched it. Either patch it, or ignore it.

Mods
If you would like to make your own mods, you will have to follow the mod standard. It is required to have some mIRC scripting knowledge, this includes socket scripting and hash tables scripting. If you want to learn, type /help hash tables (from mIRC) and /help sockets (from mIRC).

If you want to permanently store data in a CGSB hash table, feel free. The global table is "cgsb", the local ones are "cgsbN" where N is a number. If you store data in the local tables, use $hget($sockname,ITEM) to refference (note $sockname is only a value when used in a socket event).

Example mod:

;TITLE MYACCESS - Line 1, The title of your mod
;AUTHOR entropy - Line 2, The mod author name
;COMMANDS myaccess(0) - Line 3, The commands this mod uses seperated with space (the 0 is the access required for the command, can be a number 0-5)
;VERSION 1.0 - Line 4, The version number of the mod
;HELP myaccess|Returns user access on channel.|none - Line 5(and on), These 3 seperate things represent 1: command, 2: info, 3: access required. For each command, supply a new line starting with ;HELP.

;============================== ALIASES
all aliases go here.

;============================== EVENTS
on *:sockread:cgsb*:{
    var %z = $hget(cgsb,buffer), %p = $hget(cgsb,$+($sockname,.prefix))
    var %t = $gettok($hget(cgsb,$+($sockname,.colors)),1,32), %u = $gettok($hget(cgsb,$+($sockname,.colors)),2,32)
    var %a = $hget($sockname,access)
    tokenize 32 %z
    if ($2 == privmsg && $left($3,1) == $chr(35) && $+(:,%p,*) iswm $4) {
      if ($+(:,%p,myaccess) == $4) {
        sockwrite -n $sockname privmsg $3 $+(:,$iif(%u && %t,$+($chr(3),%t,$chr(44),%u,$chr(32)))) $+ This is a line of text colored (if set). You have %a access on $+($3,.) $chr(3)
      }
    }
  }

The "var %z" line declares that the incomming data should be stored in temp variable %z. The "var %p" part sets %p to the bot command prefix.
The "var %t" & "var %u" declares temp variables to be set to the bot colors.
The "var %a" line sets temp variable %a to the access of the user triggering the event (forces 0,1,2,3,4,5).



If you need some help with modding, or with the bot in general, you can get on irc network DALnet and message entropy or get on channel #scripted.



This socket bot is provided as is, with no guarantees or liabilities from the author. It is provided as a service. Feel free to browse the code in the mIRC editor and take a look around. It is a copyright project in the works, so no worrying about rippers or thieves :)