MVpybot Major Update
Saturday, June 26th, 2010There is a somewhat-major bot update in the works. The plugins system has been completely redone. Instead of plugin files being used for whatever functions can be found in them, they now have to explicitly register functions. Here is an example, the rewritten ping plugin:
#!/usr/bin/python def register(): registerfunction('ping', ping) addhelp('ping', help_ping) def ping(): outstuff='' print "ping called" if (len(cmd)<2): return('PRIVMSG %s :Incorrect usage. Syntax: ping (4|6) <address>.' %(channel)) else: if cmd[1]=='4' or cmd[1]=='6': if cmd[1]=='4': output=syscmd(['ping','-c','5','-i','0.2',cmd[2]]) outsplit=output.split('\n') outparts=outsplit[-3:-1] for part in outparts: outstuff+='PRIVMSG %s :%s\n' %(channel,part) if cmd[1]=='6': output=syscmd(['ping6','-c','5','-i','0.2',cmd[2]]) outsplit=output.split('\n') outparts=outsplit[-3:-1] for part in outparts: outstuff+='PRIVMSG %s :%s\n' %(channel,part) return(outstuff) else: return('PRIVMSG %s :Error: protocol must be either 4 or 6' %channel) def help_ping(): return('PRIVMSG %s :Pings an internet address. Usage: ping (4|6) <address>.' %(channel))
A plugin’s register() function is called when the plugin is loaded. It can use registerfunction(), addlistener(), and addhelp(). You can use each function as many times as you want, in case you have multiple functions and/or listeners, or if you want to include help with your plugin.
Read more to find out how to use the new plugin features.