def __init__(self, irc): self.__parent = super(Bantracker, self) self.__parent.__init__(irc) self.default_irc = irc self.lastMsgs = {} self.lastStates = {} self.replies = {} self.logs = ircutils.IrcDict() self.nicks = {} self.hosts = {} self.bans = ircutils.IrcDict() self.thread_timer = threading.Timer(10.0, dequeue, args=(self,irc)) self.thread_timer.start() db = self.registryValue('database') if db: self.db = sqlite3.connect(db) else: self.db = None self.get_bans(irc) self.get_nicks(irc) self.pendingReviews = PersistentCache('bt.reviews.db') self.pendingReviews.open() self._banreviewfix() # add scheduled event for check bans that need review, check every hour try: schedule.removeEvent(self.name()) except: pass schedule.addPeriodicEvent(lambda : self.reviewBans(irc), 60*60, name=self.name())
def __init__(self, irc): self.__parent = super(Topic, self) self.__parent.__init__(irc) self.undos = ircutils.IrcDict() self.redos = ircutils.IrcDict() self.lastTopics = ircutils.IrcDict() self.watchingFor332 = ircutils.IrcSet()
def __init__(self, irc): self.__parent = super(Ctcp, self) self.__parent.__init__(irc) self.ignores = ircutils.IrcDict() self.floods = ircutils.FloodQueue(conf.supybot.abuse.flood.interval()) conf.supybot.abuse.flood.interval.addCallback( self.setFloodQueueTimeout)
def __init__(self, irc): self.__parent = super(Mantis, self) self.__parent.__init__(irc) self.saidBugs = ircutils.IrcDict() sayTimeout = self.registryValue('bugSnarferTimeout') for k in irc.state.channels.keys(): self.saidBugs[k] = TimeoutQueue(sayTimeout) self.urlbase = self.registryValue('urlbase') self.privateurlbase = self.registryValue('privateurlbase') if self.privateurlbase != "": serviceUrl = self.privateurlbase + '/api/soap/mantisconnect.php' else: serviceUrl = self.urlbase + '/api/soap/mantisconnect.php' self.server = SOAPProxy(serviceUrl)._ns(namespace) self.username = self.registryValue('username') self.password = self.registryValue('password') self.oldperiodic = self.registryValue('bugPeriodicCheck') self.irc = irc self.lastBug = 0 bugPeriodicCheck = self.oldperiodic if bugPeriodicCheck > 0: schedule.addPeriodicEvent(self._bugPeriodicCheck, bugPeriodicCheck, name=self.name()) reload(sys) sys.setdefaultencoding('utf-8')
def version(self, irc, msg, args, channel, optlist): """[<channel>] [--nicks] Sends a CTCP VERSION to <channel>, returning the various version strings returned. It waits for 10 seconds before returning the versions received at that point. If --nicks is given, nicks are associated with the version strings; otherwise, only the version strings are given. """ self.versions = ircutils.IrcDict() nicks = False for (option, arg) in optlist: if option == 'nicks': nicks = True irc.queueMsg(ircmsgs.privmsg(channel, '\x01VERSION\x01')) def doReply(): if self.versions: L = [] for (reply, nickslist) in self.versions.iteritems(): if nicks: L.append( format('%L responded with %q', nickslist, reply)) else: L.append(reply) irc.reply(format('%L', L)) else: irc.reply('I received no version responses.') wait = self.registryValue('versionWait') schedule.addEvent(doReply, time.time() + wait)
def __init__(self, irc): self.__parent = super(Roundup, self) self.__parent.__init__(irc) self.saidBugs = ircutils.IrcDict() self.saidAttachments = ircutils.IrcDict() sayTimeout = self.registryValue('bugSnarferTimeout') for k in irc.state.channels.keys(): self.saidBugs[k] = TimeoutQueue(sayTimeout) self.saidAttachments[k] = TimeoutQueue(sayTimeout) #period = self.registryValue('mboxPollTimeout') #schedule.addPeriodicEvent(self._pollMbox, period, name=self.name(), # now=False) for name in self.registryValue('roundups'): registerRoundup(name) reload(sys) sys.setdefaultencoding('utf-8')
def __init__(self, irc): self.__parent = super(Later, self) self.__parent.__init__(irc) self._notes = ircutils.IrcDict() self.wildcards = [] self.filename = conf.supybot.directories.data.dirize('Later.db') self._openNotes()
def __init__(self, irc): self.__parent = super(Topic, self) self.__parent.__init__(irc) self.undos = ircutils.IrcDict() self.redos = ircutils.IrcDict() self.lastTopics = ircutils.IrcDict() self.watchingFor332 = ircutils.IrcSet() try: pkl = open(filename, 'rb') try: self.undos = pickle.load(pkl) self.redos = pickle.load(pkl) self.lastTopics = pickle.load(pkl) self.watchingFor332 = pickle.load(pkl) except Exception, e: self.log.debug('Unable to load pickled data: %s', e) pkl.close()
def __init__(self, irc): self.__parent = super(Relay, self) self.__parent.__init__(irc) self._whois = {} self.lastmsg = {} self.ircstates = {} self.queuedTopics = MultiSet() self.lastRelayMsgs = ircutils.IrcDict()
def test(self): d = ircutils.IrcDict() d['#FOO'] = 'bar' self.assertEqual(d['#FOO'], 'bar') self.assertEqual(d['#Foo'], 'bar') self.assertEqual(d['#foo'], 'bar') del d['#fOO'] d['jemfinch{}'] = 'bar' self.assertEqual(d['jemfinch{}'], 'bar') self.assertEqual(d['jemfinch[]'], 'bar') self.assertEqual(d['JEMFINCH[]'], 'bar')
def __init__(self, irc): self.__parent = super(Redmine, self) self.__parent.__init__(irc) self.saidBugs = ircutils.IrcDict() sayTimeout = self.registryValue('bugSnarferTimeout') for k in irc.state.channels.keys(): self.saidBugs[k] = TimeoutQueue(sayTimeout) self.url = self.registryValue('urlbase') self.auth = BasicAuth(self.registryValue('apikey'), str(random.random())) self.resource = Resource(self.url, filters=[self.auth])
def getLog(self, irc, channel): self.checkLogNames() try: logs = self.logs[irc] except KeyError: logs = ircutils.IrcDict() self.logs[irc] = logs if channel in logs: return logs[channel] else: try: name = self.getLogName(channel) logDir = self.getLogDir(irc, channel) log = file(os.path.join(logDir, name), 'a') logs[channel] = log return log except IOError: self.log.exception('Error opening log:') return FakeLog()
def testContains(self): d = ircutils.IrcDict() d['#FOO'] = None self.failUnless('#foo' in d) d['#fOOBAR[]'] = None self.failUnless('#foobar{}' in d)
def __init__(self, filename): self.dbs = ircutils.IrcDict() self.filename = filename
def testContains(self): d = ircutils.IrcDict() d['#FOO'] = None self.assertTrue('#foo' in d) d['#fOOBAR[]'] = None self.assertTrue('#foobar{}' in d)
def testCopyable(self): d = ircutils.IrcDict() d['foo'] = 'bar' self.assertTrue(d == copy.copy(d)) self.assertTrue(d == copy.deepcopy(d))
def __init__(self, filename): self.engines = ircutils.IrcDict() self.filename = filename.replace('sqlite3', 'sqlalchemy')
def __init__(self, filename): self.engines = ircutils.IrcDict() self.filename = filename self.sqlalchemy = sqlalchemy
def __init__(self, filename, engine): self.dbs = ircutils.IrcDict() self.filename = filename self.engine = engine
def __init__(self, suffix='.db'): self.dbCache = ircutils.IrcDict() suffix = self.suffix if self.suffix and self.suffix[0] != '.': suffix = '.' + suffix self.suffix = suffix
def __init__(self): self.noFlush = False self.filename = None self.channels = ircutils.IrcDict()
def __init__(self): self.channels = ircutils.IrcDict()
def __init__(self, irc): self.__parent = super(Filter, self) self.__parent.__init__(irc) self.outFilters = ircutils.IrcDict()
def testGet(self): d = ircutils.IrcDict() self.assertEqual(d.get('#FOO'), None) d['#foo'] = 1 self.assertEqual(d.get('#FOO'), 1)
def testSetdefault(self): d = ircutils.IrcDict() d.setdefault('#FOO', []).append(1) self.assertEqual(d['#foo'], [1]) self.assertEqual(d['#fOO'], [1]) self.assertEqual(d['#FOO'], [1])
def testKeys(self): d = ircutils.IrcDict() self.assertEqual(d.keys(), [])
wrappers = ircutils.IrcDict({ 'admin': admin, 'anything': anything, 'banmask': getBanmask, 'boolean': getBoolean, 'callerInGivenChannel': callerInGivenChannel, 'isGranted': getHaveHalfopPlus, # Backward compatibility 'capability': getSomethingNoSpaces, 'channel': getChannel, 'channelOrGlobal': getChannelOrGlobal, 'channelDb': getChannelDb, 'checkCapability': checkCapability, 'checkCapabilityButIgnoreOwner': checkCapabilityButIgnoreOwner, 'checkChannelCapability': checkChannelCapability, 'color': getIrcColor, 'commandName': getCommandName, 'email': getEmail, 'expiry': getExpiry, 'filename': getSomething, # XXX Check for validity. 'float': getFloat, 'glob': getGlob, 'halfop': getHalfop, 'haveHalfop': getHaveHalfop, 'haveHalfop+': getHaveHalfopPlus, 'haveOp': getHaveOp, 'haveOp+': getHaveOp, # We don't handle modes greater than op. 'haveVoice': getHaveVoice, 'haveVoice+': getHaveVoicePlus, 'hostmask': getHostmask, 'httpUrl': getHttpUrl, 'id': getId, 'inChannel': inChannel, 'index': getIndex, 'int': getInt, 'ip': getIp, 'letter': getLetter, 'literal': getLiteral, 'long': getLong, 'lowered': getLowered, 'matches': getMatch, 'networkIrc': getNetworkIrc, 'nick': getNick, 'nickInChannel': nickInChannel, 'nonInt': getNonInt, 'nonNegativeInt': getNonNegativeInt, 'now': getNow, 'onlyInChannel': onlyInChannel, 'op': getOp, 'otherUser': getOtherUser, 'owner': owner, 'plugin': getPlugin, 'positiveInt': getPositiveInt, 'private': private, 'public': public, 'regexpMatcher': getMatcher, 'regexpReplacer': getReplacer, 'seenNick': getSeenNick, 'something': getSomething, 'somethingWithoutSpaces': getSomethingNoSpaces, 'text': getText, 'to': getTo, 'url': getUrl, 'user': getUser, 'validChannel': validChannel, 'voice': getVoice, })
def testCopyable(self): d = ircutils.IrcDict() d['foo'] = 'bar' self.failUnless(d == copy.copy(d)) self.failUnless(d == copy.deepcopy(d))
def testGetSetItem(self): d = ircutils.IrcDict() d['#FOO'] = 12 self.assertEqual(12, d['#foo']) d['#fOOBAR[]'] = 'blah' self.assertEqual('blah', d['#foobar{}'])
def __init__(self, irc): self.__parent = super(Ctcp, self) self.__parent.__init__(irc) self.ignores = ircutils.IrcDict() self.floods = ircutils.FloodQueue(60)