mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-29 21:54:22 +01:00
yay! no more stray whitespace
This commit is contained in:
parent
27e3b07119
commit
315810d08e
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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'):
|
||||
|
@ -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
|
||||
|
@ -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 <wink>
|
||||
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
|
||||
|
@ -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):
|
||||
"""<alias>
|
||||
|
||||
|
@ -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."""))
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -141,7 +141,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
|
||||
|
||||
def die(self):
|
||||
self.db.close()
|
||||
|
||||
|
||||
def add(self, irc, msg, args):
|
||||
"""<name> <url> <description>
|
||||
|
||||
@ -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=<keyword>] <bugzilla name> <search string in desc>
|
||||
|
||||
Look for bugs with <search string in the desc>, also matching
|
||||
|
||||
Look for bugs with <search string in the desc>, also matching
|
||||
<keywords>. <keywords> 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):
|
||||
"""<abbreviation> <number>
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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:
|
||||
|
@ -245,7 +245,7 @@ class Debian(callbacks.Privmsg,
|
||||
_incomingRe = re.compile(r'<a href="(.*?\.deb)">', re.I)
|
||||
def incoming(self, irc, msg, args):
|
||||
"""[--{regexp,arch}=<value>] <glob>
|
||||
|
||||
|
||||
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))
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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):
|
||||
"""[<channel>] [<command>]
|
||||
|
||||
|
||||
Sets the outFilter of this plugin to be <command>. If no command is
|
||||
given, unsets the outFilter. <channel> 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):
|
||||
"""<text>
|
||||
|
||||
@ -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):
|
||||
"""<text>
|
||||
|
||||
@ -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):
|
||||
"""<text>
|
||||
|
||||
|
@ -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):
|
||||
"""<letter>
|
||||
|
||||
|
@ -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):
|
||||
"""[<channel>] <nick>
|
||||
|
||||
@ -353,7 +353,7 @@ class FunDB(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||
def excuse(self, irc, msg, args):
|
||||
"""[<channel>] [<id>]
|
||||
|
||||
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
|
||||
<id>. <channel> is only necessary if the message isn't sent in the
|
||||
channel itself.
|
||||
"""
|
||||
|
@ -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):
|
||||
"""<search> [--{language,restrict}=<value>] [--{notsafe,similar}]
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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 <unit> to <other unit>. 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:
|
||||
|
@ -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.')
|
||||
|
@ -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):
|
||||
"""<movie title>
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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):
|
||||
"""[<channel>] <number> <regexp>
|
||||
|
||||
@ -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:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
###
|
||||
# Copyright (c) 2004, William Robinson.
|
||||
# Copyright (c) 2004, William Robinson.
|
||||
# Derived from work (c) 1998, Adam Spiers <adam.spiers@new.ox.ac.uk>
|
||||
# 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 '
|
||||
|
@ -121,7 +121,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||
|
||||
def open(self, irc, msg, args):
|
||||
"""[<channel>] <question>
|
||||
|
||||
|
||||
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):
|
||||
"""[<channel>] <id>
|
||||
|
||||
|
||||
Closes the poll with the given <id>; 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):
|
||||
"""[<channel>] <id> <option text>
|
||||
|
||||
|
||||
Add an option with the given text to the poll with the given id.
|
||||
"""
|
||||
channel = privmsgs.getChannel(msg, args)
|
||||
@ -213,7 +213,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||
|
||||
def vote(self, irc, msg, args):
|
||||
"""[<channel>] <poll id> <option id>
|
||||
|
||||
|
||||
Vote for the option with the given id on the poll with the given poll
|
||||
id. This command can also be used to override any previous vote.
|
||||
"""
|
||||
@ -263,7 +263,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||
|
||||
def results(self, irc, msg, args):
|
||||
"""[<channel>] <id>
|
||||
|
||||
|
||||
Shows the results for the poll with the given id.
|
||||
"""
|
||||
channel = privmsgs.getChannel(msg, args)
|
||||
@ -291,7 +291,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||
(id, question, startedBy)
|
||||
cursor.execute("""SELECT count(user_id), option_id
|
||||
FROM votes
|
||||
WHERE poll_id=%s
|
||||
WHERE poll_id=%s
|
||||
GROUP BY option_id
|
||||
UNION
|
||||
SELECT 0, id AS option_id
|
||||
@ -316,7 +316,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||
s = utils.commaAndify(results)
|
||||
reply += ' - %s' % s
|
||||
irc.reply(reply)
|
||||
|
||||
|
||||
def list(self, irc, msg, args):
|
||||
"""takes no arguments.
|
||||
|
||||
|
@ -130,7 +130,7 @@ class Python(callbacks.PrivmsgCommandAndRegexp):
|
||||
newmodule = getModule(moduleName)
|
||||
if newmodule is None:
|
||||
irc.error('No module %s exists.' % moduleName)
|
||||
else:
|
||||
else:
|
||||
if hasattr(newmodule, funcName):
|
||||
f = getattr(newmodule, funcName)
|
||||
if hasattr(f, '__doc__') and f.__doc__:
|
||||
@ -190,7 +190,7 @@ class Python(callbacks.PrivmsgCommandAndRegexp):
|
||||
if resp:
|
||||
irc.reply('; '.join(resp), prefixName = False)
|
||||
aspnRecipes = privmsgs.urlSnarfer(aspnRecipes)
|
||||
|
||||
|
||||
|
||||
Class = Python
|
||||
|
||||
|
@ -107,7 +107,7 @@ class QuoteGrabs(plugins.ChannelDBHandler, callbacks.Privmsg):
|
||||
db.create_function('nickeq', 2, p)
|
||||
db.commit()
|
||||
return db
|
||||
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
if ircutils.isChannel(msg.args[0]):
|
||||
(channel, payload) = msg.args
|
||||
@ -150,7 +150,7 @@ class QuoteGrabs(plugins.ChannelDBHandler, callbacks.Privmsg):
|
||||
db.commit()
|
||||
|
||||
def _sendGrabMsg(self, irc, msg):
|
||||
s = 'jots down a new quote for %s' % msg.nick
|
||||
s = 'jots down a new quote for %s' % msg.nick
|
||||
irc.queueMsg(ircmsgs.action(msg.args[0], s))
|
||||
|
||||
def grab(self, irc, msg, args):
|
||||
@ -268,7 +268,7 @@ class QuoteGrabs(plugins.ChannelDBHandler, callbacks.Privmsg):
|
||||
try:
|
||||
grabber = ircdb.users.getUser(grabber_mask).name
|
||||
except:
|
||||
grabber = grabber_mask
|
||||
grabber = grabber_mask
|
||||
irc.reply('%s (Said by: %s; grabbed by %s at %s)' % \
|
||||
(quote, hostmask, grabber, time_str))
|
||||
|
||||
|
@ -276,7 +276,7 @@ class Relay(callbacks.Privmsg):
|
||||
Owner.disambiguate(irc, args)
|
||||
self.Proxy(otherIrc, msg, args)
|
||||
command = privmsgs.checkCapability(command, 'admin')
|
||||
|
||||
|
||||
def say(self, irc, msg, args):
|
||||
"""<network> [<channel>] <text>
|
||||
|
||||
@ -348,7 +348,7 @@ class Relay(callbacks.Privmsg):
|
||||
utils.sortBy(ircutils.toLower, usersS)
|
||||
usersS = ', '.join(ifilter(None, imap(', '.join,
|
||||
(ops,halfops,voices,usersS))))
|
||||
users.append('%s (%s): %s' %
|
||||
users.append('%s (%s): %s' %
|
||||
(ircutils.bold(abbreviation), numUsers, usersS))
|
||||
users.sort()
|
||||
irc.reply('; '.join(users))
|
||||
@ -506,7 +506,7 @@ class Relay(callbacks.Privmsg):
|
||||
self.relayedMsgs[msg] += 1
|
||||
except KeyError:
|
||||
self.relayedMsgs[msg] = 1
|
||||
|
||||
|
||||
def _sendToOthers(self, irc, msg):
|
||||
assert msg.command == 'PRIVMSG' or msg.command == 'TOPIC'
|
||||
for otherIrc in self.ircs.itervalues():
|
||||
@ -641,7 +641,7 @@ class Relay(callbacks.Privmsg):
|
||||
## text.startswith('mode change') or \
|
||||
## text.startswith('nick change') or \
|
||||
## text.startswith('topic change'))
|
||||
|
||||
|
||||
def outFilter(self, irc, msg):
|
||||
if not self.started:
|
||||
return msg
|
||||
|
@ -130,7 +130,7 @@ class Scheduler(callbacks.Privmsg):
|
||||
return
|
||||
except ValueError:
|
||||
pass
|
||||
self.events[name] = command
|
||||
self.events[name] = command
|
||||
f = self._makeCommandFunction(irc, msg, command, remove=False)
|
||||
id = schedule.addPeriodicEvent(f, seconds, name)
|
||||
assert id == name
|
||||
|
@ -62,10 +62,10 @@ def ircToLowerOrInt(x):
|
||||
return x
|
||||
else:
|
||||
return ircutils.toLower(x)
|
||||
|
||||
|
||||
class IrcStringAndIntDict(utils.InsensitivePreservingDict):
|
||||
key = staticmethod(ircToLowerOrInt)
|
||||
|
||||
|
||||
class SeenDB(plugins.ChannelUserDB):
|
||||
IdDict = IrcStringAndIntDict
|
||||
def serialize(self, v):
|
||||
@ -74,7 +74,7 @@ class SeenDB(plugins.ChannelUserDB):
|
||||
def deserialize(self, channel, id, L):
|
||||
(seen, saying) = L
|
||||
return (float(seen), saying)
|
||||
|
||||
|
||||
def update(self, channel, nickOrId, saying):
|
||||
seen = time.time()
|
||||
self[channel, nickOrId] = (seen, saying)
|
||||
@ -84,7 +84,7 @@ class SeenDB(plugins.ChannelUserDB):
|
||||
return self[channel, nickOrId]
|
||||
|
||||
filename = os.path.join(conf.supybot.directories.data(), 'Seen.db')
|
||||
|
||||
|
||||
class Seen(callbacks.Privmsg):
|
||||
noIgnore = True
|
||||
def __init__(self):
|
||||
@ -99,7 +99,7 @@ class Seen(callbacks.Privmsg):
|
||||
self.log.debug('Odd, no flush in flushers: %r', world.flushers)
|
||||
self.db.close()
|
||||
callbacks.Privmsg.die(self)
|
||||
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
if ircutils.isChannel(msg.args[0]):
|
||||
said = ircmsgs.prettyPrint(msg)
|
||||
@ -110,7 +110,7 @@ class Seen(callbacks.Privmsg):
|
||||
self.db.update(channel, id, said)
|
||||
except KeyError:
|
||||
pass # Not in the database.
|
||||
|
||||
|
||||
def seen(self, irc, msg, args):
|
||||
"""[<channel>] [--user] [<name>]
|
||||
|
||||
@ -138,7 +138,7 @@ class Seen(callbacks.Privmsg):
|
||||
return
|
||||
try:
|
||||
(when, said) = self.db.seen(channel, nickOrId)
|
||||
irc.reply('%s was last seen here %s ago saying: %s' %
|
||||
irc.reply('%s was last seen here %s ago saying: %s' %
|
||||
(name, utils.timeElapsed(time.time()-when), said))
|
||||
except KeyError:
|
||||
irc.reply('I have not seen %s.' % name)
|
||||
|
@ -95,7 +95,7 @@ conf.registerChannelValue(conf.supybot.plugins.Services.ChanServ, 'voice',
|
||||
registry.Boolean(False, """Determines whether the bot will request to get
|
||||
voiced by the ChanServ when it joins the channel."""))
|
||||
|
||||
|
||||
|
||||
class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||
capability = 'admin'
|
||||
def __init__(self):
|
||||
@ -144,7 +144,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||
if nick and irc.nick != nick:
|
||||
if irc.afterConnect and not self.sentGhost:
|
||||
irc.sendMsg(ircmsgs.nick(nick)) # The 433 is handled elsewhere.
|
||||
|
||||
|
||||
def do001(self, irc, msg):
|
||||
# New connection, make sure sentGhost is False.
|
||||
self.sentGhost = False
|
||||
@ -199,7 +199,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||
nick = self.registryValue('nick')
|
||||
lowered = s.lower()
|
||||
return bool('killed' in lowered and (nick in s or 'ghost' in lowered))
|
||||
|
||||
|
||||
def doNotice(self, irc, msg):
|
||||
if irc.afterConnect:
|
||||
nickserv = self.registryValue('NickServ')
|
||||
@ -251,7 +251,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||
self.log.info('Requesting voice from %s in %s',
|
||||
chanserv, channel)
|
||||
irc.sendMsg(ircmsgs.privmsg(chanserv, 'voice %s' % channel))
|
||||
|
||||
|
||||
def do366(self, irc, msg): # End of /NAMES list; finished joining a channel
|
||||
if self.identified:
|
||||
channel = msg.args[1] # nick is msg.args[0].
|
||||
|
@ -122,7 +122,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
||||
def __init__(self):
|
||||
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||
self.__class__.sf = self.__class__.sourceforge
|
||||
|
||||
|
||||
def _formatResp(self, text, num=''):
|
||||
"""
|
||||
Parses the Sourceforge query to return a list of tuples that
|
||||
@ -164,7 +164,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
||||
conf.supybot.replies.possibleBug()
|
||||
except webutils.WebError, e:
|
||||
raise callbacks.Error, str(e)
|
||||
|
||||
|
||||
_bold = lambda self, m: (ircutils.bold(m[0]),) + m[1:]
|
||||
_sfTitle = re.compile(r'Detail:(\d+) - ([^<]+)</title>', re.I)
|
||||
_linkType = re.compile(r'(\w+ \w+|\w+): Tracker Detailed View', re.I)
|
||||
|
@ -72,7 +72,7 @@ class Status(callbacks.Privmsg):
|
||||
|
||||
def do001(self, irc, msg):
|
||||
self.connected[irc] = time.time()
|
||||
|
||||
|
||||
def net(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
@ -108,7 +108,7 @@ class Status(callbacks.Privmsg):
|
||||
response = ('I have taken %.2f seconds of user time and %.2f seconds '
|
||||
'of system time, for a total of %.2f seconds of CPU '
|
||||
'time. %s'
|
||||
'I have spawned %s; I currently have %s still running.' %
|
||||
'I have spawned %s; I currently have %s still running.' %
|
||||
(user, system, user + system, children,
|
||||
utils.nItems('thread', world.threadsSpawned),
|
||||
activeThreads))
|
||||
|
@ -75,7 +75,7 @@ class TodoDB(plugins.DBHandler):
|
||||
db.commit()
|
||||
return db
|
||||
|
||||
|
||||
|
||||
class Todo(callbacks.Privmsg):
|
||||
def __init__(self):
|
||||
callbacks.Privmsg.__init__(self)
|
||||
@ -138,7 +138,7 @@ class Todo(callbacks.Privmsg):
|
||||
irc.reply('That user has no todos.')
|
||||
return
|
||||
L = ['#%s: %s' % (item[0], self._shrink(item[1]))
|
||||
for item in cursor.fetchall()]
|
||||
for item in cursor.fetchall()]
|
||||
if len(L) == 1:
|
||||
s = 'Todo for %s: %s' % (arg, L[0])
|
||||
else:
|
||||
@ -181,8 +181,8 @@ class Todo(callbacks.Privmsg):
|
||||
except KeyError:
|
||||
irc.errorNotRegistered()
|
||||
return
|
||||
(optlist, rest) = getopt.getopt(args, '', ['priority='])
|
||||
priority = 0
|
||||
(optlist, rest) = getopt.getopt(args, '', ['priority='])
|
||||
priority = 0
|
||||
for (option, arg) in optlist:
|
||||
if option == '--priority':
|
||||
try:
|
||||
@ -198,7 +198,7 @@ class Todo(callbacks.Privmsg):
|
||||
VALUES (NULL, %s, %s, %s, %s, 1)""",
|
||||
priority, now, id, text)
|
||||
db.commit()
|
||||
cursor.execute("""SELECT id FROM todo
|
||||
cursor.execute("""SELECT id FROM todo
|
||||
WHERE added_at=%s AND userid=%s""", now, id)
|
||||
todoId = cursor.fetchone()[0]
|
||||
irc.replySuccess('(Todo #%s added)' % (todoId))
|
||||
|
@ -62,7 +62,7 @@ class Topic(callbacks.Privmsg):
|
||||
def __init__(self):
|
||||
callbacks.Privmsg.__init__(self)
|
||||
self.lastTopics = ircutils.IrcDict()
|
||||
|
||||
|
||||
def _splitTopic(self, topic, channel):
|
||||
separator = self.registryValue('separator', channel)
|
||||
return filter(None, topic.split(separator))
|
||||
@ -84,7 +84,7 @@ class Topic(callbacks.Privmsg):
|
||||
except KeyError:
|
||||
name = msg.nick
|
||||
return self.topicFormatter % (topic, name)
|
||||
|
||||
|
||||
def _sendTopic(self, irc, channel, topics):
|
||||
topics = [s for s in topics if s and not s.isspace()]
|
||||
self.lastTopics[channel] = topics
|
||||
|
@ -224,7 +224,7 @@ class URL(callbacks.PrivmsgCommandAndRegexp,
|
||||
s = 'Title: %s (at %s)' % (title, domain)
|
||||
irc.reply(s, prefixName=False)
|
||||
titleSnarfer = privmsgs.urlSnarfer(titleSnarfer)
|
||||
|
||||
|
||||
def _updateTinyDb(self, url, tinyurl, channel):
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
|
@ -108,7 +108,7 @@ def pipeReadline(fd, timeout=2):
|
||||
return r[0].readline()
|
||||
else:
|
||||
raise TimeoutError
|
||||
|
||||
|
||||
|
||||
|
||||
class Unix(callbacks.Privmsg):
|
||||
|
@ -62,7 +62,7 @@ class Utilities(callbacks.Privmsg):
|
||||
"""
|
||||
text = privmsgs.getArgs(args)
|
||||
irc.reply(text)
|
||||
|
||||
|
||||
def success(self, irc, msg, args):
|
||||
"""[<text>]
|
||||
|
||||
@ -86,7 +86,7 @@ class Utilities(callbacks.Privmsg):
|
||||
irc.reply(args[-1])
|
||||
else:
|
||||
raise callbacks.Error
|
||||
|
||||
|
||||
def strjoin(self, irc, msg, args):
|
||||
"""<separator> <string 1> [<string> ...]
|
||||
|
||||
@ -213,7 +213,7 @@ class Utilities(callbacks.Privmsg):
|
||||
print '***', allTokens
|
||||
Owner = irc.getCallback('Owner')
|
||||
Owner.processTokens(irc, msg, allTokens)
|
||||
|
||||
|
||||
|
||||
|
||||
Class = Utilities
|
||||
|
@ -85,7 +85,7 @@ class WordStatsDB(plugins.ChannelUserDB):
|
||||
self.channelWords[channel].setdefault(word, 0)
|
||||
self.channelWords[channel][word] += count
|
||||
return d
|
||||
|
||||
|
||||
def getWordCount(self, channel, id, word):
|
||||
return self[channel, id][word]
|
||||
|
||||
@ -98,7 +98,7 @@ class WordStatsDB(plugins.ChannelUserDB):
|
||||
L = self.channelWords[channel].keys()
|
||||
L.sort()
|
||||
return L
|
||||
|
||||
|
||||
def getTotalWordCount(self, channel, word):
|
||||
return self.channelWords[channel][word]
|
||||
|
||||
@ -142,7 +142,7 @@ class WordStatsDB(plugins.ChannelUserDB):
|
||||
if ircutils.nickEqual(chan, channel):
|
||||
if word in d:
|
||||
del d[word]
|
||||
|
||||
|
||||
def addMsg(self, msg):
|
||||
assert msg.command == 'PRIVMSG'
|
||||
(channel, text) = msg.args
|
||||
@ -168,7 +168,7 @@ class WordStatsDB(plugins.ChannelUserDB):
|
||||
if word not in self[channel, id]:
|
||||
self[channel, id][word] = 0
|
||||
self[channel, id][word] += 1
|
||||
|
||||
|
||||
|
||||
filename=os.path.join(conf.supybot.directories.data(), 'WordStats.db')
|
||||
class WordStats(callbacks.Privmsg):
|
||||
@ -201,7 +201,7 @@ class WordStats(callbacks.Privmsg):
|
||||
self.log.debug('Queried and ignoring.')
|
||||
finally:
|
||||
self.queried = False
|
||||
|
||||
|
||||
def add(self, irc, msg, args):
|
||||
"""[<channel>] <word>
|
||||
|
||||
|
@ -101,7 +101,7 @@ class HangmanGame:
|
||||
self.unused = ''
|
||||
self.hidden = ''
|
||||
self.guess = ''
|
||||
|
||||
|
||||
def getWord(self, dbHandler):
|
||||
db = dbHandler.getDb()
|
||||
cursor = db.cursor()
|
||||
@ -229,7 +229,7 @@ class Words(callbacks.Privmsg):
|
||||
irc.reply(utils.commaAndify(words))
|
||||
else:
|
||||
irc.reply('That word has no anagrams I could find.')
|
||||
|
||||
|
||||
###
|
||||
# HANGMAN
|
||||
###
|
||||
@ -360,11 +360,11 @@ class Words(callbacks.Privmsg):
|
||||
###
|
||||
# END HANGMAN
|
||||
###
|
||||
|
||||
|
||||
|
||||
Class = Words
|
||||
|
||||
### TODO: Write a script to make the database.
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -82,7 +82,7 @@ class XMLLogger(callbacks.Privmsg):
|
||||
self.log.warning('My flusher wasn\'t in world.flushers: %r',
|
||||
world.flushers)
|
||||
self.fd.close()
|
||||
|
||||
|
||||
def writeMsg(self, msg):
|
||||
pretty = self.registryValue('prettyPrint')
|
||||
includeTime = self.registryValue('includeTime')
|
||||
|
@ -123,25 +123,25 @@ repliesStatement = [
|
||||
canonicalizeRe = [(re.compile(r[0], re.I), r[1]) for r in [
|
||||
(r"(.*)", r" \1 "),
|
||||
(r"\s\s+", r" "),
|
||||
|
||||
|
||||
(r" si ", r" is "),
|
||||
(r" teh ", r "the "),
|
||||
|
||||
|
||||
# where blah is -> where is blah
|
||||
# XXX: Why two?
|
||||
(r" (where|what|who) (\S+) (is|are) ", r" \1 \3 \2 "),
|
||||
# XXX: Non greedy (.*) ?
|
||||
(r" (where|what|who) (.*) (is|are) ", r" \1 \3 \2 "),
|
||||
|
||||
|
||||
# XXX: Does absolutely nothing?
|
||||
#(r"^\s*(.*?)\s*", r"\1"),
|
||||
|
||||
|
||||
(r" be tellin'?g? ", r" tell "),
|
||||
(r" '?bout ", r" about "),
|
||||
|
||||
(r",? any(hoo?w?|ways?) ", r" "),
|
||||
(r",?\s?(pretty )*please\?? $", r"\?"),
|
||||
|
||||
|
||||
# Profanity filters; just delete it.
|
||||
(r" th(e|at|is) (((m(o|u)th(a|er) ?)?fuck(in'?g?)?|hell|heck|(god-?)?damn?(ed)?) ?)+ ", r" "),
|
||||
(r" wtf ", r" where "),
|
||||
@ -217,7 +217,7 @@ class InfobotDatabase(object):
|
||||
filename = 'Infobot.db'
|
||||
filename = os.path.join(conf.supybot.directories.data(), filename)
|
||||
self._db = anydbm.open(filename, 'c')
|
||||
|
||||
|
||||
def die(self):
|
||||
self._db.close()
|
||||
|
||||
@ -259,7 +259,7 @@ class InfobotDatabase(object):
|
||||
return
|
||||
log.info('dup: %s !%s! %s' % (key, verb, value))
|
||||
raise KeyError, key
|
||||
|
||||
|
||||
def setFactoid(self, key, verb, value):
|
||||
verb = verb.lower()
|
||||
dbKey = key.lower()
|
||||
@ -277,23 +277,23 @@ class InfobotDatabase(object):
|
||||
newValue = '%s, or %s' % (currentValue, value)
|
||||
self._db[dbKey] = newValue
|
||||
log.info('add: %s +%s+ %s' % (key, verb, value))
|
||||
|
||||
|
||||
def deleteFactoid(self, verb, key):
|
||||
verb = verb.lower()
|
||||
dbKey = key.lower()
|
||||
dbKey = '%s %s' % (verb, dbKey)
|
||||
del db[dbKey]
|
||||
log.info('forgot: %s' % key)
|
||||
|
||||
|
||||
def getNumberOfFactoids(self):
|
||||
return len(self._db)
|
||||
|
||||
|
||||
|
||||
class Infobot(callbacks.Privmsg):
|
||||
def __init__(self):
|
||||
callbacks.Privmsg.__init__(self)
|
||||
self.db = InfobotDatabase()
|
||||
|
||||
|
||||
# Patterns for processing private messages.
|
||||
statementRe = re.compile(r'^(no[-:, ]+)?(.+?)\s+(is|are|was|were)'
|
||||
r'\s+(also\s+)?(.+)$', re.I)
|
||||
@ -335,7 +335,7 @@ class Infobot(callbacks.Privmsg):
|
||||
match = self.shortQuestionRe.search(s)
|
||||
if match:
|
||||
self.shortQuestion(proxy, match, addressed)
|
||||
|
||||
|
||||
def statement(self, irc, match, addressed):
|
||||
(correction, key, verb, addition, value) = match.groups()
|
||||
if self.db.hasFactoid(verb, key):
|
||||
@ -383,10 +383,10 @@ class Infobot(callbacks.Privmsg):
|
||||
return
|
||||
if addressed or self.registryValue('replyQuestionWhenNotAddressed'):
|
||||
irc.reply(random.choice(repliesStatement) % factoid)
|
||||
|
||||
|
||||
def forget(self, irc, msg, args):
|
||||
"""<factoid>
|
||||
|
||||
|
||||
Make the bot forget about <factoid>."""
|
||||
key = privmsgs.getArgs()
|
||||
try:
|
||||
@ -401,7 +401,7 @@ class Infobot(callbacks.Privmsg):
|
||||
|
||||
def whatis(self, irc, msg, args):
|
||||
"""<factoid>
|
||||
|
||||
|
||||
Explain what <factoid> is."""
|
||||
key = privmsgs.getArgs()
|
||||
try:
|
||||
@ -416,7 +416,7 @@ class Infobot(callbacks.Privmsg):
|
||||
|
||||
def stats(self, irc, msg, args):
|
||||
"""<requires no arguments>
|
||||
|
||||
|
||||
Display some statistics on the infobot database."""
|
||||
num = self.db.getNumberOfFactoids()
|
||||
if self.registryValue('infobotStyleStatus'):
|
||||
|
@ -72,18 +72,18 @@ class Markov(callbacks.Privmsg):
|
||||
filename = os.path.join(conf.supybot.directories.data(), filename)
|
||||
self.dbCache[channel] = anydbm.open(filename, 'c')
|
||||
return self.dbCache[channel]
|
||||
|
||||
|
||||
def _getNumberOfPairs(self, db):
|
||||
# Minus one, because we have a key storing the first pairs.
|
||||
return len(db) - 1
|
||||
|
||||
|
||||
def _getNumberOfFirstPairs(self, db):
|
||||
try:
|
||||
pairs = db[''].split()
|
||||
except KeyError:
|
||||
return 0
|
||||
return len(pairs)
|
||||
|
||||
|
||||
def _getFirstPair(self, db):
|
||||
try:
|
||||
pairs = db[''].split()
|
||||
@ -91,7 +91,7 @@ class Markov(callbacks.Privmsg):
|
||||
raise ValueError('No starting pairs in the database.')
|
||||
pair = random.choice(pairs)
|
||||
return pair.split('\x00', 1)
|
||||
|
||||
|
||||
def _getFollower(self, db, first, second):
|
||||
pair = '%s %s' % (first, second)
|
||||
try:
|
||||
@ -99,7 +99,7 @@ class Markov(callbacks.Privmsg):
|
||||
except KeyError:
|
||||
return '\x00'
|
||||
return random.choice(followers)
|
||||
|
||||
|
||||
def _addFirstPair(self, db, first, second):
|
||||
pair = '%s\x00%s' % (first, second)
|
||||
try:
|
||||
@ -107,7 +107,7 @@ class Markov(callbacks.Privmsg):
|
||||
except KeyError:
|
||||
startingPairs = ''
|
||||
db[''] = '%s%s ' % (startingPairs, pair)
|
||||
|
||||
|
||||
def _addPair(self, db, first, second, follower):
|
||||
pair = '%s %s' % (first, second)
|
||||
try:
|
||||
|
2
setup.py
2
setup.py
@ -83,7 +83,7 @@ setup(
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Programming Language :: Python',
|
||||
],
|
||||
|
||||
|
||||
# Installation data
|
||||
packages=['supybot',
|
||||
'supybot.src',
|
||||
|
14
src/Admin.py
14
src/Admin.py
@ -57,7 +57,7 @@ import privmsgs
|
||||
import schedule
|
||||
import callbacks
|
||||
|
||||
|
||||
|
||||
class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||
capability = 'admin'
|
||||
def __init__(self):
|
||||
@ -81,7 +81,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||
chans.append(channel)
|
||||
irc.queueMsg(ircmsgs.joins(chans, keys))
|
||||
do422 = do377 = do376
|
||||
|
||||
|
||||
def do437(self, irc, msg):
|
||||
"""Nick/channel temporarily unavailable."""
|
||||
target = msg.args[0]
|
||||
@ -119,7 +119,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||
irc.error('Cannot join %s, it\'s banned me.' % channel)
|
||||
except KeyError:
|
||||
self.log.debug('Got 474 without Admin.join being called.')
|
||||
|
||||
|
||||
def do475(self, irc, msg):
|
||||
try:
|
||||
channel = msg.args[1]
|
||||
@ -153,7 +153,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||
self.log.info('Invited to %s by %s', channel, msg.prefix)
|
||||
irc.queueMsg(ircmsgs.join(channel))
|
||||
conf.supybot.channels().add(channel)
|
||||
|
||||
|
||||
def join(self, irc, msg, args):
|
||||
"""<channel>[,<key>] [<channel>[,<key>] ...]
|
||||
|
||||
@ -226,14 +226,14 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||
'a channel I\'m in is +m and I\'m -v in it.')
|
||||
else:
|
||||
self.log.debug('Got 438 without Admin.nick being called.')
|
||||
|
||||
|
||||
def doNick(self, irc, msg):
|
||||
if msg.nick == irc.nick or msg.args[0] == irc.nick:
|
||||
try:
|
||||
del self.pendingNickChanges[irc]
|
||||
except KeyError:
|
||||
self.log.debug('Got NICK without Admin.nick being called.')
|
||||
|
||||
|
||||
def nick(self, irc, msg, args):
|
||||
"""<nick>
|
||||
|
||||
@ -431,7 +431,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||
irc.replySuccess()
|
||||
except KeyError:
|
||||
irc.error('%s wasn\'t in the ignores database.' % hostmask)
|
||||
|
||||
|
||||
def ignores(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
|
@ -227,7 +227,7 @@ class Config(callbacks.Privmsg):
|
||||
registry.open(world.registryFilename)
|
||||
irc.replySuccess()
|
||||
reload = privmsgs.checkCapability(reload, 'owner')
|
||||
|
||||
|
||||
|
||||
|
||||
Class = Config
|
||||
|
@ -68,7 +68,7 @@ class Misc(callbacks.Privmsg):
|
||||
if not isinstance(irc.irc, irclib.Irc):
|
||||
brackets = conf.supybot.reply.brackets.get(msg.args[0])()
|
||||
irc.reply(''.join([brackets[0],' '.join(tokens), brackets[1]]))
|
||||
|
||||
|
||||
def list(self, irc, msg, args):
|
||||
"""[--private] [<module name>]
|
||||
|
||||
@ -115,7 +115,7 @@ class Misc(callbacks.Privmsg):
|
||||
else:
|
||||
irc.error('That plugin exists, but it has no '
|
||||
'commands with help.')
|
||||
|
||||
|
||||
def apropos(self, irc, msg, args):
|
||||
"""<string>
|
||||
|
||||
@ -176,7 +176,7 @@ class Misc(callbacks.Privmsg):
|
||||
return
|
||||
command = callbacks.canonicalName(name)
|
||||
# Users might expect "@help @list" to work.
|
||||
command = command.lstrip(conf.supybot.prefixChars())
|
||||
command = command.lstrip(conf.supybot.prefixChars())
|
||||
cbs = callbacks.findCallbackForCommand(irc, command)
|
||||
if len(cbs) > 1:
|
||||
tokens = [command]
|
||||
@ -294,7 +294,7 @@ class Misc(callbacks.Privmsg):
|
||||
break
|
||||
L = ['%s: %s' % (k, v) for (k, v) in names.items() if v]
|
||||
irc.reply(utils.commaAndify(L))
|
||||
|
||||
|
||||
def source(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
|
@ -550,7 +550,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
||||
irc.replySuccess()
|
||||
except AttributeError: # There's a cleaner way to do this, but I'm lazy.
|
||||
irc.error('I couldn\'t reconnect. You should restart me instead.')
|
||||
|
||||
|
||||
|
||||
|
||||
Class = Owner
|
||||
|
@ -187,7 +187,7 @@ class User(callbacks.Privmsg):
|
||||
user.name = newname
|
||||
ircdb.users.setUser(id, user)
|
||||
irc.replySuccess()
|
||||
|
||||
|
||||
def addhostmask(self, irc, msg, args):
|
||||
"""<name> <hostmask> [<password>]
|
||||
|
||||
|
18
src/ircdb.py
18
src/ircdb.py
@ -154,7 +154,7 @@ class UserCapabilitySet(CapabilitySet):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.__parent = super(UserCapabilitySet, self)
|
||||
self.__parent.__init__(*args, **kwargs)
|
||||
|
||||
|
||||
def __contains__(self, capability):
|
||||
capability = ircutils.toLower(capability)
|
||||
if capability == 'owner' or capability == antiOwner:
|
||||
@ -423,12 +423,12 @@ class IrcChannel(object):
|
||||
for ignore in self.ignores:
|
||||
write('ignore ' + ignore)
|
||||
fd.write(os.linesep)
|
||||
|
||||
|
||||
|
||||
class Creator(object):
|
||||
def badCommand(self, command, rest, lineno):
|
||||
raise ValueError, 'Invalid command on line %s: %s' % (lineno, command)
|
||||
|
||||
|
||||
class IrcUserCreator(Creator):
|
||||
id = None
|
||||
def __init__(self, users):
|
||||
@ -496,7 +496,7 @@ class IrcChannelCreator(Creator):
|
||||
if self.name is None:
|
||||
raise ValueError, 'Unexpected channel description without channel.'
|
||||
self.c.lobotomized = bool(eval(rest))
|
||||
|
||||
|
||||
def defaultallow(self, rest, lineno):
|
||||
if self.name is None:
|
||||
raise ValueError, 'Unexpected channel description without channel.'
|
||||
@ -531,7 +531,7 @@ class IrcChannelCreator(Creator):
|
||||
if self.hadChannel:
|
||||
self.channels.setChannel(self.name, self.c)
|
||||
IrcChannelCreator.name = None
|
||||
|
||||
|
||||
|
||||
class UsersDictionary(utils.IterableMap):
|
||||
"""A simple serialized-to-file User Database."""
|
||||
@ -666,7 +666,7 @@ class UsersDictionary(utils.IterableMap):
|
||||
for hostmask in self._hostmaskCache[id]:
|
||||
del self._hostmaskCache[hostmask]
|
||||
del self._hostmaskCache[id]
|
||||
|
||||
|
||||
def setUser(self, id, user):
|
||||
"""Sets a user (given its id) to the IrcUser given it."""
|
||||
assert isinstance(id, int), 'setUser takes an integer userId.'
|
||||
@ -713,7 +713,7 @@ class UsersDictionary(utils.IterableMap):
|
||||
self.users[id] = user
|
||||
self.flush()
|
||||
return (id, user)
|
||||
|
||||
|
||||
|
||||
class ChannelsDictionary(utils.IterableMap):
|
||||
def __init__(self):
|
||||
@ -815,7 +815,7 @@ class IgnoresDB(object):
|
||||
log.warning('IgnoresDB.reload failed: %s', e)
|
||||
else:
|
||||
log.warning('IgnoresDB.reload called without self.filename.')
|
||||
|
||||
|
||||
def checkIgnored(self, prefix):
|
||||
for hostmask in self.hostmasks:
|
||||
if ircutils.hostmaskPatternEqual(hostmask, prefix):
|
||||
@ -858,7 +858,7 @@ except EnvironmentError, e:
|
||||
world.flushers.append(users.flush)
|
||||
world.flushers.append(ignores.flush)
|
||||
world.flushers.append(channels.flush)
|
||||
|
||||
|
||||
|
||||
###
|
||||
# Useful functions for checking credentials.
|
||||
|
@ -57,7 +57,7 @@ import utils
|
||||
def debug(s, *args):
|
||||
"""Prints a debug string. Most likely replaced by our logging debug."""
|
||||
print '***', s % args
|
||||
|
||||
|
||||
def isUserHostmask(s):
|
||||
"""Returns whether or not the string s is a valid User hostmask."""
|
||||
p1 = s.find('!')
|
||||
@ -401,7 +401,7 @@ class IrcString(str):
|
||||
"""This class does case-insensitive comparison and hashing of nicks."""
|
||||
def __new__(cls, s=''):
|
||||
return str.__new__(cls, intern(s))
|
||||
|
||||
|
||||
def __init__(self, s):
|
||||
assert isinstance(s, basestring), \
|
||||
'Cannot make an IrcString from %s' % type(s)
|
||||
@ -432,7 +432,7 @@ class IrcSet(sets.Set):
|
||||
self.__parent.__init__()
|
||||
for elt in seq:
|
||||
self.add(elt)
|
||||
|
||||
|
||||
def add(self, s):
|
||||
return self.__parent.add(IrcString(s))
|
||||
|
||||
|
10
src/log.py
10
src/log.py
@ -93,7 +93,7 @@ class StdoutStreamHandler(logging.StreamHandler):
|
||||
self.disable()
|
||||
error('Error logging to stdout. Removing stdout handler.')
|
||||
exception('Uncaught exception in StdoutStreamHandler:')
|
||||
|
||||
|
||||
|
||||
class BetterFileHandler(logging.FileHandler):
|
||||
def emit(self, record):
|
||||
@ -208,7 +208,7 @@ def firewall(f, errorHandler=None):
|
||||
errorHandler(self, *args, **kwargs)
|
||||
except Exception, e:
|
||||
logException(self, 'Uncaught exception in errorHandler')
|
||||
|
||||
|
||||
m = utils.changeFunctionName(m, f.func_name, f.__doc__)
|
||||
return m
|
||||
|
||||
@ -245,14 +245,14 @@ class ValidLogLevel(registry.String):
|
||||
|
||||
def __str__(self):
|
||||
return logging.getLevelName(self.value)
|
||||
|
||||
|
||||
class LogLevel(ValidLogLevel):
|
||||
"""Invalid log level. Value must be either DEBUG, INFO, WARNING, ERROR,
|
||||
or CRITICAL."""
|
||||
def setValue(self, v):
|
||||
ValidLogLevel.setValue(self, v)
|
||||
_logger.setLevel(self.value) # _logger defined later.
|
||||
|
||||
|
||||
conf.supybot.directories.register('log', registry.String('logs', """Determines
|
||||
what directory the bot will store its logfiles in."""))
|
||||
|
||||
@ -271,7 +271,7 @@ class BooleanRequiredFalseOnWindows(registry.Boolean):
|
||||
registry.Boolean.set(self, s)
|
||||
if self.value and os.name == 'nt':
|
||||
raise InvalidRegistryValue, 'Value cannot be true on Windows.'
|
||||
|
||||
|
||||
conf.supybot.log.stdout.register('colorized',
|
||||
BooleanRequiredFalseOnWindows(False, """Determines whether the bot's logs to
|
||||
stdout (if enabled) will be colorized with ANSI color."""))
|
||||
|
@ -107,8 +107,8 @@ class DBHandler(object):
|
||||
if self.cachedDb is not None:
|
||||
self.cachedDb.die()
|
||||
del self.cachedDb
|
||||
|
||||
|
||||
|
||||
|
||||
# XXX: This shouldn't be a mixin. This should be contained by classes that
|
||||
# want such behavior. But at this point, it wouldn't gain much for us
|
||||
# to refactor it.
|
||||
@ -174,18 +174,18 @@ class ChannelUserDictionary(UserDict.DictMixin):
|
||||
|
||||
def __delitem__(self, (channel, id)):
|
||||
del self.channels[channel][id]
|
||||
|
||||
|
||||
def iteritems(self):
|
||||
for (channel, ids) in self.channels.iteritems():
|
||||
for (id, v) in ids.iteritems():
|
||||
yield ((channel, id), v)
|
||||
|
||||
|
||||
def keys(self):
|
||||
L = []
|
||||
for (k, _) in self.iteritems():
|
||||
L.append(k)
|
||||
return L
|
||||
|
||||
|
||||
|
||||
class ChannelUserDB(ChannelUserDictionary):
|
||||
def __init__(self, filename):
|
||||
@ -347,7 +347,7 @@ class PeriodicFileDownloader(object):
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
world.threadsSpawned += 1
|
||||
|
||||
|
||||
|
||||
_randomnickRe = re.compile(r'\$rand(?:om)?nick', re.I)
|
||||
_randomdateRe = re.compile(r'\$rand(?:om)?date', re.I)
|
||||
@ -368,7 +368,7 @@ def standardSubstitute(irc, msg, text):
|
||||
def randInt(m):
|
||||
return str(random.randint(-1000, 1000))
|
||||
def randDate(m):
|
||||
t = pow(2,30)*random.random()+time.time()/4.0
|
||||
t = pow(2,30)*random.random()+time.time()/4.0
|
||||
return time.ctime(t)
|
||||
def randNick(m):
|
||||
if channel != 'somewhere':
|
||||
|
@ -141,7 +141,7 @@ def _threadedWrapMethod(f):
|
||||
finally:
|
||||
self.threaded = originalThreaded
|
||||
return utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||
|
||||
|
||||
def thread(f):
|
||||
"""Makes sure a command spawns a thread when called."""
|
||||
f = _threadedWrapMethod(f)
|
||||
@ -194,7 +194,7 @@ def urlSnarfer(f):
|
||||
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||
newf.q = q # This isn't necessary, it's just for debugging.
|
||||
return newf
|
||||
|
||||
|
||||
|
||||
class CapabilityCheckingPrivmsg(callbacks.Privmsg):
|
||||
"""A small subclass of callbacks.Privmsg that checks self.capability
|
||||
|
@ -148,7 +148,7 @@ class Group(object):
|
||||
return self.__makeChild(attr, str(self))
|
||||
else:
|
||||
self.__nonExistentEntry(attr)
|
||||
|
||||
|
||||
def get(self, attr):
|
||||
# Not getattr(self, attr) because some nodes might have groups that
|
||||
# are named the same as their methods.
|
||||
@ -167,7 +167,7 @@ class Group(object):
|
||||
except InvalidRegistryValue:
|
||||
# It's probably supposed to be registered later.
|
||||
pass
|
||||
|
||||
|
||||
def register(self, name, node=None):
|
||||
if not isValidRegistryName(name):
|
||||
raise InvalidRegistryName, name
|
||||
@ -214,7 +214,7 @@ class Value(Group):
|
||||
private=False, showDefault=True, **kwargs):
|
||||
Group.__init__(self, **kwargs)
|
||||
self.default = default
|
||||
self.private = private
|
||||
self.private = private
|
||||
self.showDefault = showDefault
|
||||
self.help = utils.normalizeWhitespace(help.strip())
|
||||
self.setValue(default)
|
||||
@ -250,7 +250,7 @@ class Value(Group):
|
||||
for (name, v) in self.children.items():
|
||||
if v.__class__ is self.X:
|
||||
self.unregister(name)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return repr(self())
|
||||
|
||||
@ -334,7 +334,7 @@ class OnlySomeStrings(String):
|
||||
assert self.validStrings, 'There must be some valid strings. ' \
|
||||
'This is a bug.'
|
||||
String.__init__(self, *args, **kwargs)
|
||||
|
||||
|
||||
def error(self):
|
||||
raise InvalidRegistryValue, \
|
||||
'That is not a valid value. Valid values include %s.' % \
|
||||
@ -348,14 +348,14 @@ class OnlySomeStrings(String):
|
||||
except ValueError:
|
||||
return s # This is handled in setValue.
|
||||
return self.validStrings[i]
|
||||
|
||||
|
||||
def setValue(self, s):
|
||||
s = self.normalize(s)
|
||||
if s in self.validStrings:
|
||||
String.setValue(self, s)
|
||||
else:
|
||||
self.error()
|
||||
|
||||
|
||||
class NormalizedString(String):
|
||||
def set(self, s):
|
||||
s = utils.normalizeWhitespace(s.strip())
|
||||
@ -376,7 +376,7 @@ class StringSurroundedBySpaces(String):
|
||||
if v.rstrip() == v:
|
||||
v += ' '
|
||||
String.setValue(self, v)
|
||||
|
||||
|
||||
class StringWithSpaceOnRight(String):
|
||||
def setValue(self, v):
|
||||
if v.rstrip() == v:
|
||||
@ -410,7 +410,7 @@ class Regexp(Value):
|
||||
def __str__(self):
|
||||
self() # Gotta update if we've been reloaded.
|
||||
return self.sr
|
||||
|
||||
|
||||
class SeparatedListOf(Value):
|
||||
List = list
|
||||
Value = Value
|
||||
@ -422,7 +422,7 @@ class SeparatedListOf(Value):
|
||||
def joiner(self, L):
|
||||
"""Override this to join the internal list for output."""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def set(self, s):
|
||||
L = self.splitter(s)
|
||||
for (i, s) in enumerate(L):
|
||||
@ -442,13 +442,13 @@ class SeparatedListOf(Value):
|
||||
# can run into issues showing users the value if they've disabled
|
||||
# nick prefixes in any of the numerous ways possible. Since the
|
||||
# config parser doesn't care about this space, we'll use it :)
|
||||
return ' '
|
||||
|
||||
return ' '
|
||||
|
||||
class SpaceSeparatedListOf(SeparatedListOf):
|
||||
def splitter(self, s):
|
||||
return s.split()
|
||||
joiner = ' '.join
|
||||
|
||||
|
||||
class SpaceSeparatedListOfStrings(SpaceSeparatedListOf):
|
||||
Value = String
|
||||
|
||||
@ -457,7 +457,7 @@ class CommaSeparatedListOfStrings(SeparatedListOf):
|
||||
def splitter(self, s):
|
||||
return re.split(r'\s*,\s*', s)
|
||||
joiner = ', '.join
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
#if 1:
|
||||
@ -496,7 +496,7 @@ if __name__ == '__main__':
|
||||
|
||||
print supybot.throttleTime.help
|
||||
print supybot.plugins.topic.separator.help
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
@ -182,7 +182,7 @@ class queue(object):
|
||||
def reset(self):
|
||||
self.back[:] = []
|
||||
self.front[:] = []
|
||||
|
||||
|
||||
def enqueue(self, elt):
|
||||
self.back.append(elt)
|
||||
|
||||
@ -342,7 +342,7 @@ class TwoWayDictionary(dict):
|
||||
for (key, value) in kwargs.iteritems():
|
||||
self[key] = value
|
||||
self[value] = key
|
||||
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
dict.__setitem__(self, key, value)
|
||||
dict.__setitem__(self, value, key)
|
||||
|
@ -101,7 +101,7 @@ class SupyReconnectingFactory(ReconnectingClientFactory):
|
||||
protocol = ReconnectingClientFactory.buildProtocol(self, addr)
|
||||
protocol.irc = self.irc
|
||||
return protocol
|
||||
|
||||
|
||||
def die(self):
|
||||
pass
|
||||
|
||||
|
@ -42,10 +42,10 @@ class Reader(object):
|
||||
|
||||
def normalizeCommand(self, s):
|
||||
return s.lower()
|
||||
|
||||
|
||||
def readFile(self, filename):
|
||||
self.read(file(filename))
|
||||
|
||||
|
||||
def read(self, fd):
|
||||
lineno = 0
|
||||
for line in fd:
|
||||
|
@ -335,11 +335,11 @@ def pluralize(s, i=2):
|
||||
lowered = s.lower()
|
||||
# Exception dictionary
|
||||
if lowered in plurals:
|
||||
return matchCase(s, plurals[lowered])
|
||||
return matchCase(s, plurals[lowered])
|
||||
# Words ending with 'ch', 'sh' or 'ss' such as 'punch(es)', 'fish(es)
|
||||
# and miss(es)
|
||||
elif any(lowered.endswith, ['ch', 'sh', 'ss']):
|
||||
return matchCase(s, s+'es')
|
||||
return matchCase(s, s+'es')
|
||||
# Words ending with a consonant followed by a 'y' such as
|
||||
# 'try (tries)' or 'spy (spies)'
|
||||
elif re.search(_pluralizeRegex, lowered):
|
||||
|
@ -36,7 +36,7 @@ import logging
|
||||
|
||||
if not os.path.exists('test-conf'):
|
||||
os.mkdir('test-conf')
|
||||
|
||||
|
||||
registryFilename = os.path.join('test-conf', 'test.conf')
|
||||
fd = file(registryFilename, 'w')
|
||||
fd.write("""
|
||||
@ -94,7 +94,7 @@ if __name__ == '__main__':
|
||||
pluginLogDir = os.path.join(conf.supybot.directories.log(), 'plugins')
|
||||
if not os.path.exists(pluginLogDir):
|
||||
os.mkdir(pluginLogDir)
|
||||
|
||||
|
||||
for filename in os.listdir(pluginLogDir):
|
||||
os.remove(os.path.join(pluginLogDir, filename))
|
||||
|
||||
|
@ -136,7 +136,7 @@ class AdminTestCase(PluginTestCase, PluginDocumentation):
|
||||
|
||||
def testAddCapabilityOwner(self):
|
||||
self.assertError('admin addcapability %s owner' % self.nick)
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -69,14 +69,14 @@ class AliasTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
plugins = ('Alias', 'Filter', 'Utilities')
|
||||
def testNoAliasWithNestedCommandName(self):
|
||||
self.assertError('alias add foo "[bar] baz"')
|
||||
|
||||
|
||||
def testDoesNotOverwriteCommands(self):
|
||||
self.assertError('alias add alias "echo foo bar baz"')
|
||||
self.assertError('alias add add "echo foo bar baz"')
|
||||
self.assertError('alias add remove "echo foo bar baz"')
|
||||
self.assertError('alias add lock "echo foo bar baz"')
|
||||
self.assertError('alias add unlock "echo foo bar baz"')
|
||||
|
||||
|
||||
def testAliasHelp(self):
|
||||
self.assertNotError('alias add slashdot foo')
|
||||
self.assertRegexp('help slashdot', "Alias for 'foo.*'")
|
||||
@ -86,7 +86,7 @@ class AliasTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
self.assertResponse('foo', 'bar')
|
||||
self.assertNotError('alias remove foo')
|
||||
self.assertNoResponse('foo', 2)
|
||||
|
||||
|
||||
def testDollars(self):
|
||||
self.assertNotError('alias add rot26 "rot13 [rot13 $1]"')
|
||||
self.assertResponse('rot26 foobar', 'foobar')
|
||||
@ -155,7 +155,7 @@ class AliasTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
def testSimpleAliasWithoutArgsImpliesDollarStar(self):
|
||||
self.assertNotError('alias add exo echo')
|
||||
self.assertResponse('exo foo bar baz', 'foo bar baz')
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -51,7 +51,7 @@ class BadWordsTestCase(PluginTestCase):
|
||||
self.assertRegexp('echo %s' % word, word)
|
||||
self.assertRegexp('echo foo%sbar' % word, word)
|
||||
self.assertRegexp('echo [strjoin "" %s]' % ' '.join(word), word)
|
||||
|
||||
|
||||
def testAddbadwords(self):
|
||||
self.assertNotError('badwords add %s' % ' '.join(self.badwords))
|
||||
self._test()
|
||||
|
@ -51,7 +51,7 @@ if sqlite is not None:
|
||||
_ = self.irc.takeMsg()
|
||||
chanop = ircdb.makeChannelCapability(self.channel, 'op')
|
||||
ircdb.users.getUser(self.nick).addCapability(chanop)
|
||||
|
||||
|
||||
def test(self):
|
||||
self.assertNotError('channelstats')
|
||||
self.assertNotError('channelstats')
|
||||
@ -79,7 +79,7 @@ if sqlite is not None:
|
||||
self.assertEqual(m1.args[1], m2.args[1])
|
||||
finally:
|
||||
conf.supybot.plugins.ChannelStats.selfStats.setValue(True)
|
||||
|
||||
|
||||
def testNoKeyErrorStats(self):
|
||||
self.assertNotRegexp('stats sweede', 'KeyError')
|
||||
|
||||
|
@ -56,7 +56,7 @@ class FunTest(ChannelPluginTestCase, PluginDocumentation):
|
||||
|
||||
def testPing(self):
|
||||
self.assertResponse('ping', 'pong')
|
||||
|
||||
|
||||
def testNoErrors(self):
|
||||
self.assertNotError('objects')
|
||||
self.assertNotError('levenshtein Python Perl')
|
||||
|
@ -70,7 +70,7 @@ if network:
|
||||
conf.supybot.plugins.Gameknot.statSnarfer.setValue(True)
|
||||
self.assertNotError('http://gameknot.com/stats.pl?ironchefchess')
|
||||
self.assertNotError('http://gameknot.com/chess.pl?bd=907498')
|
||||
|
||||
|
||||
|
||||
def testSnarfer(self):
|
||||
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True)
|
||||
|
@ -38,7 +38,7 @@ class GoogleTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'google blah'))
|
||||
self.assertNoResponse(' ')
|
||||
|
||||
|
||||
def testGroupsSnarfer(self):
|
||||
conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
|
||||
self.assertRegexp('http://groups.google.com/groups?dq=&hl=en&'
|
||||
|
@ -43,7 +43,7 @@ if network:
|
||||
def testHeaders(self):
|
||||
self.assertError('headers ftp://ftp.cdrom.com/pub/linux')
|
||||
self.assertNotError('headers http://www.slashdot.org/')
|
||||
|
||||
|
||||
def testDoctype(self):
|
||||
self.assertError('doctype ftp://ftp.cdrom.com/pub/linux')
|
||||
self.assertNotError('doctype http://www.slashdot.org/')
|
||||
|
@ -54,7 +54,7 @@ if sqlite:
|
||||
|
||||
def testCantCreateLookupNamedLookup(self):
|
||||
self.assertError('lookup add lookup foo.supyfact')
|
||||
|
||||
|
||||
def setUp(self):
|
||||
PluginTestCase.setUp(self)
|
||||
dataDir = conf.supybot.directories.data()
|
||||
|
@ -79,16 +79,16 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertResponse('base 10 8 [base 8 76532]', '76532')
|
||||
self.assertResponse('base 10 36 [base 36 csalnwea]', 'CSALNWEA')
|
||||
self.assertResponse('base 5 4 [base 4 5 212231]', '212231')
|
||||
|
||||
|
||||
self.assertRegexp('base 37 1', 'between 2 and 36')
|
||||
self.assertRegexp('base 1 1', 'between 2 and 36')
|
||||
self.assertRegexp('base 12 1 1', 'between 2 and 36')
|
||||
self.assertRegexp('base 1 12 1', 'between 2 and 36')
|
||||
self.assertRegexp('base 1.0 12 1', 'between 2 and 36')
|
||||
self.assertRegexp('base A 1', 'between 2 and 36')
|
||||
|
||||
|
||||
self.assertRegexp('base 4 4', 'Invalid <number>')
|
||||
self.assertRegexp('base 10 12 A', 'Invalid <number>')
|
||||
self.assertRegexp('base 10 12 A', 'Invalid <number>')
|
||||
|
||||
print
|
||||
print "If we have not fixed a bug with Math.base, the following ",
|
||||
@ -125,7 +125,7 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
||||
|
||||
def testCalcFloorWorksWithSqrt(self):
|
||||
self.assertNotError('calc floor(sqrt(5))')
|
||||
|
||||
|
||||
def testRpn(self):
|
||||
self.assertResponse('rpn 5 2 +', '7')
|
||||
self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]')
|
||||
@ -138,7 +138,7 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
||||
|
||||
def testRpmNoSyntaxError(self):
|
||||
self.assertNotRegexp('rpn 2 3 foobar', 'SyntaxError')
|
||||
|
||||
|
||||
def testConvert(self):
|
||||
self.assertResponse('convert 1 m to cm', '100')
|
||||
self.assertResponse('convert m to cm', '100')
|
||||
@ -146,7 +146,7 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertResponse('convert 32 F to C', '0')
|
||||
self.assertResponse('convert 32 C to F', '89.6')
|
||||
self.assertResponse('convert [calc 2*pi] rad to degree', '360')
|
||||
self.assertResponse('convert amu to atomic mass unit',
|
||||
self.assertResponse('convert amu to atomic mass unit',
|
||||
'1')
|
||||
self.assertResponse('convert [calc 2*pi] rad to circle', '1')
|
||||
|
||||
@ -156,7 +156,7 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertError('convert 1 gram to meatballs')
|
||||
self.assertError('convert 1 mol to grams')
|
||||
self.assertError('convert 1 m to kpa')
|
||||
|
||||
|
||||
def testConvertSingularPlural(self):
|
||||
self.assertResponse('convert [calc 2*pi] rads to degrees',
|
||||
'360')
|
||||
|
@ -68,7 +68,7 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
self.assertResponse('StRlEn foobar', '6')
|
||||
finally:
|
||||
conf.supybot.reply.whenNotCommand.set(original)
|
||||
|
||||
|
||||
def testHelp(self):
|
||||
self.assertHelp('help list')
|
||||
self.assertRegexp('help help', r'^\(\x02help')
|
||||
@ -171,11 +171,11 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
self.assertNotError('more %s' % nick)
|
||||
self.assertNotError('more %s' % nick.upper())
|
||||
self.assertNotError('more %s' % nick.lower())
|
||||
|
||||
|
||||
def testPrivate(self):
|
||||
m = self.getMsg('private [list]')
|
||||
self.failIf(ircutils.isChannel(m.args[0]))
|
||||
|
||||
|
||||
def testNotice(self):
|
||||
m = self.getMsg('notice [list]')
|
||||
self.assertEqual(m.command, 'NOTICE')
|
||||
@ -211,7 +211,7 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
|
||||
def testRevisionIsCaseInsensitive(self):
|
||||
self.assertNotError('revision misc')
|
||||
|
||||
|
||||
def testSeconds(self):
|
||||
self.assertResponse('seconds 1s', '1')
|
||||
self.assertResponse('seconds 10s', '10')
|
||||
|
@ -53,7 +53,7 @@ if sqlite is not None:
|
||||
if option in L:
|
||||
L.remove(option)
|
||||
self.failIf(L, 'Some options never seen: %s' % L)
|
||||
|
||||
|
||||
def testPickOptions(self):
|
||||
self._testOptions('(a|b)', ['a', 'b'])
|
||||
self._testOptions('a', ['a'])
|
||||
@ -76,7 +76,7 @@ if sqlite is not None:
|
||||
self.assertNotError('moo is foo')
|
||||
# Check stripping punctuation
|
||||
self.assertError('moo!? is foo') # 'moo' already exists
|
||||
self.assertNotError('foo!? is foo')
|
||||
self.assertNotError('foo!? is foo')
|
||||
self.assertResponse('foo', 'foo is foo')
|
||||
self.assertNotError('bar is <reply>moo is moo')
|
||||
self.assertResponse('bar', 'moo is moo')
|
||||
@ -149,7 +149,7 @@ if sqlite is not None:
|
||||
'Last requested by foo!bar@baz on .*?, '
|
||||
'requested 2 times.$')
|
||||
# Make sure I solved this bug
|
||||
# Check and make sure all the other stuff is reset
|
||||
# Check and make sure all the other stuff is reset
|
||||
self.assertNotError('foo is bar')
|
||||
self.assertNotError('foo =~ s/bar/blah/')
|
||||
self.assertNotError('foo')
|
||||
@ -183,7 +183,7 @@ if sqlite is not None:
|
||||
'^moo: Created by tester on.*?\.')
|
||||
finally:
|
||||
world.testing = True
|
||||
|
||||
|
||||
def testChangeFactoid(self):
|
||||
self.assertNotError('moo is <reply>moo')
|
||||
self.assertNotError('moo =~ s/moo/moos/')
|
||||
@ -214,8 +214,8 @@ if sqlite is not None:
|
||||
self.assertNotError('moogle is <reply>moo')
|
||||
self.assertError('most popular')
|
||||
self.assertResponse('most authored',
|
||||
'Most prolific author: moo (1)')
|
||||
self.assertRegexp('most recent', "1 latest factoid:.*moogle")
|
||||
'Most prolific author: moo (1)')
|
||||
self.assertRegexp('most recent', "1 latest factoid:.*moogle")
|
||||
self.assertResponse('moogle', 'moo')
|
||||
self.assertRegexp('most popular',
|
||||
"Top 1 requested factoid:.*moogle.*(1)")
|
||||
@ -223,9 +223,9 @@ if sqlite is not None:
|
||||
self.prefix = userPrefix2
|
||||
self.assertNotError('mogle is <reply>mo')
|
||||
self.assertRegexp('most authored',
|
||||
'Most prolific authors:.*moo.*(1).*boo.*(1)')
|
||||
'Most prolific authors:.*moo.*(1).*boo.*(1)')
|
||||
self.assertRegexp('most recent',
|
||||
"2 latest factoids:.*mogle.*moogle.*")
|
||||
"2 latest factoids:.*mogle.*moogle.*")
|
||||
self.assertResponse('moogle', 'moo')
|
||||
self.assertRegexp('most popular',
|
||||
"Top 1 requested factoid:.*moogle.*(2)")
|
||||
@ -339,6 +339,6 @@ if sqlite is not None:
|
||||
self.assertNotError('foo is <reply>bar')
|
||||
self.assertNotError('bar is <reply>baz')
|
||||
self.assertRegexp('randomfactoid', r'bar|baz')
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -85,7 +85,7 @@ if sqlite is not None:
|
||||
time.sleep(6)
|
||||
print 'Done sleeping.'
|
||||
self.assertNotError('old')
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
@ -45,7 +45,7 @@ class OSUTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertRegexp('osu building Dl', r'^Dreese Lab')
|
||||
self.assertRegexp('osu building dL', r'^Dreese Lab')
|
||||
self.assertRegexp('osu building dl', r'^Dreese Lab')
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
@ -45,7 +45,7 @@ class OwnerTestCase(PluginTestCase, PluginDocumentation):
|
||||
conf.allowEval = True
|
||||
self.assertNotError('eval 100')
|
||||
s = "[irc.__class__ for irc in " \
|
||||
"irc.getCallback('Relay').ircstates.keys()]"
|
||||
"irc.getCallback('Relay').ircstates.keys()]"
|
||||
self.assertNotRegexp('eval ' + s, '^SyntaxError')
|
||||
conf.allowEval = False
|
||||
self.assertError('eval 100')
|
||||
|
@ -68,9 +68,9 @@ class PythonTestCase(PluginTestCase, PluginDocumentation):
|
||||
'Implementation of sets using sorted lists')
|
||||
finally:
|
||||
conf.supybot.plugins.Python.aspnSnarfer.setValue(False)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
@ -44,7 +44,7 @@ if sqlite:
|
||||
plugins = ('QuoteGrabs',)
|
||||
def testQuoteGrab(self):
|
||||
testPrefix = 'foo!bar@baz'
|
||||
self.assertError('grab foo')
|
||||
self.assertError('grab foo')
|
||||
# Test join/part/notice (shouldn't grab)
|
||||
self.irc.feedMsg(ircmsgs.join(self.channel, prefix=testPrefix))
|
||||
self.assertError('grab foo')
|
||||
@ -53,7 +53,7 @@ if sqlite:
|
||||
# Test privmsgs
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something',
|
||||
prefix=testPrefix))
|
||||
self.assertNotError('grab foo')
|
||||
self.assertNotError('grab foo')
|
||||
self.assertResponse('quote foo', '<foo> something')
|
||||
# Test actions
|
||||
self.irc.feedMsg(ircmsgs.action(self.channel, 'moos',
|
||||
@ -78,7 +78,7 @@ if sqlite:
|
||||
testPrefix = 'foo!bar@baz'
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
||||
prefix=testPrefix))
|
||||
self.assertNotError('grab foo')
|
||||
self.assertNotError('grab foo')
|
||||
self.assertNotError('grab foo') # note:NOTanerror,stillwon'tdupe
|
||||
self.assertResponse('quotegrabs list foo', '#1: test')
|
||||
|
||||
|
@ -71,7 +71,7 @@ if sqlite is not None:
|
||||
self.assertRegexp('stats #foo', '0')
|
||||
self.assertError('random #foo')
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
@ -63,12 +63,12 @@ class RootWarnerTestCase(PluginTestCase):
|
||||
finally:
|
||||
conf.supybot.plugins.RootWarner.warn.setValue(True)
|
||||
conf.supybot.plugins.RootWarner.kick.setValue(False)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -38,7 +38,7 @@ class SchedulerTestCase(ChannelPluginTestCase):
|
||||
def tearDown(self):
|
||||
schedule.schedule.reset()
|
||||
ChannelPluginTestCase.tearDown(self)
|
||||
|
||||
|
||||
def testAddRemove(self):
|
||||
self.assertRegexp('scheduler list', 'no.*commands')
|
||||
m = self.assertNotError('scheduler add 5 echo testAddRemove')
|
||||
|
@ -143,7 +143,7 @@ if network:
|
||||
'func=detail&aid=400942&group_id=235&'
|
||||
'atid=390395',
|
||||
s)
|
||||
|
||||
|
||||
# test that it works without index.php
|
||||
self.assertNotError('http://sourceforge.net/tracker/?'
|
||||
'func=detail&aid=540223&group_id=235&'
|
||||
|
@ -65,7 +65,7 @@ https://sourceforge.net/projects/pyrelaychecker/
|
||||
http://gameknot.com/tsignup.pl
|
||||
http://lambda.weblogs.com/xml/rss.xml
|
||||
""".strip().splitlines()
|
||||
|
||||
|
||||
try:
|
||||
import sqlite
|
||||
except ImportError:
|
||||
@ -77,7 +77,7 @@ if sqlite is not None:
|
||||
def setUp(self):
|
||||
ChannelPluginTestCase.setUp(self)
|
||||
conf.supybot.plugins.URL.tinyurlSnarfer.setValue(False)
|
||||
|
||||
|
||||
def test(self):
|
||||
counter = 0
|
||||
self.assertNotError('url random')
|
||||
|
@ -65,6 +65,6 @@ if os.name == 'posix':
|
||||
def testFortune(self):
|
||||
self.assertNotError('fortune')
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -45,7 +45,7 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
|
||||
## self.assertNotError('register foo bar')
|
||||
## self.prefix = original
|
||||
## self.assertRegexp('hostmasks foo', 'only.*your.*own')
|
||||
|
||||
|
||||
def testRegisterUnregister(self):
|
||||
self.prefix = self.prefix1
|
||||
self.assertNotError('register foo bar')
|
||||
@ -75,7 +75,7 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertNotError('register Foo bar')
|
||||
self.assertResponse('user list', 'Foo')
|
||||
self.assertResponse('user list f*', 'Foo')
|
||||
|
||||
|
||||
def testChangeUsername(self):
|
||||
self.prefix = self.prefix1
|
||||
self.assertNotError('register foo bar')
|
||||
@ -93,7 +93,7 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertEqual(ircdb.users.getUser(self.prefix).password, 'baz')
|
||||
self.assertNotError('setpassword --hashed foo baz biff')
|
||||
self.assertNotEqual(ircdb.users.getUser(self.prefix).password, 'biff')
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
@ -43,7 +43,7 @@ class UtilitiesTestCase(PluginTestCase):
|
||||
|
||||
def testLast(self):
|
||||
self.assertResponse('utilities last foo bar baz', 'baz')
|
||||
|
||||
|
||||
def testStrjoin(self):
|
||||
self.assertResponse('strjoin + foo bar baz', 'foo+bar+baz')
|
||||
|
||||
|
@ -129,13 +129,13 @@ class TokenizerTestCase(SupyTestCase):
|
||||
self.assertEqual(tokenize(s), [s])
|
||||
s = s[:-1] + '\x0f'
|
||||
self.assertEqual(tokenize(s), [s])
|
||||
|
||||
|
||||
def testColor(self):
|
||||
s = '\x032,3foo\x03'
|
||||
self.assertEqual(tokenize(s), [s])
|
||||
s = s[:-1] + '\x0f'
|
||||
self.assertEqual(tokenize(s), [s])
|
||||
|
||||
|
||||
|
||||
class FunctionsTestCase(SupyTestCase):
|
||||
def testCanonicalName(self):
|
||||
@ -226,7 +226,7 @@ class FunctionsTestCase(SupyTestCase):
|
||||
self.assertEqual(callbacks.tokenize('foo'), ['foo'])
|
||||
self.assertEqual(callbacks.tokenize('foo'), ['foo'])
|
||||
self.assertEqual(callbacks.tokenize('bar [baz]'), ['bar', ['baz']])
|
||||
|
||||
|
||||
|
||||
class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
plugins = ('Utilities', 'Misc')
|
||||
@ -295,7 +295,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
self.failIf(ircutils.isChannel(m.args[0]))
|
||||
finally:
|
||||
conf.supybot.reply.errorInPrivate.set(original)
|
||||
|
||||
|
||||
# Now for stuff not based on the plugins.
|
||||
class First(callbacks.Privmsg):
|
||||
def firstcmd(self, irc, msg, args):
|
||||
@ -347,7 +347,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
self.irc.addCallback(self.First())
|
||||
self.irc.addCallback(self.FirstRepeat())
|
||||
self.assertError('help first')
|
||||
|
||||
|
||||
def testHelpDispatching(self):
|
||||
self.irc.addCallback(self.First())
|
||||
self.assertHelp('help firstcmd')
|
||||
@ -413,7 +413,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
def invalidCommand(self, irc, msg, tokens):
|
||||
s = 'This shouldn\'t keep Misc.invalidCommand from being called'
|
||||
raise Exception, s
|
||||
|
||||
|
||||
def testBadInvalidCommandDoesNotKillAll(self):
|
||||
try:
|
||||
original = str(conf.supybot.reply.whenNotCommand)
|
||||
@ -422,7 +422,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
self.assertRegexp('asdfjkl', 'not a valid command')
|
||||
finally:
|
||||
conf.supybot.reply.whenNotCommand.set(original)
|
||||
|
||||
|
||||
|
||||
class PrivmsgCommandAndRegexpTestCase(PluginTestCase):
|
||||
plugins = ()
|
||||
|
@ -90,7 +90,7 @@ class FunctionsTest(SupyTestCase):
|
||||
def testRsplit(self):
|
||||
self.assertEqual(rsplit('foo bar baz'), 'foo bar baz'.split())
|
||||
self.assertEqual(rsplit('foo bar baz', maxsplit=1),
|
||||
['foo bar', 'baz'])
|
||||
['foo bar', 'baz'])
|
||||
self.assertEqual(rsplit('foo bar baz', maxsplit=1),
|
||||
['foo bar', 'baz'])
|
||||
self.assertEqual(rsplit('foobarbaz', 'bar'), ['foo', 'baz'])
|
||||
|
@ -53,7 +53,7 @@ class IrcMsgQueueTestCase(SupyTestCase):
|
||||
def testInit(self):
|
||||
q = irclib.IrcMsgQueue([self.msg, self.topic, self.ping])
|
||||
self.assertEqual(len(q), 3)
|
||||
|
||||
|
||||
def testLen(self):
|
||||
q = irclib.IrcMsgQueue()
|
||||
q.enqueue(self.msg)
|
||||
@ -262,7 +262,7 @@ class IrcStateTestCase(SupyTestCase):
|
||||
st.addMsg(self.irc, ircmsgs.quit(prefix='foo!bar@baz'))
|
||||
self.failIf('foo' in st.channels['#foo'].users)
|
||||
self.failUnless('foo' in st2.channels['#foo'].users)
|
||||
|
||||
|
||||
|
||||
def testEq(self):
|
||||
state1 = irclib.IrcState()
|
||||
@ -314,7 +314,7 @@ class IrcTestCase(SupyTestCase):
|
||||
|
||||
def test433Response(self):
|
||||
# This is necessary; it won't change nick if irc.originalName==irc.nick
|
||||
self.irc.nick = 'somethingElse'
|
||||
self.irc.nick = 'somethingElse'
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg('433 * %s :Nickname already in use.' %\
|
||||
self.irc.nick))
|
||||
msg = self.irc.takeMsg()
|
||||
|
@ -54,7 +54,7 @@ class FunctionsTestCase(SupyTestCase):
|
||||
s = 'jamessan|work!~jamessan@209-6-166-196.c3-0.' \
|
||||
'abr-ubr1.sbo-abr.ma.cable.rcn.com'
|
||||
self.failUnless(ircutils.hostmaskPatternEqual(s, s))
|
||||
|
||||
|
||||
def testIsUserHostmask(self):
|
||||
self.failUnless(ircutils.isUserHostmask(self.hostmask))
|
||||
self.failUnless(ircutils.isUserHostmask('a!b@c'))
|
||||
@ -237,7 +237,7 @@ class FunctionsTestCase(SupyTestCase):
|
||||
for _ in range(100): # 100 should be good :)
|
||||
ip = randomIP()
|
||||
self.assertEqual(ip, ircutils.unDccIP(ircutils.dccIP(ip)))
|
||||
|
||||
|
||||
|
||||
class IrcDictTestCase(SupyTestCase):
|
||||
def test(self):
|
||||
|
@ -82,12 +82,12 @@ class FunctionsTestCase(SupyTestCase):
|
||||
self.failIf(all(L[0].__eq__, L), 'all $randomnicks were the same')
|
||||
c = plugins.standardSubstitute(self.irc, msg, '$channel')
|
||||
self.assertEqual(c, msg.args[0])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ class UrlSnarferTestCase(PluginTestCase):
|
||||
self.FCalled = False
|
||||
self.GCalled = False
|
||||
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||
|
||||
|
||||
def F(self, irc, msg, match):
|
||||
r"."
|
||||
self.FCalled = True
|
||||
|
@ -131,6 +131,6 @@ class ValuesTestCase(SupyTestCase):
|
||||
self.assertEqual(v(), None)
|
||||
self.assertRaises(registry.InvalidRegistryValue,
|
||||
v.setValue, re.compile(r'foo'))
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -205,7 +205,7 @@ class QueueTest(SupyTestCase):
|
||||
self.assertEqual(len(q), 1)
|
||||
q.reset()
|
||||
self.assertEqual(len(q), 0)
|
||||
|
||||
|
||||
def testGetitem(self):
|
||||
q = queue()
|
||||
n = 10
|
||||
@ -370,7 +370,7 @@ class SmallQueueTest(SupyTestCase):
|
||||
self.assertEqual(len(q), 1)
|
||||
q.reset()
|
||||
self.assertEqual(len(q), 0)
|
||||
|
||||
|
||||
def testGetitem(self):
|
||||
q = queue()
|
||||
n = 10
|
||||
@ -599,7 +599,7 @@ class PersistentDictionaryTestCase(SupyTestCase):
|
||||
d2 = PersistentDictionary('test.dict')
|
||||
self.failUnless(1 in d2)
|
||||
self.assertEqual(d2[1], 2)
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user