diff --git a/examples/Random.py b/examples/Random.py index 9e669011a..4ed6104db 100644 --- a/examples/Random.py +++ b/examples/Random.py @@ -62,7 +62,7 @@ class Seed(registry.Value): self.setValue(long(s)) except ValueError: raise registry.InvalidRegistryValue, 'Value must be an integer.' - + conf.registerPlugin('Random') conf.registerGlobalValue(conf.supybot.plugins.Random, 'seed', Seed(0, """ Sets the seed of the random number generator. The seen must be a valid diff --git a/others/babelfish.py b/others/babelfish.py index 0e3992d5d..d3651d981 100644 --- a/others/babelfish.py +++ b/others/babelfish.py @@ -8,7 +8,7 @@ Summary: import babelizer - + print ' '.join(babelizer.available_languages) print babelizer.translate( 'How much is that doggie in the window?', @@ -17,7 +17,7 @@ Summary: def babel_callback(phrase): print phrase sys.stdout.flush() - + babelizer.babelize( 'I love a reigning knight.', 'English', 'German', callback = babel_callback ) @@ -108,7 +108,7 @@ def translate(phrase, from_lang, to_lang): to_code = __languages[to_lang.lower()] except KeyError, lang: raise LanguageNotAvailableError(lang) - + params = urllib.urlencode( { 'BabelFishFrontPage' : 'yes', 'doit' : 'done', 'tt' : 'urltext', @@ -163,7 +163,7 @@ if __name__ == '__main__': print x sys.stdout.flush(); - + babelize("I won't take that sort of treatment from you, or from your doggie!", 'english', 'french', callback = printer) diff --git a/others/convertcore.py b/others/convertcore.py index c05a7e73d..1627f0f45 100755 --- a/others/convertcore.py +++ b/others/convertcore.py @@ -1,13 +1,13 @@ #!/usr/bin/env python #**************************************************************************** -# This file has been modified from its original version. It has been -# formatted to fit your irc bot. +# This file has been modified from its original version. It has been +# formatted to fit your irc bot. # # The original version is a nifty PyQt application written by Douglas Bell, # available at http://www.bellz.org/convertall/. # -# Below is the original copyright. Doug Bell rocks. +# Below is the original copyright. Doug Bell rocks. # The hijacker is Keith Jones, and he has no bomb in his shoe. # #**************************************************************************** @@ -46,8 +46,8 @@ import StringIO # followed by either equations or equivalency lists for the definition. # For equations, two are given, separated by a ';'. Both are functions of # "x", the first going from the unit to the equivalent unit and the second -# one in reverse. Any valid Python expression returning a float (including -# the functions in the math module) should work. The equivalency list is a +# one in reverse. Any valid Python expression returning a float (including +# the functions in the math module) should work. The equivalency list is a # python list of tuples giving points for linear interpolation. # # All units must reduce to primitive units, which are indicated by an '!' @@ -1042,7 +1042,7 @@ class UnitData(dict): typeUnits[unit.typeName].append(unit.name) self.sortedKeys = self.keys() self.sortedKeys.sort() - + if len(self.sortedKeys) < len(units): raise UnitDataError, 'Duplicate unit names found' @@ -1137,7 +1137,7 @@ class Unit: ############################################################################ # Wrapper functionality # -############################################################################ +############################################################################ # Parse the data file, and set everything up for conversion @@ -1154,7 +1154,7 @@ toUnit = UnitGroup(data, option) def convert(num, unit1, unit2): """ Convert from one unit to another - num is the factor for the first unit. Raises UnitDataError for + num is the factor for the first unit. Raises UnitDataError for various errors. """ fromUnit.update(unit1) @@ -1162,17 +1162,17 @@ def convert(num, unit1, unit2): fromUnit.reduceGroup() toUnit.reduceGroup() - + # Match up unit categories if not fromUnit.categoryMatch(toUnit): raise UnitDataError('unit categories did not match') - + return fromUnit.convert(num, toUnit) - + def units(type): - """ Return comma separated string list of units of given type, or + """ Return comma separated string list of units of given type, or a list of types if the argument is not valid. """ if type in types: diff --git a/others/dictclient.py b/others/dictclient.py index 30575ca58..6302125de 100644 --- a/others/dictclient.py +++ b/others/dictclient.py @@ -105,7 +105,7 @@ class Connection: capstr, msgid = re.search('<(.*)> (<.*>)$', string).groups() self.capabilities = capstr.split('.') self.messageid = msgid - + def getcapabilities(self): """Returns a list of the capabilities advertised by the server.""" return self.capabilities @@ -120,7 +120,7 @@ class Connection: network traffic!""" if hasattr(self, 'dbdescs'): return self.dbdescs - + self.sendcommand("SHOW DB") self.dbdescs = self.get100dict() return self.dbdescs @@ -176,7 +176,7 @@ class Connection: if database != '*' and database != '!' and \ not database in self.getdbdescs(): raise Exception, "Invalid database '%s' specified" % database - + self.sendcommand("DEFINE " + enquote(database) + " " + enquote(word)) code = self.getresultcode()[0] @@ -243,11 +243,11 @@ class Database: a database name.""" self.conn = dictconn self.name = dbname - + def getname(self): """Returns the short name for this database.""" return self.name - + def getdescription(self): if hasattr(self, 'description'): return self.description @@ -258,7 +258,7 @@ class Database: else: self.description = self.conn.getdbdescs()[self.getname()] return self.description - + def getinfo(self): """Returns a string of info describing this database.""" if hasattr(self, 'info'): diff --git a/others/rssparser.py b/others/rssparser.py index 1ea72ef52..2e492aa54 100644 --- a/others/rssparser.py +++ b/others/rssparser.py @@ -12,7 +12,7 @@ RSS 0.9x/common elements: Additional RSS 1.0/2.0 elements: - dc:rights, dc:language, dc:creator, dc:date, dc:subject, content:encoded, admin:generatorAgent, admin:errorReportsTo, - + Addition Pie/Atom/Echo elements: - subtitle, created, issued, modified, summary, id, content @@ -167,7 +167,7 @@ class FeedParser(sgmllib.SGMLParser): prefix = self.namespacemap.get(prefix, prefix) name = prefix + ':' + suffix return name - + def _getAttribute(self, attrs, name): value = [v for k, v in attrs if self._mapToStandardPrefix(k) == name] if value: @@ -175,7 +175,7 @@ class FeedParser(sgmllib.SGMLParser): else: value = None return value - + def start_channel(self, attrs): self.push('channel', 0) self.inchannel = 1 @@ -183,16 +183,16 @@ class FeedParser(sgmllib.SGMLParser): def end_channel(self): self.pop('channel') self.inchannel = 0 - + def start_image(self, attrs): self.inimage = 1 - + def end_image(self): self.inimage = 0 - + def start_textinput(self, attrs): self.intextinput = 1 - + def end_textinput(self): self.intextinput = 0 @@ -300,7 +300,7 @@ class FeedParser(sgmllib.SGMLParser): def end_entry(self): self.pop('item') self.initem = 0 - + def start_subtitle(self, attrs): self.push('subtitle', 1) @@ -312,7 +312,7 @@ class FeedParser(sgmllib.SGMLParser): def end_summary(self): self.pop('summary') - + def start_modified(self, attrs): self.push('modified', 1) @@ -376,7 +376,7 @@ class FeedParser(sgmllib.SGMLParser): end_div = end_content end_xhtml_body = end_content end_xhtml_div = end_content - + def unknown_starttag(self, tag, attrs): if self.incontent and self.contentmode == 'xml': self.handle_data("<%s%s>" % (tag, "".join([' %s="%s"' % t for t in attrs]))) @@ -504,7 +504,7 @@ class FeedURLHandler(urllib2.HTTPRedirectHandler, urllib2.HTTPDefaultErrorHandle http_error_300 = http_error_302 http_error_307 = http_error_302 - + def open_resource(source, etag=None, modified=None, agent=None, referrer=None): """ URI, filename, or string --> stream @@ -538,7 +538,7 @@ def open_resource(source, etag=None, modified=None, agent=None, referrer=None): if not agent: agent = USER_AGENT - + # try to open with urllib2 (to use optional headers) request = urllib2.Request(source) if etag: @@ -556,7 +556,7 @@ def open_resource(source, etag=None, modified=None, agent=None, referrer=None): except: # source is not a valid URL, but it might be a valid filename pass - + # try to open with native open function (if source is a filename) try: return open(source) @@ -568,7 +568,7 @@ def open_resource(source, etag=None, modified=None, agent=None, referrer=None): def get_etag(resource): """ - Get the ETag associated with a response returned from a call to + Get the ETag associated with a response returned from a call to open_resource(). If the resource was not returned from an HTTP server or the server did diff --git a/others/urllib2.py b/others/urllib2.py index 914df8b91..8cfb01492 100644 --- a/others/urllib2.py +++ b/others/urllib2.py @@ -705,7 +705,7 @@ class AbstractDigestAuthHandler: # prompting for the information. Crap. This isn't great # but it's better than the current 'repeat until recursion # depth exceeded' approach - raise HTTPError(req.get_full_url(), 401, "digest auth failed", + raise HTTPError(req.get_full_url(), 401, "digest auth failed", headers, None) else: self.retried += 1 @@ -780,7 +780,7 @@ class AbstractDigestAuthHandler: else: # XXX handle auth-int. pass - + # XXX should the partial digests be encoded too? base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \ @@ -822,7 +822,7 @@ class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): def http_error_401(self, req, fp, code, msg, headers): host = urlparse.urlparse(req.get_full_url())[1] - retry = self.http_error_auth_reqed('www-authenticate', + retry = self.http_error_auth_reqed('www-authenticate', host, req, headers) self.reset_retry_count() return retry @@ -834,7 +834,7 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): def http_error_407(self, req, fp, code, msg, headers): host = req.get_host() - retry = self.http_error_auth_reqed('proxy-authenticate', + retry = self.http_error_auth_reqed('proxy-authenticate', host, req, headers) self.reset_retry_count() return retry diff --git a/plugins/Alias.py b/plugins/Alias.py index bc6c4befd..fef7d7494 100644 --- a/plugins/Alias.py +++ b/plugins/Alias.py @@ -186,7 +186,7 @@ class Alias(callbacks.Privmsg): del self.aliases[alias] del self.__class__.__call__ callbacks.Privmsg.__call__(self, irc, msg) - + def lock(self, irc, msg, args): """ diff --git a/plugins/Amazon.py b/plugins/Amazon.py index 9fcce4a08..2da3666d7 100644 --- a/plugins/Amazon.py +++ b/plugins/Amazon.py @@ -70,7 +70,7 @@ class LicenseKey(registry.String): registry.String.set(self, s) if self.value: amazon.setLicense(self.value) - + conf.registerPlugin('Amazon') conf.registerChannelValue(conf.supybot.plugins.Amazon, 'bold', registry.Boolean(True, """Determines whether the results are bolded.""")) diff --git a/plugins/Anonymous.py b/plugins/Anonymous.py index 92c303b57..315963554 100644 --- a/plugins/Anonymous.py +++ b/plugins/Anonymous.py @@ -62,7 +62,7 @@ conf.registerChannelValue(conf.supybot.plugins.Anonymous, conf.registerGlobalValue(conf.supybot.plugins.Anonymous, 'requireRegistration', registry.Boolean(True, """Determines whether the bot should require people trying to use this plugin to be registered.""")) - + class Anonymous(callbacks.Privmsg): private = True @@ -95,7 +95,7 @@ class Anonymous(callbacks.Privmsg): 'disallow the use of this plugin.') return irc.queueMsg(ircmsgs.privmsg(channel, text)) - + Class = Anonymous diff --git a/plugins/Babelfish.py b/plugins/Babelfish.py index 6d535ff59..a31acdf3b 100644 --- a/plugins/Babelfish.py +++ b/plugins/Babelfish.py @@ -58,7 +58,7 @@ class SpaceSeparatedListOfLanguages(registry.SeparatedListOf): def splitter(self, s): return s.split() joiner = ' '.join - + conf.registerPlugin('Babelfish') conf.registerChannelValue(conf.supybot.plugins.Babelfish, 'languages', SpaceSeparatedListOfLanguages(babelfish.available_languages, """Determines @@ -87,7 +87,7 @@ class Babelfish(callbacks.Privmsg): if toLang not in languages: toLang = None return (fromLang, toLang) - + def languages(self, irc, msg, args): """takes no arguments diff --git a/plugins/Bugzilla.py b/plugins/Bugzilla.py index dd61ded3e..75ca605e6 100644 --- a/plugins/Bugzilla.py +++ b/plugins/Bugzilla.py @@ -141,7 +141,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp): def die(self): self.db.close() - + def add(self, irc, msg, args): """ @@ -229,7 +229,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp): """Given a URL and query list for a CSV bug list, it'll return all the bugs in a dict """ - bugs = {} + bugs = {} try: url = '%s/buglist.cgi?%s' % (url, '&'.join(query)) u = webutils.getUrlFd(url) @@ -256,11 +256,11 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp): i += 1 u.close() return bugs - + def search(self, irc, msg, args): """[--keywords=] - - Look for bugs with , also matching + + Look for bugs with , also matching . can be statuses, severities, priorities, or resolutions, seperated by commas""" keywords = None @@ -270,7 +270,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp): keywords = arguments.split(',') (name,searchstr)= privmsgs.getArgs(rest, required=2) if not keywords: - keywords = ['UNCONFIRMED', 'NEW', 'ASSIGNED', 'REOPENED'] + keywords = ['UNCONFIRMED', 'NEW', 'ASSIGNED', 'REOPENED'] query = self.keywords2query(keywords) query.append('short_desc_type=allwordssubstr') query.append('short_desc=%s' % urllib.quote(searchstr)) @@ -292,7 +292,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp): (utils.nItems('bug', len(bugs)), searchstr, ' AND '.join(keywords), utils.commaAndify(map(str, bugids))) irc.reply(s) - + def bug(self, irc, msg, args): """ diff --git a/plugins/ChannelRelay.py b/plugins/ChannelRelay.py index edb607060..191513d40 100644 --- a/plugins/ChannelRelay.py +++ b/plugins/ChannelRelay.py @@ -57,7 +57,7 @@ class ValidChannelOrNothing(conf.ValidChannel): conf.ValidChannel.setValue(self, v) except registry.InvalidRegistryValue: registry.Value.setValue(self, '') - + conf.registerPlugin('ChannelRelay') conf.registerGlobalValue(conf.supybot.plugins.ChannelRelay, 'source', ValidChannelOrNothing('', """Determines the channel that the bot will look @@ -114,7 +114,7 @@ class ChannelRelay(callbacks.Privmsg): s = msg.args[1] s = self.registryValue('prefix') + s irc.queueMsg(ircmsgs.privmsg(target, s)) - + def do376(self, irc, msg): source = self.registryValue('source') target = self.registryValue('target') diff --git a/plugins/ChannelStats.py b/plugins/ChannelStats.py index b1f78d740..a52f999f1 100644 --- a/plugins/ChannelStats.py +++ b/plugins/ChannelStats.py @@ -161,7 +161,7 @@ class UserStat(ChannelStat): class StatsDB(plugins.ChannelUserDB): def __init__(self, *args, **kwargs): plugins.ChannelUserDB.__init__(self, *args, **kwargs) - + def serialize(self, v): return v.values() @@ -189,7 +189,7 @@ class StatsDB(plugins.ChannelUserDB): def getChannelStats(self, channel): return self[channel, 'channelStats'] - + def getUserStats(self, channel, id): return self[channel, id] @@ -222,7 +222,7 @@ class ChannelStats(callbacks.Privmsg): self.lastmsg = msg self.db.addMsg(msg) super(ChannelStats, self).__call__(irc, msg) - + def outFilter(self, irc, msg): if msg.command == 'PRIVMSG': if ircutils.isChannel(msg.args[0]): @@ -344,7 +344,7 @@ class ChannelStats(callbacks.Privmsg): except KeyError: irc.error('I\'ve never been on %s.' % channel) - + Class = ChannelStats # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/plugins/Debian.py b/plugins/Debian.py index 39f346ecb..f09267d60 100644 --- a/plugins/Debian.py +++ b/plugins/Debian.py @@ -245,7 +245,7 @@ class Debian(callbacks.Privmsg, _incomingRe = re.compile(r'', re.I) def incoming(self, irc, msg, args): """[--{regexp,arch}=] - + Checks debian incoming for a matching package name. The arch parameter defaults to i386; --regexp returns only those package names that match a given regexp, and normal matches use standard *nix @@ -322,7 +322,7 @@ class Debian(callbacks.Privmsg, if m: m = m.group(1) if fnmatch.fnmatch(m, glob): - packages.append(m) + packages.append(m) fd.close() if packages: irc.reply(utils.commaAndify(packages)) diff --git a/plugins/Dict.py b/plugins/Dict.py index ed6976998..91afa942e 100644 --- a/plugins/Dict.py +++ b/plugins/Dict.py @@ -135,7 +135,7 @@ class Dict(callbacks.Privmsg): L.append('%s: %s' % (db, s)) utils.sortBy(len, L) if dictionary == '*' and len(dbs) > 1: - s = '%s responded: %s' % (utils.commaAndify(dbs), '; '.join(L)) + s = '%s responded: %s' % (utils.commaAndify(dbs), '; '.join(L)) else: s = '; '.join(L) irc.reply(s) diff --git a/plugins/Dunno.py b/plugins/Dunno.py index 5ac3a7044..a9733ac4e 100644 --- a/plugins/Dunno.py +++ b/plugins/Dunno.py @@ -66,7 +66,7 @@ class Dunno(callbacks.Privmsg): def __init__(self): callbacks.Privmsg.__init__(self) self.makeDb(dbfilename) - + def makeDb(self, filename): """create Dunno database and tables""" if os.path.exists(filename): @@ -81,7 +81,7 @@ class Dunno(callbacks.Privmsg): dunno TEXT )""") self.db.commit() - + def invalidCommand(self, irc, msg, tokens): cursor = self.db.cursor() cursor.execute("""SELECT dunno @@ -220,7 +220,7 @@ class Dunno(callbacks.Privmsg): cursor = self.db.cursor() cursor.execute("""SELECT COUNT(*) FROM dunnos""") irc.reply(cursor.fetchone()[0]) - + Class = Dunno diff --git a/plugins/Enforcer.py b/plugins/Enforcer.py index 579d6a6f6..fef79e35e 100644 --- a/plugins/Enforcer.py +++ b/plugins/Enforcer.py @@ -66,7 +66,7 @@ class ValidNickOrEmptyString(registry.String): raise registry.InvalidRegistryValue, \ 'Value must be a valid nick or the empty string.' self.value = v - + conf.registerPlugin('Enforcer') conf.registerChannelValue(conf.supybot.plugins.Enforcer, 'enforce', registry.Boolean(True, """Determines whether the bot will enforce @@ -112,7 +112,7 @@ class Enforcer(callbacks.Privmsg): def __init__(self): callbacks.Privmsg.__init__(self) self.topics = ircutils.IrcDict() - + def doJoin(self, irc, msg): channel = msg.args[0] c = ircdb.channels.getChannel(channel) @@ -263,7 +263,7 @@ class Enforcer(callbacks.Privmsg): irc.queueMsg(ircmsgs.join(channel)) else: self.log.warning('Not cycling %s: it\'s +i', channel) - + def doPart(self, irc, msg): if msg.prefix != irc.prefix: channel = msg.args[0] diff --git a/plugins/Filter.py b/plugins/Filter.py index 8398dad51..378634e82 100644 --- a/plugins/Filter.py +++ b/plugins/Filter.py @@ -52,7 +52,7 @@ import callbacks class MyFilterProxy(object): def reply(self, s): self.s = s - + class Filter(callbacks.Privmsg): """This plugin offers several commands which transform text in some way. It also provides the capability of using such commands to 'filter' the @@ -86,7 +86,7 @@ class Filter(callbacks.Privmsg): 'supa1337', 'colorstrip', 'aol'] def outfilter(self, irc, msg, args, channel): """[] [] - + Sets the outFilter of this plugin to be . If no command is given, unsets the outFilter. is only necessary if the message isn't sent in the channel itself. @@ -104,7 +104,7 @@ class Filter(callbacks.Privmsg): self.outFilters[channel] = [] irc.replySuccess() outfilter = privmsgs.checkChannelCapability(outfilter, 'op') - + def squish(self, irc, msg, args): """ @@ -217,7 +217,7 @@ class Filter(callbacks.Privmsg): ('eE', '3'), ('t', '+'), ('T', '7'), ('l', '1'), ('D', '|)'), ('B', '|3'), ('I', ']['), ('Vv', '\\/'), ('wW', '\\/\\/'), ('d', 'c|'), ('b', '|>'), - ('c', '<'), ('h', '|n'),] + ('c', '<'), ('h', '|n'),] def supa1337(self, irc, msg, args): """ @@ -380,7 +380,7 @@ class Filter(callbacks.Privmsg): text = text.replace(' their ', ' there ') smiley = random.choice(['<3', ':)', ':-)', ':D', ':-D']) text += smiley*3 - + def jeffk(self, irc, msg, args): """ diff --git a/plugins/Fun.py b/plugins/Fun.py index ab8c3574e..63e2b6bf2 100644 --- a/plugins/Fun.py +++ b/plugins/Fun.py @@ -58,7 +58,7 @@ import callbacks class MyFunProxy(object): def reply(self, msg, s): self.s = s - + class Fun(callbacks.Privmsg): def __init__(self): self.outFilters = ircutils.IrcDict() @@ -86,7 +86,7 @@ class Fun(callbacks.Privmsg): i = int(quad) ret += '%02x' % i irc.reply(ret.upper()) - + def ord(self, irc, msg, args): """ diff --git a/plugins/FunDB.py b/plugins/FunDB.py index 16f985e32..c29bc7b7c 100755 --- a/plugins/FunDB.py +++ b/plugins/FunDB.py @@ -89,7 +89,7 @@ conf.registerPlugin('FunDB') conf.registerChannelValue(conf.supybot.plugins.FunDB, 'showIds', registry.Boolean(True, """Determine whether the bot will show the id of an excuse/insult/praise/lart.""")) - + class FunDB(callbacks.Privmsg, plugins.ChannelDBHandler): """ Contains the 'fun' commands that require a database. Currently includes @@ -322,7 +322,7 @@ class FunDB(callbacks.Privmsg, plugins.ChannelDBHandler): return '%s (#%s)' % (s, id) else: return s - + def insult(self, irc, msg, args): """[] @@ -353,7 +353,7 @@ class FunDB(callbacks.Privmsg, plugins.ChannelDBHandler): def excuse(self, irc, msg, args): """[] [] - Gives you a standard, random BOFH excuse or the excuse with the given + Gives you a standard, random BOFH excuse or the excuse with the given . is only necessary if the message isn't sent in the channel itself. """ diff --git a/plugins/Google.py b/plugins/Google.py index 1d0106f42..1d75b46cd 100644 --- a/plugins/Google.py +++ b/plugins/Google.py @@ -155,7 +155,7 @@ class Language(registry.OnlySomeStrings): else: s = s.lower()[:-2] + s[-2:] return s - + conf.registerPlugin('Google') conf.registerChannelValue(conf.supybot.plugins.Google, 'groupsSnarfer', registry.Boolean(False, """Determines whether the groups snarfer is @@ -222,7 +222,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp): irc.reply(url) else: irc.reply('Google found nothing.') - + def google(self, irc, msg, args): """ [--{language,restrict}=] [--{notsafe,similar}] diff --git a/plugins/Herald.py b/plugins/Herald.py index 6c2e561ca..4f99b25dd 100644 --- a/plugins/Herald.py +++ b/plugins/Herald.py @@ -109,7 +109,7 @@ class Herald(callbacks.Privmsg): throttle = self.registryValue('throttleTime', channel) if now - self.lastHerald.get((channel, id), 0) > throttle: if (channel, id) in self.lastParts: - i = self.registryValue('throttleTimeAfterPart', channel) + i = self.registryValue('throttleTimeAfterPart', channel) if now - self.lastParts[channel, id] < i: return self.lastHerald[channel, id] = now diff --git a/plugins/Infobot.py b/plugins/Infobot.py index c7b901b13..721634605 100755 --- a/plugins/Infobot.py +++ b/plugins/Infobot.py @@ -152,7 +152,7 @@ class InfobotDB(object): def getConfirm(self): return random.choice(self._confirms) + random.choice(self._ends) - + def getChangeCount(self): return self._changes @@ -189,7 +189,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp): msg = self.msg self.replied = True irc.reply(plugins.standardSubstitute(irc, msg, s), prefixName=False) - + def confirm(self, irc=None, msg=None): if self.registryValue('personality'): self.reply(self.db.getConfirm(), irc=irc, msg=msg) @@ -235,7 +235,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp): if s.startswith(contraction): s = replacement + s[len(contraction):] return s - + _forceRe = re.compile(r'^no[,: -]+', re.I) def doPrivmsg(self, irc, msg): maybeAddressed = callbacks.addressed(irc.nick, msg, @@ -345,7 +345,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp): 'to the database since this plugin was loaded.' % (utils.nItems('request', self.db.getChangeCount()), utils.nItems('change', self.db.getResponseCount()))) - + Class = Infobot diff --git a/plugins/LogToIrc.py b/plugins/LogToIrc.py index e015c1042..f33ad95d2 100644 --- a/plugins/LogToIrc.py +++ b/plugins/LogToIrc.py @@ -94,8 +94,8 @@ class IrcHandler(logging.Handler): irc.sendMsg(msg) else: print '*** Not sending to %r' % target - - + + class IrcFormatter(log.Formatter): def formatException(self, (E, e, tb)): L = [utils.exnToString(e), '::'] @@ -225,7 +225,7 @@ class LogToIrc(callbacks.Privmsg): if ircutils.isChannel(target): irc.queueMsg(ircmsgs.join(target)) do377 = do422 = do376 - + Class = LogToIrc diff --git a/plugins/Lookup.py b/plugins/Lookup.py index 0a3eb703e..a0f918d40 100644 --- a/plugins/Lookup.py +++ b/plugins/Lookup.py @@ -88,7 +88,7 @@ def configure(advanced): continue command = something('What would you like the command to be?') conf.registerGlobalValue(lookups,command, registry.String(filename,'')) - + conf.registerPlugin('Lookup') conf.registerGroup(conf.supybot.plugins.Lookup, 'lookups') diff --git a/plugins/Math.py b/plugins/Math.py index 85efb4622..6fd14a148 100644 --- a/plugins/Math.py +++ b/plugins/Math.py @@ -50,7 +50,7 @@ import utils import privmsgs import callbacks -import convertcore +import convertcore class Math(callbacks.Privmsg): @@ -109,7 +109,7 @@ class Math(callbacks.Privmsg): return '-%s' % valStr else: return valStr - + def _convertBaseToBase(self, number, toBase, fromBase): """ Convert a number from any base, 2 through 36, to any other @@ -119,7 +119,7 @@ class Math(callbacks.Privmsg): if toBase == 10: return str(number) return self._convertDecimalToBase(number, toBase) - + _mathEnv = {'__builtins__': types.ModuleType('__builtins__'), 'i': 1j} _mathEnv.update(math.__dict__) _mathEnv.update(cmath.__dict__) @@ -143,7 +143,7 @@ class Math(callbacks.Privmsg): return str(int(x)) else: return str(x) - + def _complexToString(self, x): realS = self._floatToString(x.real) imagS = self._floatToString(x.imag) @@ -249,7 +249,7 @@ class Math(callbacks.Privmsg): except Exception, e: irc.error(utils.exnToString(e)) icalc = privmsgs.checkCapability(icalc, 'trusted') - + _rpnEnv = { 'dup': lambda s: s.extend([s.pop()]*2), 'swap': lambda s: s.extend([s.pop(), s.pop()]) @@ -307,9 +307,9 @@ class Math(callbacks.Privmsg): Converts from to . If number isn't given, it defaults to 1. For unit information, see 'units' command. """ - + # see if the first arg is a number of some sort - if args: + if args: try: num = float(args[0]) args.pop(0) @@ -327,7 +327,7 @@ class Math(callbacks.Privmsg): try: newNum = convertcore.convert(num, unit1, unit2) newNum = self._floatToString(newNum) - + irc.reply('%s' % newNum) except convertcore.UnitDataError, ude: irc.error(str(ude)) @@ -339,13 +339,13 @@ class Math(callbacks.Privmsg): passed as arguments. When called with a type as an argument, returns the units of that type. """ - + if len(args) == 0: type = None else: type = ' '.join(args) irc.reply(convertcore.units(type)) - + Class = Math # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/plugins/MoobotFactoids.py b/plugins/MoobotFactoids.py index 483ea3988..c2a4a7057 100644 --- a/plugins/MoobotFactoids.py +++ b/plugins/MoobotFactoids.py @@ -151,7 +151,7 @@ class MoobotDBHandler(plugins.DBHandler): db.commit() return db - + class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): priority = 98 addressedRegexps = ['changeFactoid', 'augmentFactoid', @@ -197,7 +197,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): """ db = self.dbHandler.getDb() cursor = db.cursor() - cursor.execute("""SELECT fact, key FROM factoids + cursor.execute("""SELECT fact, key FROM factoids ORDER BY random() LIMIT 1""") if cursor.rowcount == 0: irc.error('No factoids in the database.') @@ -269,7 +269,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): if cursor.rowcount != 0: irc.error('Factoid "%s" already exists.' % key) return - # Otherwise, + # Otherwise, cursor.execute("""INSERT INTO factoids VALUES (%s, %s, %s, NULL, NULL, NULL, NULL, NULL, NULL, %s, 0)""", @@ -288,7 +288,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): key, regexp = match.groups() db = self.dbHandler.getDb() cursor = db.cursor() - # Check and make sure it's in the DB + # Check and make sure it's in the DB cursor.execute("""SELECT locked_at, fact FROM factoids WHERE key LIKE %s""", key) if cursor.rowcount == 0: @@ -305,9 +305,9 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): except ValueError, e: irc.error('Invalid regexp: "%s"' % regexp) return - new_fact = r(fact) - cursor.execute("""UPDATE factoids - SET fact = %s, modified_by = %s, + new_fact = r(fact) + cursor.execute("""UPDATE factoids + SET fact = %s, modified_by = %s, modified_at = %s WHERE key = %s""", new_fact, id, int(time.time()), key) db.commit() @@ -324,7 +324,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): key, new_text = match.groups() db = self.dbHandler.getDb() cursor = db.cursor() - # Check and make sure it's in the DB + # Check and make sure it's in the DB cursor.execute("""SELECT locked_at, fact FROM factoids WHERE key LIKE %s""", key) if cursor.rowcount == 0: @@ -360,7 +360,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): key = key.split(' ', 1)[1] # Take out everything to first space db = self.dbHandler.getDb() cursor = db.cursor() - # Check and make sure it's in the DB + # Check and make sure it's in the DB cursor.execute("""SELECT locked_at, fact FROM factoids WHERE key LIKE %s""", key) if cursor.rowcount == 0: @@ -659,7 +659,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): if cursor.rowcount == 0: irc.error('No such factoid: "%s"' % key) return - (_, locked_at) = cursor.fetchone() + (_, locked_at) = cursor.fetchone() if locked_at is not None: irc.error("Factoid is locked, cannot remove.") return @@ -674,7 +674,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): """ db = self.dbHandler.getDb() cursor = db.cursor() - cursor.execute("""SELECT fact, key FROM factoids + cursor.execute("""SELECT fact, key FROM factoids ORDER BY random() LIMIT 1""") if cursor.rowcount == 0: irc.error('No factoids in the database.') diff --git a/plugins/Movies.py b/plugins/Movies.py index 58b66d293..28b7717ca 100644 --- a/plugins/Movies.py +++ b/plugins/Movies.py @@ -61,7 +61,7 @@ class Movies(callbacks.Privmsg): utils.pluralize('genre', len(movie.genres())), movie.rating(), movie.url) return s - + def imdb(self, irc, msg, args): """ diff --git a/plugins/Network.py b/plugins/Network.py index 5bfd75e5f..636d276d6 100644 --- a/plugins/Network.py +++ b/plugins/Network.py @@ -148,7 +148,7 @@ class Network(callbacks.Privmsg): irc.reply(s) except NameError, e: irc.error('I couldn\'t find such a domain.') - + Class = Network diff --git a/plugins/News.py b/plugins/News.py index 7071cf45f..3700ce652 100644 --- a/plugins/News.py +++ b/plugins/News.py @@ -184,7 +184,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg): db.commit() irc.replySuccess() remove = privmsgs.checkChannelCapability(remove, 'news') - + def change(self, irc, msg, args, channel): """[] @@ -246,10 +246,10 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg): return subjects = ['#%s: %s' % (id, s) for (id, s) in cursor.fetchall()] irc.reply(utils.commaAndify(subjects)) - - + + Class = News # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/plugins/Nickometer.py b/plugins/Nickometer.py index 1ab3d59c9..e2712d8a7 100644 --- a/plugins/Nickometer.py +++ b/plugins/Nickometer.py @@ -1,6 +1,6 @@ #!/usr/bin/python ### -# Copyright (c) 2004, William Robinson. +# Copyright (c) 2004, William Robinson. # Derived from work (c) 1998, Adam Spiers # All rights reserved. # @@ -30,8 +30,8 @@ ### ### -# This algorithm is almost a direct from a the perl nickometer from -# blootbot. Hardly any of the original code has been used, though most of +# This algorithm is almost a direct from a the perl nickometer from +# blootbot. Hardly any of the original code has been used, though most of # the comments, I copy-pasted. As a matter of courtesy, the original copyright # message follows: # @@ -108,13 +108,13 @@ class Nickometer(callbacks.Privmsg): Tells you how lame said nick is. """ score = 0L - + nick = privmsgs.getArgs(args) originalNick = nick if not nick: irc.error('Give me a nick to judge as the argument, please.') return - + specialCost = [('69', 500), ('dea?th', 500), ('dark', 400), @@ -142,9 +142,9 @@ class Nickometer(callbacks.Privmsg): tempNick = nick if special[0][0] != '\\': tempNick = tempNick.translate(letterNumberTranslator) - + if tempNick and re.search(special[0], tempNick, re.IGNORECASE): - score += self.punish(special[1], 'matched special case /%s/' % + score += self.punish(special[1], 'matched special case /%s/' % special[0]) # I don't really know about either of these next two statements, @@ -158,7 +158,7 @@ class Nickometer(callbacks.Privmsg): # Punish consecutive non-alphas matches=re.findall('[^\w\d]{2,}',nick) for match in matches: - score += self.punish(slowPow(10, len(match)), + score += self.punish(slowPow(10, len(match)), '%s consecutive non-alphas ' % len(match)) # Remove balanced brackets ... @@ -174,7 +174,7 @@ class Nickometer(callbacks.Privmsg): # ... and punish for unmatched brackets unmatched = re.findall('[][(){}]', nick) if len(unmatched) > 0: - score += self.punish(slowPow(10, len(unmatched)), + score += self.punish(slowPow(10, len(unmatched)), '%s unmatched parentheses' % len(unmatched)) # Punish k3wlt0k @@ -202,7 +202,7 @@ class Nickometer(callbacks.Privmsg): # Punish uppercase to lowercase shifts and vice-versa, modulo # exceptions above - + # the commented line is the equivalent of the original, but i think # they intended my version, otherwise, the first caps alpha will # still be punished @@ -211,7 +211,7 @@ class Nickometer(callbacks.Privmsg): if cshifts > 1 and re.match('.*[A-Z].*', nick): score += self.punish(slowPow(9, cshifts), '%s case shifts' % cshifts) - + # Punish lame endings if re.match('.*[XZ][^a-zA-Z]*$', nickOriginalCase): score += self.punish(50, 'the last alphanumeric character was lame') @@ -226,7 +226,7 @@ class Nickometer(callbacks.Privmsg): caps = re.findall('[A-Z]', nick) if caps and len(caps) > 0: score += self.punish(slowPow(7, len(caps)), - '%s extraneous caps' % len(caps)) + '%s extraneous caps' % len(caps)) # one trailing underscore is ok. i also added a - for parasite- nick = re.sub('[-_]$','',nick) @@ -235,7 +235,7 @@ class Nickometer(callbacks.Privmsg): remains = re.findall('[^a-zA-Z0-9]', nick) if remains and len(remains) > 0: score += self.punish(50*len(remains) + slowPow(9, len(remains)), - '%s extraneous symbols' % len(remains)) + '%s extraneous symbols' % len(remains)) # Use an appropriate function to map [0, +inf) to [0, 100) percentage = 100 * (1 + math.tanh((score - 400.0) / 400.0)) * \ @@ -243,8 +243,8 @@ class Nickometer(callbacks.Privmsg): # if it's above 99.9%, show as many digits as is insteresting score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',`percentage`) - - irc.reply('The "lame nick-o-meter" reading for "%s" is %s%%.' % + + irc.reply('The "lame nick-o-meter" reading for "%s" is %s%%.' % (originalNick, score_string)) self.log.debug('Calculated lameness score for %s as %s ' diff --git a/plugins/Poll.py b/plugins/Poll.py index 78fbbcba6..2f6e5b33c 100644 --- a/plugins/Poll.py +++ b/plugins/Poll.py @@ -121,7 +121,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler): def open(self, irc, msg, args): """[] - + Creates a new poll with the given question. """ channel = privmsgs.getChannel(msg, args) @@ -144,7 +144,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler): def close(self, irc, msg, args): """[] - + Closes the poll with the given ; further votes will not be allowed. """ channel = privmsgs.getChannel(msg, args) @@ -166,7 +166,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler): def add(self, irc, msg, args): """[] Valid CSS!