bot.status = "dispatch" event.bind(bot) if event.iscommand or event.hascc() or event.wouldmatchre(): try: event.iscommand = True if not event.options: event.makeoptions() try: result = event.execute() except NoSuchCommand as ex: logging.warn("no such command: %s" % event.usercmnd) if event.giveresponse: event.reply("no %s command found" % str(ex).strip()) event.launched() ; event.ready() except Exception as ex: handle_exception() else: logging.debug("dispatch - no go for %s" % event.auth or event.userhost) speechrunner.put(3, "SPEECH", event) event.launched() ; event.ready() ## register callback last_callbacks.add('PRIVMSG', dispatch, predispatch, speed=3) last_callbacks.add('MESSAGE', dispatch, predispatch) last_callbacks.add('BLIP_SUBMITTED', dispatch, predispatch) last_callbacks.add('WEB', dispatch, predispatch) last_callbacks.add('CONSOLE', dispatch, predispatch) last_callbacks.add('DCC', dispatch, predispatch) last_callbacks.add('DISPATCH', dispatch, predispatch) last_callbacks.add('EVENT', dispatch, predispatch) last_callbacks.add('CONVORE', dispatch, predispatch) last_callbacks.add('TORNADO', dispatch, predispatch)
if twittername: return True except Exception as ex: pass return False def twittercb(bot, event): event.dontbind = False event.bind(force=True) try: twittername = event.chan.data.twittername except Exception as ex: handle_exception() ; twittername = None try: username = event.origin ; logging.info("using origin %s" % event.origin) except Exception as ex: handle_exception() ; username = None if twittername: try: twitter_out(twittername or username or "tl", event.txt, event) except Exception as ex: logging.warn("error posting to twitter: %s" % str(ex)) last_callbacks.add("RSS", twittercb, twitterpre) ## twitter command def handle_twitter(bot, ievent): """ arguments: <txt> - send a twitter message. """ go = getauth() if not go: ievent.reply("the twitter plugin needs the credentials.py file in the .tl/config dir. see the examples directory") ; return txt = ievent.rest if ievent.ispipelined: txt = ievent.wait() if not txt: ievent.missing('<txt>') ; return else: if ievent.chan: taglist = ievent.chan.data.taglist if taglist: