def on_privmsg(self, connection, event): # Executed when the bot recieves a PM conf = shelve.open(".config") if(len(event.arguments()) == 0): return try: sent_cmd = event.arguments()[0].split()[0].upper() except IndexError: if len(event.arguments()) <= 1: sent_cmd = event.arguments() else: sent_cmd = event.arguments()[0] sent_nick = event.source().split("!")[0] sent_user = event.source().split("!")[1].split("@")[1].split(".")[0] print "-> PRIVMSG from " + sent_nick + ": " + event.arguments()[0] if sent_cmd == "ENTER": if len(event.arguments()[0].split()) < 4: connection.privmsg(sent_nick, "Not enough arguments for 'enter' command!") connection.privmsg(sent_nick, "Syntax: /msg " + conf["BotNick"] + " enter CHANNEL(,CHANNEL2) USERNAME IRCKEY") else: sent_chan = event.arguments()[0].split()[1] sent_chans = sent_chan.split(",") sent_userval = event.arguments()[0].split()[2] sent_irckey = event.arguments()[0].split()[3] print "-> User(nickname) " + sent_nick + " executed the 'enter' command to enter " + sent_chan + ". Given username: "******"" or sent_irckey == "" or sent_chan == "": connection.privmsg(sent_nick, "Not enough arguments for 'enter' command!") connection.privmsg(sent_nick, "Syntax: /msg " + conf["BotNick"] + " enter CHANNEL(,CHANNEL2) USERNAME IRCKEY") else: res = ValidateUser(sent_userval, sent_irckey) print "-> enter Command Result: " + res if res == "MATCH": print "-> Changing host and identity for " + sent_userval connection.send_raw("CHGIDENT " + sent_nick + " " + str(getUserID(sent_userval))) connection.send_raw("CHGHOST " + sent_nick + " " + getUserHost(sent_userval)) for chan in sent_chans: connection.send_raw(conf["sajoinCmd"] + " " + sent_nick + " " + chan) ircprivs = getIRCPrivs(sent_userval) if ircprivs != "0": connection.privmsg("CHANSERV", IRCPrivCmds[ircprivs] + " " + event.target() + " " + sent_nick) elif res == "DISABLED": connection.privmsg(sent_nick, "You are disabled! You cannot join the member channels unless you are enabled!") if conf["DisabledChan"] != "": connection.privmsg(sent_nick, "You may join " + conf["DisabledChan"] + " and politely ask for your account back...") elif res == "NO_MATCH": connection.privmsg(sent_nick, "Incorrent IRC Key!") elif res == "USER_NOT_FOUND": connection.privmsg(sent_nick, "The username you specified was NOT found!") elif res == "KEY_NOT_SET": connection.privmsg(sent_nick, "Your IRC Key is not set! Please set your IRC Key to join the channels!") elif sent_cmd == "RELOAD" and IsHighStaff(sent_user): print "-> Reloading configuration" connection.privmsg(sent_nick, "Reloading") config_response = botconfig.configure("YES") if config_response != "Error": print "Reload successful" conf = shelve.open(".config") for i,v in config_response.iteritems(): conf[i] = v conf.close() connection.privmsg(sent_nick, "Reload successful") else: connection.privmsg(event.source().split("!")[0], "Reload failed, see bot output for details") elif sent_cmd == "ENABLE" and IsHighStaff(sent_user) and len(event.arguments()[0].split()) == 2: targetuser = event.arguments()[0].split()[1] print "-> Enabling user '" + targetuser + "'" res = EnableUser(targetuser) if res == "XUSER": print "-> Enabling user '" + targetuser + "'" + ": **USER NOT FOUND!**" connection.privmsg(sent_nick, "Username not found!") elif res == "ISENABLED": print "-> Enabling user '" + targetuser + "' : User Already Enabled!" connection.privmsg(sent_nick, "User '" + targetuser + "' is already enabled!") elif res == "SUCCESS": print "-> Enabling user '" + targetuser + "' : User Enabled Successfully!" connection.privmsg(sent_nick, "User '" + targetuser + "' has been enabled!")
def on_privmsg(self, connection, event): # Executed when the bot recieves a PM conf = shelve.open(".config") if (len(event.arguments()) == 0): return try: sent_cmd = event.arguments()[0].split()[0].upper() except IndexError: if len(event.arguments()) <= 1: sent_cmd = event.arguments() else: sent_cmd = event.arguments()[0] sent_nick = event.source().split("!")[0] sent_user = event.source().split("!")[1].split("@")[1].split(".")[0] print "-> PRIVMSG from " + sent_nick + ": " + event.arguments()[0] if sent_cmd == "ENTER": if len(event.arguments()[0].split()) < 4: connection.privmsg( sent_nick, "Not enough arguments for 'enter' command!") connection.privmsg( sent_nick, "Syntax: /msg " + conf["BotNick"] + " enter CHANNEL(,CHANNEL2) USERNAME IRCKEY") else: sent_chan = event.arguments()[0].split()[1] sent_chans = sent_chan.split(",") sent_userval = event.arguments()[0].split()[2] sent_irckey = event.arguments()[0].split()[3] print "-> User(nickname) " + sent_nick + " executed the 'enter' command to enter " + sent_chan + ". Given username: "******"" or sent_irckey == "" or sent_chan == "": connection.privmsg( sent_nick, "Not enough arguments for 'enter' command!") connection.privmsg( sent_nick, "Syntax: /msg " + conf["BotNick"] + " enter CHANNEL(,CHANNEL2) USERNAME IRCKEY") else: res = ValidateUser(sent_userval, sent_irckey) print "-> enter Command Result: " + res if res == "MATCH": print "-> Changing host and identity for " + sent_userval connection.send_raw("CHGIDENT " + sent_nick + " " + str(getUserID(sent_userval))) connection.send_raw("CHGHOST " + sent_nick + " " + getUserHost(sent_userval)) for chan in sent_chans: connection.send_raw(conf["sajoinCmd"] + " " + sent_nick + " " + chan) ircprivs = getIRCPrivs(sent_userval) if ircprivs != "0": connection.privmsg( "CHANSERV", IRCPrivCmds[ircprivs] + " " + event.target() + " " + sent_nick) elif res == "DISABLED": connection.privmsg( sent_nick, "You are disabled! You cannot join the member channels unless you are enabled!" ) if conf["DisabledChan"] != "": connection.privmsg( sent_nick, "You may join " + conf["DisabledChan"] + " and politely ask for your account back...") elif res == "NO_MATCH": connection.privmsg(sent_nick, "Incorrent IRC Key!") elif res == "USER_NOT_FOUND": connection.privmsg( sent_nick, "The username you specified was NOT found!") elif res == "KEY_NOT_SET": connection.privmsg( sent_nick, "Your IRC Key is not set! Please set your IRC Key to join the channels!" ) elif sent_cmd == "RELOAD" and IsHighStaff(sent_user): print "-> Reloading configuration" connection.privmsg(sent_nick, "Reloading") config_response = botconfig.configure("YES") if config_response != "Error": print "Reload successful" conf = shelve.open(".config") for i, v in config_response.iteritems(): conf[i] = v conf.close() connection.privmsg(sent_nick, "Reload successful") else: connection.privmsg( event.source().split("!")[0], "Reload failed, see bot output for details") elif sent_cmd == "ENABLE" and IsHighStaff(sent_user) and len( event.arguments()[0].split()) == 2: targetuser = event.arguments()[0].split()[1] print "-> Enabling user '" + targetuser + "'" res = EnableUser(targetuser) if res == "XUSER": print "-> Enabling user '" + targetuser + "'" + ": **USER NOT FOUND!**" connection.privmsg(sent_nick, "Username not found!") elif res == "ISENABLED": print "-> Enabling user '" + targetuser + "' : User Already Enabled!" connection.privmsg( sent_nick, "User '" + targetuser + "' is already enabled!") elif res == "SUCCESS": print "-> Enabling user '" + targetuser + "' : User Enabled Successfully!" connection.privmsg( sent_nick, "User '" + targetuser + "' has been enabled!")
import time, shelve, os, sys, random, string, MySQLdb, threading, socket, shutil import ircbot, irclib, botconfig, updater, hashlib print "\n*********************************************************************" print "** ZooKeeper " + VERSION + " - Gazelle Server IRC Bot" print "** http://tbsf.me/zookeeper - Written By: eXploytIT - April 2011" print "*********************************************************************" print "** Options: --noupdate || -n : Don't check for updates" print "*********************************************************************\n" ## Check for updates if "--noupdate" not in sys.argv and "-n" not in sys.argv: updater.update(VERSION) ## Validate config file config_response = botconfig.configure() if config_response != "Error": print "*** Config read OK ***" conf = shelve.open(".config") for i,v in config_response.iteritems(): conf[i] = v conf.close() else: sys.exit() ## Make the config dictionary config = shelve.open(".config") ############################################################################################### ############################################################################################### ## Bot settings variables
import time, shelve, os, sys, random, string, MySQLdb, threading, socket, shutil import ircbot, irclib, botconfig, updater, hashlib print "\n*********************************************************************" print "** ZooKeeper " + VERSION + " - Gazelle Server IRC Bot" print "** http://tbsf.me/zookeeper - Written By: eXploytIT - April 2011" print "*********************************************************************" print "** Options: --noupdate || -n : Don't check for updates" print "*********************************************************************\n" ## Check for updates if "--noupdate" not in sys.argv and "-n" not in sys.argv: updater.update(VERSION) ## Validate config file config_response = botconfig.configure() if config_response != "Error": print "*** Config read OK ***" conf = shelve.open(".config") for i, v in config_response.iteritems(): conf[i] = v conf.close() else: sys.exit() ## Make the config dictionary config = shelve.open(".config") ############################################################################################### ############################################################################################### ## Bot settings variables