Python irssi bot [Python]
This is is a work in progress. It is a simple minded bot for irssi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import irssi import os import re import inspect class Bot: about = "I am a simple minded bot written by tomfmason. I plan on adding features today." #public message def msg_public(self,server,msg,nick,address,target): self.dispatch(server, msg, nick, address, target, True) #private message def msg_private(self,server,msg,nick,address): self.dispatch(server, msg, nick, address, nick) def build_commands(self): self.commands = {} methods = inspect.getmembers(self) for m in methods: if m[0].find("command_") >= 0 and inspect.ismethod(m[1]): self.commands[m[0].split("command_")[1]] = m[1] def dispatch(self,server, msg, nick, address, target, public=False): self.build_commands() for command in self.commands.keys(): if msg.find(command) >= 0: return self.commands[command](server, msg, nick, address, target, public) def send_msg(self, message,server, nick, target, public=False): if public: server.command("/MSG %s %s: %s" % (target, nick, message)) else: server.command("/MSG %s %s" % (nick, message)) def command_about(self,server, msg, nick, address, target, public): self.send_msg(self.about,server, nick, target, public) bot = Bot() irssi.signal_add("message public", bot.msg_public) irssi.signal_add("message private", bot.msg_private) |

Comments
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval
Comment awaiting approval