예제 #1
0
 def callback(self, cb, bot, event):
     """  do the actual callback with provided bot and event as arguments. """
     if event.stop: logging.info("callbacks - event is stopped.") ; return
     event.calledfrom = cb.modname
     try:
         if event.status == "done":
             logging.debug("callback - event is done .. ignoring")
             return
         if event.chan and cb.plugname in event.chan.data.denyplug:
             logging.warn("%s denied in %s - %s" % (cb.modname, event.channel, event.auth))
             return
         if cb.prereq:
             logging.debug('callbacks - executing in loop %s' % str(cb.prereq))
             if not cb.prereq(bot, event): return
         if not cb.func: return
         if event.isremote(): logging.info('%s - executing REMOTE %s - %s' % (bot.name, getname(cb.func), event.cbtype))
         elif event.cbtype == "TICK": logging.debug('LOCAL - %s - executing %s - %s' % (bot.name, getname(cb.func), event.cbtype))
         else: logging.info('%s - executing %s - %s' % (bot.name, getname(cb.func), event.cbtype))
         event.iscallback = True
         logging.debug("callback - %s - trail - %s" % (getname(cb.func), callstack(sys._getframe())[::-1]))
         #if not event.direct and cb.threaded and not bot.isgae: start_new_thread(cb.func, (bot, event))
         if cb.threaded and not bot.isgae: start_new_thread(cb.func, (bot, event))
         else:
             if bot.isgae or event.direct: cb.func(bot, event) 
             else:
                 from runner import callbackrunner
                 callbackrunner.put(cb.modname, cb.func, bot, event)
         return True
     except Exception, ex:
         handle_exception()
예제 #2
0
 def callback(self, cb, bot, event):
     """  do the actual callback with provided bot and event as arguments. """
     if event.stop:
         logging.info("callbacks - event is stopped.")
         return
     event.calledfrom = cb.modname
     try:
         if event.status == "done":
             logging.debug("callback - event is done .. ignoring")
             return
         if event.chan and cb.plugname in event.chan.data.denyplug:
             logging.warn("%s denied in %s - %s" %
                          (cb.modname, event.channel, event.auth))
             return
         if cb.prereq:
             logging.debug('callbacks - executing in loop %s' %
                           str(cb.prereq))
             if not cb.prereq(bot, event): return
         if not cb.func: return
         if event.isremote():
             logging.info('%s - executing REMOTE %s - %s' %
                          (bot.name, getname(cb.func), event.cbtype))
         elif event.cbtype == "TICK":
             logging.debug('LOCAL - %s - executing %s - %s' %
                           (bot.name, getname(cb.func), event.cbtype))
         else:
             logging.info('%s - executing %s - %s' %
                          (bot.name, getname(cb.func), event.cbtype))
         event.iscallback = True
         logging.debug("callback - %s - trail - %s" %
                       (getname(cb.func), callstack(sys._getframe())[::-1]))
         #if not event.direct and cb.threaded and not bot.isgae: start_new_thread(cb.func, (bot, event))
         if cb.threaded and not bot.isgae:
             start_new_thread(cb.func, (bot, event))
         else:
             if bot.isgae or event.direct: cb.func(bot, event)
             else:
                 from runner import callbackrunner
                 callbackrunner.put(cb.modname, cb.func, bot, event)
         return True
     except Exception, ex:
         handle_exception()
