diff --git a/README b/README index 03249c0..cc9f839 100644 --- a/README +++ b/README @@ -2,9 +2,13 @@ http://twistedmatrix.com/documents/current/words/examples/ircLogBot.py To Run: -$ python ekan0ra.py +$ python ekan0ra.py Options: startclass in the bot's pm. endclass in bot's pm. pingall - pingall: [message] +give ops to some user - right: +take ops from user - unright: +Give voice to some body- voice: +Removes voice of some body- unvoice: diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..aa22f0c --- /dev/null +++ b/config.ini @@ -0,0 +1,4 @@ +[SectionOne] +Host: irc.freenode.net +Port: 6667 +Channel: sheesh diff --git a/ekan0ra.py b/ekan0ra.py index 7067443..4bac72e 100644 --- a/ekan0ra.py +++ b/ekan0ra.py @@ -8,8 +8,25 @@ import time, sys, os import datetime import random +import ConfigParser now = datetime.datetime.now() +Config = ConfigParser.ConfigParser() +Config.read("config.ini") + +def ConfigSectionMap(section): + values = {} + options = Config.options(section) + for option in options: + try: + values[option] = Config.get(section, option) + if values[option] == -1: + DebugPrint("skip: %s" % option) + except: + print("exception on %s!" % option) + values[option] = None + return values + class MessageLogger: """ @@ -71,7 +88,7 @@ def upload_logs(self, channel): os.system(cmd) #msg = 'The logs are updated to: http://sayanchowdhury.dgplug.org/irclogs/%s'%self.filename #self.say(channel, msg) - # callbacks for events + # callbacks for events def signedOn(self): """Called when bot has succesfully signed on to server.""" @@ -104,6 +121,27 @@ def privmsg(self, user, channel, msg): self.pingmsg = msg.lower().lstrip('pingall:') self.names(channel).addCallback(self.pingall) + # Give right to anybody + if msg.lower().startswith('right:') and user_cond: + msgs = msg.lower().lstrip('right: ') + self.mode(channel,True,"+o",limit=None,user=msgs, mask=None) + + # Take right from anybody + if msg.lower().startswith('unright:') and user_cond: + msgs = msg.lower().lstrip('unright: ') + self.mode(channel,True,"-o",limit=None,user=msgs, mask=None) + + #Give voice to anybody + if msg.lower().startswith('voice:') and user_cond: + msgs = msg.lower().lstrip('voice:') + self.mode(channel,True,"+v",limit=None,user=msgs, mask=None) + + #Take voice of anybody + if msg.lower().startswith('unvoice:') and user_cond: + msgs = msg.lower().lstrip('unvoice:') + self.mode(channel,True,"-v",limit=None,user=msgs, mask=None) + + def action(self, user, channel, msg): """This will get called when the bot sees someone do an action.""" user = user.split('!', 1)[0] @@ -189,10 +227,10 @@ def clientConnectionFailed(self, connector, reason): log.startLogging(sys.stdout) # create factory protocol and application - f = LogBotFactory(sys.argv[1]) + f = LogBotFactory(ConfigSectionMap("SectionOne")['channel']) # connect factory to this host and port - reactor.connectTCP("irc.freenode.net", 6667, f) + reactor.connectTCP(ConfigSectionMap("SectionOne")['host'], int(ConfigSectionMap("SectionOne")['port']), f) # run bot reactor.run()