def _restoreEvents(self, irc): try: pkl = open(filename, 'rb') try: eventdict = pickle.load(pkl) except Exception as e: self.log.debug('Unable to load pickled data: %s', e) return finally: pkl.close() except IOError as e: self.log.debug('Unable to open pickle file: %s', e) return for name, event in eventdict.items(): ircobj = callbacks.ReplyIrcProxy(irc, event['msg']) try: if event['type'] == 'single': # non-repeating event n = None if schedule.schedule.counter > int(name): # counter not reset, we're probably reloading the plugin # though we'll never know for sure, because other # plugins can schedule stuff, too. n = int(name) self._add(ircobj, event['msg'], event['time'], event['command'], n) elif event['type'] == 'repeat': # repeating event self._repeat(ircobj, event['msg'], name, event['time'], event['command'], False) except AssertionError as e: if str(e) == 'An event with the same name has already been scheduled.': # we must be reloading the plugin, event is still scheduled self.log.info('Event %s already exists, adding to dict.', name) self.events[name] = event else: raise
def inFilter(self, irc, msg): orig_msg = msg if msg.command == "PRIVMSG" and msg.args[0].lower() == irc.nick.lower( ): recipient, text = msg.args new_text = self.addressed(recipient, text, irc, msg) if new_text: irc = callbacks.ReplyIrcProxy(irc, msg) if (irc.nick.lower() == msg.args[0]): self.doPrivmsg(irc, msg) return orig_msg
def inFilter(self, irc, msg): if msg.command != "PRIVMSG": return msg if not conf.supybot.defaultIgnore(): return msg text = msg.args[1].strip() if len(text) < 6: return msg user = get_user(msg) channel = self.__getChannel(msg.args[0]) reply_chars = self.__getReplyChars(channel) my_commands = self.listCommands() cmd = self.__getCommand(text, channel) if cmd not in my_commands: return msg if user: if not channel and text[0] == self.registryValue("prefixchar"): msg.args = (msg.args[0], text[1:]) return msg if channel: if text[0] not in reply_chars: return msg # if not hasattr(irc, 'reply'): # irc = callbacks.ReplyIrcProxy(irc, msg) # self.doPrivmsg(irc, msg) else: if text[1] in reply_chars: msg.args = (msg.args[0], text[1:]) irc = callbacks.ReplyIrcProxy(irc, msg) self.doPrivmsg(irc, msg) return msg
def _restoreEvents(self, irc): try: pkl = open(filename, 'rb') try: eventdict = pickle.load(pkl) except Exception, e: self.log.debug('Unable to load pickled data: %s', e) return finally: pkl.close() except IOError, e: self.log.debug('Unable to open pickle file: %s', e) return for name, event in eventdict.iteritems(): ircobj = callbacks.ReplyIrcProxy(irc, event['msg']) try: if event['type'] == 'single': # non-repeating event n = None if schedule.schedule.counter > int(name): # counter not reset, we're probably reloading the plugin # though we'll never know for sure, because other # plugins can schedule stuff, too. n = int(name) self._add(ircobj, event['msg'], event['time'], event['command'], n) elif event['type'] == 'repeat': # repeating event self._repeat(ircobj, event['msg'], name, event['time'], event['command'], False) except AssertionError, e: if str(
def f(): # If the network isn't available, pick any other one irc = world.getIrc(network) or world.ircs[0] replyIrc = callbacks.ReplyIrcProxy(irc, msg) replyIrc.reply(_('Reminder: %s') % text, msg=msg, prefixNick=True) del self.events[str(f.eventId)]