MVpybot Major Update

There 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:


def register():
 registerfunction('ping', ping)
 addhelp('ping', help_ping)

def ping():
 print "ping called"
 if (len(cmd)<2):
  return('PRIVMSG %s :Incorrect usage. Syntax: ping (4|6) <address>.' %(channel))
  if cmd[1]=='4' or cmd[1]=='6':
   if cmd[1]=='4':

    for part in outparts:
     outstuff+='PRIVMSG %s :%s\n' %(channel,part) 

   if cmd[1]=='6':

    for part in outparts:
     outstuff+='PRIVMSG %s :%s\n' %(channel,part)
   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.

Function Usage

registerfunction() usage:

registerfunction('command', function)

where ‘command’ is the command that the user would use to access this function, and “function” is the actual python function that you have defined in your module. See the ping example above for a usage example.

addlistener() usage:

addlistener('type', function)

For addlistener(), ‘type’ is a string denoting the type of event to call the function on, such as “any” or “privmsg”. “function” works the same as with registerfunction().

addhelp() usage:

addhelp('command', function)

‘command’ is the command that the user will access help on (eg, if ‘command’ was ‘mycommand’, the user would use ‘help mycommand’ to read the help.) Function works the same as the others.

Other Notes

All plugins go in the “modules” folder now. There are no longer separate folders for different types of plugins.

I have not yet rewritten the on-the-fly module management commands (enabling, disabling, reloading, etc) so you will not be able to use these with the new system until I feel like rewriting them.

Leave a Reply