예제 #1
0
파일: bot.py 프로젝트: buzzworkers/tl
 def __init__(self, cfg, *args, **kwargs):
     if not cfg.user: raise NoUserProvided("please make sure the user config variable is set in %s (or use -u)"  % cfg.cfile)
     BotBase.__init__(self, cfg, *args, **kwargs)
     self.type = "xmpp"
     self.jids = {}
     self.xmpp = sleekxmpp.ClientXMPP(cfg.user, cfg.password)
     self.xmpp.whitespace_keepalive = False
     self.xmpp.add_event_handler("session_start", self.session_start)
     self.xmpp.add_event_handler("session_end", self.session_end)
     self.xmpp.add_event_handler("message", self.handle_message)
     self.xmpp.add_event_handler('disconnected', self.handle_disconnected)
     self.xmpp.add_event_handler('connected', self.handle_connected)
     self.xmpp.add_event_handler('presence_available', self.handle_presence)
     self.xmpp.add_event_handler('presence_dnd', self.handle_presence)
     self.xmpp.add_event_handler('presence_xa', self.handle_presence)
     self.xmpp.add_event_handler('presence_chat', self.handle_presence)
     self.xmpp.add_event_handler('presence_away', self.handle_presence)   
     self.xmpp.add_event_handler('presence_unavailable', self.handle_presence) 
     self.xmpp.add_event_handler('presence_subscribe', self.handle_presence)   
     self.xmpp.add_event_handler('presence_subscribed', self.handle_presence)  
     self.xmpp.add_event_handler('presence_unsubscribe', self.handle_presence) 
     self.xmpp.add_event_handler('presence_unsubscribed', self.handle_presence)
     self.xmpp.add_event_handler('groupchat_direct_invite', self.handle_groupinvite)
     self.xmpp.add_event_handler('groupchat_invite', self.handle_groupinvite)
     self.xmpp.add_event_handler('groupchat_message', self.handle_message)
     self.xmpp.add_event_handler('groupchat_presence', self.handle_presence)
     self.xmpp.add_event_handler('groupchat_subject', self.handle_presence)
     self.xmpp.add_event_handler('failed_auth', self.handle_failedauth)
     self.xmpp.exception = self.exception
     self.xmpp.use_signals()
     if cfg.openfire:
         import ssl
         self.xmpp.ssl_version = ssl.PROTOCOL_SSLv3
예제 #2
0
파일: bot.py 프로젝트: buzzworkers/tl
 def start(self, connect=True, *args, **kwargs):
     BotBase.start(self, False)
     try:
         if connect:
             logging.warn("connecting to %s using %s" % (self.cfg.server, self.cfg.user)) 
             self.xmpp.connect((self.cfg.server, self.cfg.port or 5222))
         self.xmpp.process(block=True)
     except Exception as ex: logging.error(str(ex))
     return True
예제 #3
0
파일: irc.py 프로젝트: buzzworkers/tl
 def __init__(self, cfg=None, users=None, plugs=None, *args, **kwargs):
     BotBase.__init__(self, cfg, users, plugs, *args, **kwargs)
     BotBase.setstate(self)
     self.type = 'irc'
     self.fsock = None
     self.oldsock = None
     self.sock = None
     self.reconnectcount = 0
     self.pongcheck = 0
     self.nickchanged = False
     self.noauto433 = False
     if self.state:
         if 'alternick' not in self.state: self.state['alternick'] = self.cfg['alternick']
         if 'no-op' not in self.state: self.state['no-op'] = []
     self.nicks401 = []
     self.cfg.port = self.cfg.port or 6667
     self.connecttime = 0
     self.encoding = 'utf-8'
     self.blocking = 1
     self.lastoutput = 0
     self.splitted = []
     if not self.cfg.server: self.cfg.server = self.cfg.host or "localhost"
     assert self.cfg.port
     assert self.cfg.server
예제 #4
0
파일: admin.py 프로젝트: buzzworkers/tl
def handle_adminmakebot(bot, ievent):
    """ arguments: <botname> <bottype> - create a bot of given type. """
    try: botname, bottype = ievent.args
    except ValueError: ievent.missing("<name> <type>") ; return
    newbot = BotBase()
    newbot.botname = botname
    newbot.type = bottype
    newbot.owner = bot.owner
    newbot.save()
    ievent.done()
예제 #5
0
파일: bot.py 프로젝트: buzzworkers/tl
 def __init__(self, cfg=None, users=None, plugs=None, botname=None, *args, **kwargs):
     BotBase.__init__(self, cfg, users, plugs, botname, *args, **kwargs)
     self.type = "console"
예제 #6
0
파일: bot.py 프로젝트: buzzworkers/tl
 def __init__(self, username):
     BotBase.__init__(self, botname="twitter-%s" % username)
     self.username = username
     self.users = TwitterUsers(getdatadir() + os.sep + "twitter" + os.sep + "users")
예제 #7
0
파일: bot.py 프로젝트: buzzworkers/tl
 def __init__(self, cfg=None, users=None, plugs=None, botname="tornado-bot", *args, **kwargs):
     BotBase.__init__(self, cfg, users, plugs, botname, bottype="tornado", *args, **kwargs)
     assert self.cfg
     self.cfg.type = "tornado"
     self.websockets = {}