예제 #3
0
 def callback(self, cb, bot, event):
     """  do the actual callback with provided bot and event as arguments. """
     #if event.stop: logging.info("callbacks -  event is stopped.") ; return
     if event.cbtype in bot.nocbs and not cb.force: logging.warn("%s in nocbs list, skipping" % event.cbtype) ; return
     event.calledfrom = cb.modname
     if not event.bonded: event.bind(bot)
     try:
         if event.status == "done":
             if not event.nolog: logging.debug("callback - event is done .. ignoring")
             stats.upitem("ignored")
             return
         if event.chan and cb.plugname in event.chan.data.denyplug:
             logging.warn("%s denied in %s - %s" % (cb.modname, event.channel, event.auth))
             stats.upitem("denied")
             return
         if cb.prereq:
             if not event.nolog: logging.info('executing in loop %s' % str(cb.prereq))
             if not cb.prereq(bot, event): return
         if not cb.func: return
         if event.isremote(): logging.info('%s - executing REMOTE %s - %s' % (bot.cfg.name, getname(cb.func), event.cbtype))
         elif not event.nolog: logging.info('%s - executing %s - %s' % (bot.cfg.name, getname(cb.func), event.cbtype))
         event.iscallback = True
         if not event.nolog: logging.debug("%s - %s - trail - %s" % (bot.cfg.name, getname(cb.func), callstack(sys._getframe())[::-1]))
         time.sleep(0.01)
         if cb.threaded: logging.info("PURE THREAD STARTED %s" % str(cb.func)) ; start_new_thread(cb.func, (bot, event))
         else:
             display = "%s/%s/%s" % (cb.plugname, bot.cfg.name, event.nick or event.channel)
             if event.cbtype == "API":
                 from runner import apirunner
                 apirunner.put(event.speed or cb.speed, display, cb.func, bot, event)
             elif  event.direct: cb.func(bot, event) 
             elif not event.dolong:
                 from runner import callbackrunner
                 callbackrunner.put(event.speed or cb.speed, display, cb.func, bot, event)
             else:
                 from runner import longrunner
                 longrunner.put(event.speed or cb.speed, display, cb.func, bot, event)
         stats.upitem(event.cbtype)
         stats.upitem("nrcallbacks")
         return True
     except Exception, ex:
         handle_exception()
예제 #4
0
 def callback(self, cb, bot, event):
     """  do the actual callback with provided bot and event as arguments. """
     #if event.stop: logging.info("callbacks -  event is stopped.") ; return
     if event.cbtype in bot.nocbs and not cb.force:
         logging.warn("%s in nocbs list, skipping" % event.cbtype)
         return
     event.calledfrom = cb.modname
     if not event.bonded: event.bind(bot)
     try:
         if event.status == "done":
             if not event.nolog:
                 logging.debug("callback - event is done .. ignoring")
             stats.upitem("ignored")
             return
         if event.chan and cb.plugname in event.chan.data.denyplug:
             logging.warn("%s denied in %s - %s" %
                          (cb.modname, event.channel, event.auth))
             stats.upitem("denied")
             return
         if cb.prereq:
             if not event.nolog:
                 logging.info('executing in loop %s' % str(cb.prereq))
             if not cb.prereq(bot, event): return
         if not cb.func: return
         if event.isremote():
             logging.info('%s - executing REMOTE %s - %s' %
                          (bot.cfg.name, getname(cb.func), event.cbtype))
         elif not event.nolog:
             logging.info('%s - executing %s - %s' %
                          (bot.cfg.name, getname(cb.func), event.cbtype))
         event.iscallback = True
         if not event.nolog:
             logging.debug("%s - %s - trail - %s" %
                           (bot.cfg.name, getname(
                               cb.func), callstack(sys._getframe())[::-1]))
         time.sleep(0.01)
         if cb.threaded:
             logging.info("PURE THREAD STARTED %s" % str(cb.func))
             start_new_thread(cb.func, (bot, event))
         else:
             display = "%s/%s/%s" % (cb.plugname, bot.cfg.name, event.nick
                                     or event.channel)
             if event.cbtype == "API":
                 from runner import apirunner
                 apirunner.put(event.speed or cb.speed, display, cb.func,
                               bot, event)
             elif event.direct:
                 cb.func(bot, event)
             elif not event.dolong:
                 from runner import callbackrunner
                 callbackrunner.put(event.speed or cb.speed, display,
                                    cb.func, bot, event)
             else:
                 from runner import longrunner
                 longrunner.put(event.speed or cb.speed, display, cb.func,
                                bot, event)
         stats.upitem(event.cbtype)
         stats.upitem("nrcallbacks")
         return True
     except Exception, ex:
         handle_exception()