-
Notifications
You must be signed in to change notification settings - Fork 2
API overview
Some API overview:
Modules will define a mappings variable that holds an iterable of util.Mapping objects:
mappings = (Mapping(type=[listOfTypes], command=commandname, regex=compiledRegEx, function=functionname),)
The Mapping object:
def __init__(self, type=None, command=None, regex=None, function = dummyfunc):
# type = [list of strings], command=string, regex=compiledRegExobject, function=a defined function that has the signature:
# def dummyfunc(event, botinstance, dbqueue):
The functionality and nature of types isn't well defined at this point.
The function used in the mapper object will be called when the conditions of the mapper are met:
- When type is matched
- When command is matched, or
- When regex matches text
In that order (probably.)
The module function is passed 3 objects:
The event object:
class Event:
def __init__(self, type=None, args=None, data=None, user=None, channel=None, msg=None, modes=None, setting=None):
self.type = type
self.args = args
self.data = data #misc used for stuff like created(self, when), and myInfo(self, servername, version, umodes, cmodes), etc
#I wonder if we can merge args and data
#should use this for one of the kickee or kicker
self.user = user
self.channel = channel
self.msg = msg
self.modes = modes
self.setting = setting #True for + modes
Some or none of these attributes will be defined depending on the type of event that is fired. See pyBBM.py source code for details.
botinstance is the actual bot object. More specifically, it is a twisted protocol object (probably), you can call it's .msg() and other type of methods to do as you please.
dbqueue allows access to the internal BBM sqlite database.
You should put SQL "requests" (statements) onto the queue like so:
dbqueue.put(query, returnq, params)
#or
dbqueue.put(query, returnq, params)
#if you aren't using param based query
The query string will be passed to dbapi2.execute, and the resulting row(s) object will be .put() onto the returnq which should be a Queue.Queue() object.
You should then returnq.get() the results. There will only ever be one item on the returnq.
It will be a tuple that has the first item as either "SUCCESS" or "ERROR", the second item will be the resulting row(s) in a list if SUCCESS else it will be the exception if ERROR