mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-06 17:44:09 +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))
|
self.setValue(long(s))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise registry.InvalidRegistryValue, 'Value must be an integer.'
|
raise registry.InvalidRegistryValue, 'Value must be an integer.'
|
||||||
|
|
||||||
conf.registerPlugin('Random')
|
conf.registerPlugin('Random')
|
||||||
conf.registerGlobalValue(conf.supybot.plugins.Random, 'seed', Seed(0, """
|
conf.registerGlobalValue(conf.supybot.plugins.Random, 'seed', Seed(0, """
|
||||||
Sets the seed of the random number generator. The seen must be a valid
|
Sets the seed of the random number generator. The seen must be a valid
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
Summary:
|
Summary:
|
||||||
|
|
||||||
import babelizer
|
import babelizer
|
||||||
|
|
||||||
print ' '.join(babelizer.available_languages)
|
print ' '.join(babelizer.available_languages)
|
||||||
|
|
||||||
print babelizer.translate( 'How much is that doggie in the window?',
|
print babelizer.translate( 'How much is that doggie in the window?',
|
||||||
@ -17,7 +17,7 @@ Summary:
|
|||||||
def babel_callback(phrase):
|
def babel_callback(phrase):
|
||||||
print phrase
|
print phrase
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
babelizer.babelize( 'I love a reigning knight.',
|
babelizer.babelize( 'I love a reigning knight.',
|
||||||
'English', 'German',
|
'English', 'German',
|
||||||
callback = babel_callback )
|
callback = babel_callback )
|
||||||
@ -108,7 +108,7 @@ def translate(phrase, from_lang, to_lang):
|
|||||||
to_code = __languages[to_lang.lower()]
|
to_code = __languages[to_lang.lower()]
|
||||||
except KeyError, lang:
|
except KeyError, lang:
|
||||||
raise LanguageNotAvailableError(lang)
|
raise LanguageNotAvailableError(lang)
|
||||||
|
|
||||||
params = urllib.urlencode( { 'BabelFishFrontPage' : 'yes',
|
params = urllib.urlencode( { 'BabelFishFrontPage' : 'yes',
|
||||||
'doit' : 'done',
|
'doit' : 'done',
|
||||||
'tt' : 'urltext',
|
'tt' : 'urltext',
|
||||||
@ -163,7 +163,7 @@ if __name__ == '__main__':
|
|||||||
print x
|
print x
|
||||||
sys.stdout.flush();
|
sys.stdout.flush();
|
||||||
|
|
||||||
|
|
||||||
babelize("I won't take that sort of treatment from you, or from your doggie!",
|
babelize("I won't take that sort of treatment from you, or from your doggie!",
|
||||||
'english', 'french', callback = printer)
|
'english', 'french', callback = printer)
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
#****************************************************************************
|
#****************************************************************************
|
||||||
# This file has been modified from its original version. It has been
|
# This file has been modified from its original version. It has been
|
||||||
# formatted to fit your irc bot.
|
# formatted to fit your irc bot.
|
||||||
#
|
#
|
||||||
# The original version is a nifty PyQt application written by Douglas Bell,
|
# The original version is a nifty PyQt application written by Douglas Bell,
|
||||||
# available at http://www.bellz.org/convertall/.
|
# 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.
|
# 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.
|
# followed by either equations or equivalency lists for the definition.
|
||||||
# For equations, two are given, separated by a ';'. Both are functions of
|
# 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
|
# "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
|
# one in reverse. Any valid Python expression returning a float (including
|
||||||
# the functions in the math module) should work. The equivalency list is a
|
# the functions in the math module) should work. The equivalency list is a
|
||||||
# python list of tuples giving points for linear interpolation.
|
# python list of tuples giving points for linear interpolation.
|
||||||
#
|
#
|
||||||
# All units must reduce to primitive units, which are indicated by an '!'
|
# 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)
|
typeUnits[unit.typeName].append(unit.name)
|
||||||
self.sortedKeys = self.keys()
|
self.sortedKeys = self.keys()
|
||||||
self.sortedKeys.sort()
|
self.sortedKeys.sort()
|
||||||
|
|
||||||
if len(self.sortedKeys) < len(units):
|
if len(self.sortedKeys) < len(units):
|
||||||
raise UnitDataError, 'Duplicate unit names found'
|
raise UnitDataError, 'Duplicate unit names found'
|
||||||
|
|
||||||
@ -1137,7 +1137,7 @@ class Unit:
|
|||||||
############################################################################
|
############################################################################
|
||||||
# Wrapper functionality
|
# Wrapper functionality
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
|
|
||||||
# Parse the data file, and set everything up for conversion
|
# Parse the data file, and set everything up for conversion
|
||||||
@ -1154,7 +1154,7 @@ toUnit = UnitGroup(data, option)
|
|||||||
def convert(num, unit1, unit2):
|
def convert(num, unit1, unit2):
|
||||||
""" Convert from one unit to another
|
""" 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.
|
various errors.
|
||||||
"""
|
"""
|
||||||
fromUnit.update(unit1)
|
fromUnit.update(unit1)
|
||||||
@ -1162,17 +1162,17 @@ def convert(num, unit1, unit2):
|
|||||||
|
|
||||||
fromUnit.reduceGroup()
|
fromUnit.reduceGroup()
|
||||||
toUnit.reduceGroup()
|
toUnit.reduceGroup()
|
||||||
|
|
||||||
# Match up unit categories
|
# Match up unit categories
|
||||||
if not fromUnit.categoryMatch(toUnit):
|
if not fromUnit.categoryMatch(toUnit):
|
||||||
raise UnitDataError('unit categories did not match')
|
raise UnitDataError('unit categories did not match')
|
||||||
|
|
||||||
return fromUnit.convert(num, toUnit)
|
return fromUnit.convert(num, toUnit)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def units(type):
|
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.
|
a list of types if the argument is not valid.
|
||||||
"""
|
"""
|
||||||
if type in types:
|
if type in types:
|
||||||
|
@ -105,7 +105,7 @@ class Connection:
|
|||||||
capstr, msgid = re.search('<(.*)> (<.*>)$', string).groups()
|
capstr, msgid = re.search('<(.*)> (<.*>)$', string).groups()
|
||||||
self.capabilities = capstr.split('.')
|
self.capabilities = capstr.split('.')
|
||||||
self.messageid = msgid
|
self.messageid = msgid
|
||||||
|
|
||||||
def getcapabilities(self):
|
def getcapabilities(self):
|
||||||
"""Returns a list of the capabilities advertised by the server."""
|
"""Returns a list of the capabilities advertised by the server."""
|
||||||
return self.capabilities
|
return self.capabilities
|
||||||
@ -120,7 +120,7 @@ class Connection:
|
|||||||
network traffic!"""
|
network traffic!"""
|
||||||
if hasattr(self, 'dbdescs'):
|
if hasattr(self, 'dbdescs'):
|
||||||
return self.dbdescs
|
return self.dbdescs
|
||||||
|
|
||||||
self.sendcommand("SHOW DB")
|
self.sendcommand("SHOW DB")
|
||||||
self.dbdescs = self.get100dict()
|
self.dbdescs = self.get100dict()
|
||||||
return self.dbdescs
|
return self.dbdescs
|
||||||
@ -176,7 +176,7 @@ class Connection:
|
|||||||
if database != '*' and database != '!' and \
|
if database != '*' and database != '!' and \
|
||||||
not database in self.getdbdescs():
|
not database in self.getdbdescs():
|
||||||
raise Exception, "Invalid database '%s' specified" % database
|
raise Exception, "Invalid database '%s' specified" % database
|
||||||
|
|
||||||
self.sendcommand("DEFINE " + enquote(database) + " " + enquote(word))
|
self.sendcommand("DEFINE " + enquote(database) + " " + enquote(word))
|
||||||
code = self.getresultcode()[0]
|
code = self.getresultcode()[0]
|
||||||
|
|
||||||
@ -243,11 +243,11 @@ class Database:
|
|||||||
a database name."""
|
a database name."""
|
||||||
self.conn = dictconn
|
self.conn = dictconn
|
||||||
self.name = dbname
|
self.name = dbname
|
||||||
|
|
||||||
def getname(self):
|
def getname(self):
|
||||||
"""Returns the short name for this database."""
|
"""Returns the short name for this database."""
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def getdescription(self):
|
def getdescription(self):
|
||||||
if hasattr(self, 'description'):
|
if hasattr(self, 'description'):
|
||||||
return self.description
|
return self.description
|
||||||
@ -258,7 +258,7 @@ class Database:
|
|||||||
else:
|
else:
|
||||||
self.description = self.conn.getdbdescs()[self.getname()]
|
self.description = self.conn.getdbdescs()[self.getname()]
|
||||||
return self.description
|
return self.description
|
||||||
|
|
||||||
def getinfo(self):
|
def getinfo(self):
|
||||||
"""Returns a string of info describing this database."""
|
"""Returns a string of info describing this database."""
|
||||||
if hasattr(self, 'info'):
|
if hasattr(self, 'info'):
|
||||||
|
@ -12,7 +12,7 @@ RSS 0.9x/common elements:
|
|||||||
Additional RSS 1.0/2.0 elements:
|
Additional RSS 1.0/2.0 elements:
|
||||||
- dc:rights, dc:language, dc:creator, dc:date, dc:subject,
|
- dc:rights, dc:language, dc:creator, dc:date, dc:subject,
|
||||||
content:encoded, admin:generatorAgent, admin:errorReportsTo,
|
content:encoded, admin:generatorAgent, admin:errorReportsTo,
|
||||||
|
|
||||||
Addition Pie/Atom/Echo elements:
|
Addition Pie/Atom/Echo elements:
|
||||||
- subtitle, created, issued, modified, summary, id, content
|
- subtitle, created, issued, modified, summary, id, content
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ class FeedParser(sgmllib.SGMLParser):
|
|||||||
prefix = self.namespacemap.get(prefix, prefix)
|
prefix = self.namespacemap.get(prefix, prefix)
|
||||||
name = prefix + ':' + suffix
|
name = prefix + ':' + suffix
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def _getAttribute(self, attrs, name):
|
def _getAttribute(self, attrs, name):
|
||||||
value = [v for k, v in attrs if self._mapToStandardPrefix(k) == name]
|
value = [v for k, v in attrs if self._mapToStandardPrefix(k) == name]
|
||||||
if value:
|
if value:
|
||||||
@ -175,7 +175,7 @@ class FeedParser(sgmllib.SGMLParser):
|
|||||||
else:
|
else:
|
||||||
value = None
|
value = None
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def start_channel(self, attrs):
|
def start_channel(self, attrs):
|
||||||
self.push('channel', 0)
|
self.push('channel', 0)
|
||||||
self.inchannel = 1
|
self.inchannel = 1
|
||||||
@ -183,16 +183,16 @@ class FeedParser(sgmllib.SGMLParser):
|
|||||||
def end_channel(self):
|
def end_channel(self):
|
||||||
self.pop('channel')
|
self.pop('channel')
|
||||||
self.inchannel = 0
|
self.inchannel = 0
|
||||||
|
|
||||||
def start_image(self, attrs):
|
def start_image(self, attrs):
|
||||||
self.inimage = 1
|
self.inimage = 1
|
||||||
|
|
||||||
def end_image(self):
|
def end_image(self):
|
||||||
self.inimage = 0
|
self.inimage = 0
|
||||||
|
|
||||||
def start_textinput(self, attrs):
|
def start_textinput(self, attrs):
|
||||||
self.intextinput = 1
|
self.intextinput = 1
|
||||||
|
|
||||||
def end_textinput(self):
|
def end_textinput(self):
|
||||||
self.intextinput = 0
|
self.intextinput = 0
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ class FeedParser(sgmllib.SGMLParser):
|
|||||||
def end_entry(self):
|
def end_entry(self):
|
||||||
self.pop('item')
|
self.pop('item')
|
||||||
self.initem = 0
|
self.initem = 0
|
||||||
|
|
||||||
def start_subtitle(self, attrs):
|
def start_subtitle(self, attrs):
|
||||||
self.push('subtitle', 1)
|
self.push('subtitle', 1)
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ class FeedParser(sgmllib.SGMLParser):
|
|||||||
|
|
||||||
def end_summary(self):
|
def end_summary(self):
|
||||||
self.pop('summary')
|
self.pop('summary')
|
||||||
|
|
||||||
def start_modified(self, attrs):
|
def start_modified(self, attrs):
|
||||||
self.push('modified', 1)
|
self.push('modified', 1)
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ class FeedParser(sgmllib.SGMLParser):
|
|||||||
end_div = end_content
|
end_div = end_content
|
||||||
end_xhtml_body = end_content
|
end_xhtml_body = end_content
|
||||||
end_xhtml_div = end_content
|
end_xhtml_div = end_content
|
||||||
|
|
||||||
def unknown_starttag(self, tag, attrs):
|
def unknown_starttag(self, tag, attrs):
|
||||||
if self.incontent and self.contentmode == 'xml':
|
if self.incontent and self.contentmode == 'xml':
|
||||||
self.handle_data("<%s%s>" % (tag, "".join([' %s="%s"' % t for t in attrs])))
|
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_300 = http_error_302
|
||||||
http_error_307 = http_error_302
|
http_error_307 = http_error_302
|
||||||
|
|
||||||
def open_resource(source, etag=None, modified=None, agent=None, referrer=None):
|
def open_resource(source, etag=None, modified=None, agent=None, referrer=None):
|
||||||
"""
|
"""
|
||||||
URI, filename, or string --> stream
|
URI, filename, or string --> stream
|
||||||
@ -538,7 +538,7 @@ def open_resource(source, etag=None, modified=None, agent=None, referrer=None):
|
|||||||
|
|
||||||
if not agent:
|
if not agent:
|
||||||
agent = USER_AGENT
|
agent = USER_AGENT
|
||||||
|
|
||||||
# try to open with urllib2 (to use optional headers)
|
# try to open with urllib2 (to use optional headers)
|
||||||
request = urllib2.Request(source)
|
request = urllib2.Request(source)
|
||||||
if etag:
|
if etag:
|
||||||
@ -556,7 +556,7 @@ def open_resource(source, etag=None, modified=None, agent=None, referrer=None):
|
|||||||
except:
|
except:
|
||||||
# source is not a valid URL, but it might be a valid filename
|
# source is not a valid URL, but it might be a valid filename
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# try to open with native open function (if source is a filename)
|
# try to open with native open function (if source is a filename)
|
||||||
try:
|
try:
|
||||||
return open(source)
|
return open(source)
|
||||||
@ -568,7 +568,7 @@ def open_resource(source, etag=None, modified=None, agent=None, referrer=None):
|
|||||||
|
|
||||||
def get_etag(resource):
|
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().
|
open_resource().
|
||||||
|
|
||||||
If the resource was not returned from an HTTP server or the server did
|
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
|
# prompting for the information. Crap. This isn't great
|
||||||
# but it's better than the current 'repeat until recursion
|
# but it's better than the current 'repeat until recursion
|
||||||
# depth exceeded' approach <wink>
|
# 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)
|
headers, None)
|
||||||
else:
|
else:
|
||||||
self.retried += 1
|
self.retried += 1
|
||||||
@ -780,7 +780,7 @@ class AbstractDigestAuthHandler:
|
|||||||
else:
|
else:
|
||||||
# XXX handle auth-int.
|
# XXX handle auth-int.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# XXX should the partial digests be encoded too?
|
# XXX should the partial digests be encoded too?
|
||||||
|
|
||||||
base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \
|
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):
|
def http_error_401(self, req, fp, code, msg, headers):
|
||||||
host = urlparse.urlparse(req.get_full_url())[1]
|
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)
|
host, req, headers)
|
||||||
self.reset_retry_count()
|
self.reset_retry_count()
|
||||||
return retry
|
return retry
|
||||||
@ -834,7 +834,7 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
|
|||||||
|
|
||||||
def http_error_407(self, req, fp, code, msg, headers):
|
def http_error_407(self, req, fp, code, msg, headers):
|
||||||
host = req.get_host()
|
host = req.get_host()
|
||||||
retry = self.http_error_auth_reqed('proxy-authenticate',
|
retry = self.http_error_auth_reqed('proxy-authenticate',
|
||||||
host, req, headers)
|
host, req, headers)
|
||||||
self.reset_retry_count()
|
self.reset_retry_count()
|
||||||
return retry
|
return retry
|
||||||
|
@ -186,7 +186,7 @@ class Alias(callbacks.Privmsg):
|
|||||||
del self.aliases[alias]
|
del self.aliases[alias]
|
||||||
del self.__class__.__call__
|
del self.__class__.__call__
|
||||||
callbacks.Privmsg.__call__(self, irc, msg)
|
callbacks.Privmsg.__call__(self, irc, msg)
|
||||||
|
|
||||||
def lock(self, irc, msg, args):
|
def lock(self, irc, msg, args):
|
||||||
"""<alias>
|
"""<alias>
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class LicenseKey(registry.String):
|
|||||||
registry.String.set(self, s)
|
registry.String.set(self, s)
|
||||||
if self.value:
|
if self.value:
|
||||||
amazon.setLicense(self.value)
|
amazon.setLicense(self.value)
|
||||||
|
|
||||||
conf.registerPlugin('Amazon')
|
conf.registerPlugin('Amazon')
|
||||||
conf.registerChannelValue(conf.supybot.plugins.Amazon, 'bold',
|
conf.registerChannelValue(conf.supybot.plugins.Amazon, 'bold',
|
||||||
registry.Boolean(True, """Determines whether the results are bolded."""))
|
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',
|
conf.registerGlobalValue(conf.supybot.plugins.Anonymous, 'requireRegistration',
|
||||||
registry.Boolean(True, """Determines whether the bot should require people
|
registry.Boolean(True, """Determines whether the bot should require people
|
||||||
trying to use this plugin to be registered."""))
|
trying to use this plugin to be registered."""))
|
||||||
|
|
||||||
|
|
||||||
class Anonymous(callbacks.Privmsg):
|
class Anonymous(callbacks.Privmsg):
|
||||||
private = True
|
private = True
|
||||||
@ -95,7 +95,7 @@ class Anonymous(callbacks.Privmsg):
|
|||||||
'disallow the use of this plugin.')
|
'disallow the use of this plugin.')
|
||||||
return
|
return
|
||||||
irc.queueMsg(ircmsgs.privmsg(channel, text))
|
irc.queueMsg(ircmsgs.privmsg(channel, text))
|
||||||
|
|
||||||
|
|
||||||
Class = Anonymous
|
Class = Anonymous
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class SpaceSeparatedListOfLanguages(registry.SeparatedListOf):
|
|||||||
def splitter(self, s):
|
def splitter(self, s):
|
||||||
return s.split()
|
return s.split()
|
||||||
joiner = ' '.join
|
joiner = ' '.join
|
||||||
|
|
||||||
conf.registerPlugin('Babelfish')
|
conf.registerPlugin('Babelfish')
|
||||||
conf.registerChannelValue(conf.supybot.plugins.Babelfish, 'languages',
|
conf.registerChannelValue(conf.supybot.plugins.Babelfish, 'languages',
|
||||||
SpaceSeparatedListOfLanguages(babelfish.available_languages, """Determines
|
SpaceSeparatedListOfLanguages(babelfish.available_languages, """Determines
|
||||||
@ -87,7 +87,7 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
if toLang not in languages:
|
if toLang not in languages:
|
||||||
toLang = None
|
toLang = None
|
||||||
return (fromLang, toLang)
|
return (fromLang, toLang)
|
||||||
|
|
||||||
def languages(self, irc, msg, args):
|
def languages(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
self.db.close()
|
self.db.close()
|
||||||
|
|
||||||
def add(self, irc, msg, args):
|
def add(self, irc, msg, args):
|
||||||
"""<name> <url> <description>
|
"""<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
|
"""Given a URL and query list for a CSV bug list, it'll return
|
||||||
all the bugs in a dict
|
all the bugs in a dict
|
||||||
"""
|
"""
|
||||||
bugs = {}
|
bugs = {}
|
||||||
try:
|
try:
|
||||||
url = '%s/buglist.cgi?%s' % (url, '&'.join(query))
|
url = '%s/buglist.cgi?%s' % (url, '&'.join(query))
|
||||||
u = webutils.getUrlFd(url)
|
u = webutils.getUrlFd(url)
|
||||||
@ -256,11 +256,11 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
i += 1
|
i += 1
|
||||||
u.close()
|
u.close()
|
||||||
return bugs
|
return bugs
|
||||||
|
|
||||||
def search(self, irc, msg, args):
|
def search(self, irc, msg, args):
|
||||||
"""[--keywords=<keyword>] <bugzilla name> <search string in desc>
|
"""[--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
|
<keywords>. <keywords> can be statuses, severities, priorities, or
|
||||||
resolutions, seperated by commas"""
|
resolutions, seperated by commas"""
|
||||||
keywords = None
|
keywords = None
|
||||||
@ -270,7 +270,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
keywords = arguments.split(',')
|
keywords = arguments.split(',')
|
||||||
(name,searchstr)= privmsgs.getArgs(rest, required=2)
|
(name,searchstr)= privmsgs.getArgs(rest, required=2)
|
||||||
if not keywords:
|
if not keywords:
|
||||||
keywords = ['UNCONFIRMED', 'NEW', 'ASSIGNED', 'REOPENED']
|
keywords = ['UNCONFIRMED', 'NEW', 'ASSIGNED', 'REOPENED']
|
||||||
query = self.keywords2query(keywords)
|
query = self.keywords2query(keywords)
|
||||||
query.append('short_desc_type=allwordssubstr')
|
query.append('short_desc_type=allwordssubstr')
|
||||||
query.append('short_desc=%s' % urllib.quote(searchstr))
|
query.append('short_desc=%s' % urllib.quote(searchstr))
|
||||||
@ -292,7 +292,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
(utils.nItems('bug', len(bugs)), searchstr,
|
(utils.nItems('bug', len(bugs)), searchstr,
|
||||||
' AND '.join(keywords), utils.commaAndify(map(str, bugids)))
|
' AND '.join(keywords), utils.commaAndify(map(str, bugids)))
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
|
|
||||||
def bug(self, irc, msg, args):
|
def bug(self, irc, msg, args):
|
||||||
"""<abbreviation> <number>
|
"""<abbreviation> <number>
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class ValidChannelOrNothing(conf.ValidChannel):
|
|||||||
conf.ValidChannel.setValue(self, v)
|
conf.ValidChannel.setValue(self, v)
|
||||||
except registry.InvalidRegistryValue:
|
except registry.InvalidRegistryValue:
|
||||||
registry.Value.setValue(self, '')
|
registry.Value.setValue(self, '')
|
||||||
|
|
||||||
conf.registerPlugin('ChannelRelay')
|
conf.registerPlugin('ChannelRelay')
|
||||||
conf.registerGlobalValue(conf.supybot.plugins.ChannelRelay, 'source',
|
conf.registerGlobalValue(conf.supybot.plugins.ChannelRelay, 'source',
|
||||||
ValidChannelOrNothing('', """Determines the channel that the bot will look
|
ValidChannelOrNothing('', """Determines the channel that the bot will look
|
||||||
@ -114,7 +114,7 @@ class ChannelRelay(callbacks.Privmsg):
|
|||||||
s = msg.args[1]
|
s = msg.args[1]
|
||||||
s = self.registryValue('prefix') + s
|
s = self.registryValue('prefix') + s
|
||||||
irc.queueMsg(ircmsgs.privmsg(target, s))
|
irc.queueMsg(ircmsgs.privmsg(target, s))
|
||||||
|
|
||||||
def do376(self, irc, msg):
|
def do376(self, irc, msg):
|
||||||
source = self.registryValue('source')
|
source = self.registryValue('source')
|
||||||
target = self.registryValue('target')
|
target = self.registryValue('target')
|
||||||
|
@ -161,7 +161,7 @@ class UserStat(ChannelStat):
|
|||||||
class StatsDB(plugins.ChannelUserDB):
|
class StatsDB(plugins.ChannelUserDB):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
plugins.ChannelUserDB.__init__(self, *args, **kwargs)
|
plugins.ChannelUserDB.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
def serialize(self, v):
|
def serialize(self, v):
|
||||||
return v.values()
|
return v.values()
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ class StatsDB(plugins.ChannelUserDB):
|
|||||||
|
|
||||||
def getChannelStats(self, channel):
|
def getChannelStats(self, channel):
|
||||||
return self[channel, 'channelStats']
|
return self[channel, 'channelStats']
|
||||||
|
|
||||||
def getUserStats(self, channel, id):
|
def getUserStats(self, channel, id):
|
||||||
return self[channel, id]
|
return self[channel, id]
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ class ChannelStats(callbacks.Privmsg):
|
|||||||
self.lastmsg = msg
|
self.lastmsg = msg
|
||||||
self.db.addMsg(msg)
|
self.db.addMsg(msg)
|
||||||
super(ChannelStats, self).__call__(irc, msg)
|
super(ChannelStats, self).__call__(irc, msg)
|
||||||
|
|
||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
if msg.command == 'PRIVMSG':
|
if msg.command == 'PRIVMSG':
|
||||||
if ircutils.isChannel(msg.args[0]):
|
if ircutils.isChannel(msg.args[0]):
|
||||||
@ -344,7 +344,7 @@ class ChannelStats(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('I\'ve never been on %s.' % channel)
|
irc.error('I\'ve never been on %s.' % channel)
|
||||||
|
|
||||||
|
|
||||||
Class = ChannelStats
|
Class = ChannelStats
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# 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)
|
_incomingRe = re.compile(r'<a href="(.*?\.deb)">', re.I)
|
||||||
def incoming(self, irc, msg, args):
|
def incoming(self, irc, msg, args):
|
||||||
"""[--{regexp,arch}=<value>] <glob>
|
"""[--{regexp,arch}=<value>] <glob>
|
||||||
|
|
||||||
Checks debian incoming for a matching package name. The arch
|
Checks debian incoming for a matching package name. The arch
|
||||||
parameter defaults to i386; --regexp returns only those package names
|
parameter defaults to i386; --regexp returns only those package names
|
||||||
that match a given regexp, and normal matches use standard *nix
|
that match a given regexp, and normal matches use standard *nix
|
||||||
@ -322,7 +322,7 @@ class Debian(callbacks.Privmsg,
|
|||||||
if m:
|
if m:
|
||||||
m = m.group(1)
|
m = m.group(1)
|
||||||
if fnmatch.fnmatch(m, glob):
|
if fnmatch.fnmatch(m, glob):
|
||||||
packages.append(m)
|
packages.append(m)
|
||||||
fd.close()
|
fd.close()
|
||||||
if packages:
|
if packages:
|
||||||
irc.reply(utils.commaAndify(packages))
|
irc.reply(utils.commaAndify(packages))
|
||||||
|
@ -135,7 +135,7 @@ class Dict(callbacks.Privmsg):
|
|||||||
L.append('%s: %s' % (db, s))
|
L.append('%s: %s' % (db, s))
|
||||||
utils.sortBy(len, L)
|
utils.sortBy(len, L)
|
||||||
if dictionary == '*' and len(dbs) > 1:
|
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:
|
else:
|
||||||
s = '; '.join(L)
|
s = '; '.join(L)
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
|
@ -66,7 +66,7 @@ class Dunno(callbacks.Privmsg):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
self.makeDb(dbfilename)
|
self.makeDb(dbfilename)
|
||||||
|
|
||||||
def makeDb(self, filename):
|
def makeDb(self, filename):
|
||||||
"""create Dunno database and tables"""
|
"""create Dunno database and tables"""
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
@ -81,7 +81,7 @@ class Dunno(callbacks.Privmsg):
|
|||||||
dunno TEXT
|
dunno TEXT
|
||||||
)""")
|
)""")
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
|
|
||||||
def invalidCommand(self, irc, msg, tokens):
|
def invalidCommand(self, irc, msg, tokens):
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT dunno
|
cursor.execute("""SELECT dunno
|
||||||
@ -220,7 +220,7 @@ class Dunno(callbacks.Privmsg):
|
|||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT COUNT(*) FROM dunnos""")
|
cursor.execute("""SELECT COUNT(*) FROM dunnos""")
|
||||||
irc.reply(cursor.fetchone()[0])
|
irc.reply(cursor.fetchone()[0])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class = Dunno
|
Class = Dunno
|
||||||
|
@ -66,7 +66,7 @@ class ValidNickOrEmptyString(registry.String):
|
|||||||
raise registry.InvalidRegistryValue, \
|
raise registry.InvalidRegistryValue, \
|
||||||
'Value must be a valid nick or the empty string.'
|
'Value must be a valid nick or the empty string.'
|
||||||
self.value = v
|
self.value = v
|
||||||
|
|
||||||
conf.registerPlugin('Enforcer')
|
conf.registerPlugin('Enforcer')
|
||||||
conf.registerChannelValue(conf.supybot.plugins.Enforcer, 'enforce',
|
conf.registerChannelValue(conf.supybot.plugins.Enforcer, 'enforce',
|
||||||
registry.Boolean(True, """Determines whether the bot will enforce
|
registry.Boolean(True, """Determines whether the bot will enforce
|
||||||
@ -112,7 +112,7 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
self.topics = ircutils.IrcDict()
|
self.topics = ircutils.IrcDict()
|
||||||
|
|
||||||
def doJoin(self, irc, msg):
|
def doJoin(self, irc, msg):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
c = ircdb.channels.getChannel(channel)
|
c = ircdb.channels.getChannel(channel)
|
||||||
@ -263,7 +263,7 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
irc.queueMsg(ircmsgs.join(channel))
|
irc.queueMsg(ircmsgs.join(channel))
|
||||||
else:
|
else:
|
||||||
self.log.warning('Not cycling %s: it\'s +i', channel)
|
self.log.warning('Not cycling %s: it\'s +i', channel)
|
||||||
|
|
||||||
def doPart(self, irc, msg):
|
def doPart(self, irc, msg):
|
||||||
if msg.prefix != irc.prefix:
|
if msg.prefix != irc.prefix:
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
|
@ -52,7 +52,7 @@ import callbacks
|
|||||||
class MyFilterProxy(object):
|
class MyFilterProxy(object):
|
||||||
def reply(self, s):
|
def reply(self, s):
|
||||||
self.s = s
|
self.s = s
|
||||||
|
|
||||||
class Filter(callbacks.Privmsg):
|
class Filter(callbacks.Privmsg):
|
||||||
"""This plugin offers several commands which transform text in some way.
|
"""This plugin offers several commands which transform text in some way.
|
||||||
It also provides the capability of using such commands to 'filter' the
|
It also provides the capability of using such commands to 'filter' the
|
||||||
@ -86,7 +86,7 @@ class Filter(callbacks.Privmsg):
|
|||||||
'supa1337', 'colorstrip', 'aol']
|
'supa1337', 'colorstrip', 'aol']
|
||||||
def outfilter(self, irc, msg, args, channel):
|
def outfilter(self, irc, msg, args, channel):
|
||||||
"""[<channel>] [<command>]
|
"""[<channel>] [<command>]
|
||||||
|
|
||||||
Sets the outFilter of this plugin to be <command>. If no command is
|
Sets the outFilter of this plugin to be <command>. If no command is
|
||||||
given, unsets the outFilter. <channel> is only necessary if the
|
given, unsets the outFilter. <channel> is only necessary if the
|
||||||
message isn't sent in the channel itself.
|
message isn't sent in the channel itself.
|
||||||
@ -104,7 +104,7 @@ class Filter(callbacks.Privmsg):
|
|||||||
self.outFilters[channel] = []
|
self.outFilters[channel] = []
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
outfilter = privmsgs.checkChannelCapability(outfilter, 'op')
|
outfilter = privmsgs.checkChannelCapability(outfilter, 'op')
|
||||||
|
|
||||||
def squish(self, irc, msg, args):
|
def squish(self, irc, msg, args):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ class Filter(callbacks.Privmsg):
|
|||||||
('eE', '3'), ('t', '+'), ('T', '7'), ('l', '1'),
|
('eE', '3'), ('t', '+'), ('T', '7'), ('l', '1'),
|
||||||
('D', '|)'), ('B', '|3'), ('I', ']['), ('Vv', '\\/'),
|
('D', '|)'), ('B', '|3'), ('I', ']['), ('Vv', '\\/'),
|
||||||
('wW', '\\/\\/'), ('d', 'c|'), ('b', '|>'),
|
('wW', '\\/\\/'), ('d', 'c|'), ('b', '|>'),
|
||||||
('c', '<'), ('h', '|n'),]
|
('c', '<'), ('h', '|n'),]
|
||||||
def supa1337(self, irc, msg, args):
|
def supa1337(self, irc, msg, args):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ class Filter(callbacks.Privmsg):
|
|||||||
text = text.replace(' their ', ' there ')
|
text = text.replace(' their ', ' there ')
|
||||||
smiley = random.choice(['<3', ':)', ':-)', ':D', ':-D'])
|
smiley = random.choice(['<3', ':)', ':-)', ':D', ':-D'])
|
||||||
text += smiley*3
|
text += smiley*3
|
||||||
|
|
||||||
def jeffk(self, irc, msg, args):
|
def jeffk(self, irc, msg, args):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ import callbacks
|
|||||||
class MyFunProxy(object):
|
class MyFunProxy(object):
|
||||||
def reply(self, msg, s):
|
def reply(self, msg, s):
|
||||||
self.s = s
|
self.s = s
|
||||||
|
|
||||||
class Fun(callbacks.Privmsg):
|
class Fun(callbacks.Privmsg):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.outFilters = ircutils.IrcDict()
|
self.outFilters = ircutils.IrcDict()
|
||||||
@ -86,7 +86,7 @@ class Fun(callbacks.Privmsg):
|
|||||||
i = int(quad)
|
i = int(quad)
|
||||||
ret += '%02x' % i
|
ret += '%02x' % i
|
||||||
irc.reply(ret.upper())
|
irc.reply(ret.upper())
|
||||||
|
|
||||||
def ord(self, irc, msg, args):
|
def ord(self, irc, msg, args):
|
||||||
"""<letter>
|
"""<letter>
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ conf.registerPlugin('FunDB')
|
|||||||
conf.registerChannelValue(conf.supybot.plugins.FunDB, 'showIds',
|
conf.registerChannelValue(conf.supybot.plugins.FunDB, 'showIds',
|
||||||
registry.Boolean(True, """Determine whether the bot will show the id of an
|
registry.Boolean(True, """Determine whether the bot will show the id of an
|
||||||
excuse/insult/praise/lart."""))
|
excuse/insult/praise/lart."""))
|
||||||
|
|
||||||
class FunDB(callbacks.Privmsg, plugins.ChannelDBHandler):
|
class FunDB(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||||
"""
|
"""
|
||||||
Contains the 'fun' commands that require a database. Currently includes
|
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)
|
return '%s (#%s)' % (s, id)
|
||||||
else:
|
else:
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def insult(self, irc, msg, args):
|
def insult(self, irc, msg, args):
|
||||||
"""[<channel>] <nick>
|
"""[<channel>] <nick>
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ class FunDB(callbacks.Privmsg, plugins.ChannelDBHandler):
|
|||||||
def excuse(self, irc, msg, args):
|
def excuse(self, irc, msg, args):
|
||||||
"""[<channel>] [<id>]
|
"""[<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
|
<id>. <channel> is only necessary if the message isn't sent in the
|
||||||
channel itself.
|
channel itself.
|
||||||
"""
|
"""
|
||||||
|
@ -155,7 +155,7 @@ class Language(registry.OnlySomeStrings):
|
|||||||
else:
|
else:
|
||||||
s = s.lower()[:-2] + s[-2:]
|
s = s.lower()[:-2] + s[-2:]
|
||||||
return s
|
return s
|
||||||
|
|
||||||
conf.registerPlugin('Google')
|
conf.registerPlugin('Google')
|
||||||
conf.registerChannelValue(conf.supybot.plugins.Google, 'groupsSnarfer',
|
conf.registerChannelValue(conf.supybot.plugins.Google, 'groupsSnarfer',
|
||||||
registry.Boolean(False, """Determines whether the groups snarfer is
|
registry.Boolean(False, """Determines whether the groups snarfer is
|
||||||
@ -222,7 +222,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
irc.reply(url)
|
irc.reply(url)
|
||||||
else:
|
else:
|
||||||
irc.reply('Google found nothing.')
|
irc.reply('Google found nothing.')
|
||||||
|
|
||||||
def google(self, irc, msg, args):
|
def google(self, irc, msg, args):
|
||||||
"""<search> [--{language,restrict}=<value>] [--{notsafe,similar}]
|
"""<search> [--{language,restrict}=<value>] [--{notsafe,similar}]
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ class Herald(callbacks.Privmsg):
|
|||||||
throttle = self.registryValue('throttleTime', channel)
|
throttle = self.registryValue('throttleTime', channel)
|
||||||
if now - self.lastHerald.get((channel, id), 0) > throttle:
|
if now - self.lastHerald.get((channel, id), 0) > throttle:
|
||||||
if (channel, id) in self.lastParts:
|
if (channel, id) in self.lastParts:
|
||||||
i = self.registryValue('throttleTimeAfterPart', channel)
|
i = self.registryValue('throttleTimeAfterPart', channel)
|
||||||
if now - self.lastParts[channel, id] < i:
|
if now - self.lastParts[channel, id] < i:
|
||||||
return
|
return
|
||||||
self.lastHerald[channel, id] = now
|
self.lastHerald[channel, id] = now
|
||||||
|
@ -152,7 +152,7 @@ class InfobotDB(object):
|
|||||||
|
|
||||||
def getConfirm(self):
|
def getConfirm(self):
|
||||||
return random.choice(self._confirms) + random.choice(self._ends)
|
return random.choice(self._confirms) + random.choice(self._ends)
|
||||||
|
|
||||||
def getChangeCount(self):
|
def getChangeCount(self):
|
||||||
return self._changes
|
return self._changes
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
msg = self.msg
|
msg = self.msg
|
||||||
self.replied = True
|
self.replied = True
|
||||||
irc.reply(plugins.standardSubstitute(irc, msg, s), prefixName=False)
|
irc.reply(plugins.standardSubstitute(irc, msg, s), prefixName=False)
|
||||||
|
|
||||||
def confirm(self, irc=None, msg=None):
|
def confirm(self, irc=None, msg=None):
|
||||||
if self.registryValue('personality'):
|
if self.registryValue('personality'):
|
||||||
self.reply(self.db.getConfirm(), irc=irc, msg=msg)
|
self.reply(self.db.getConfirm(), irc=irc, msg=msg)
|
||||||
@ -235,7 +235,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
if s.startswith(contraction):
|
if s.startswith(contraction):
|
||||||
s = replacement + s[len(contraction):]
|
s = replacement + s[len(contraction):]
|
||||||
return s
|
return s
|
||||||
|
|
||||||
_forceRe = re.compile(r'^no[,: -]+', re.I)
|
_forceRe = re.compile(r'^no[,: -]+', re.I)
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
maybeAddressed = callbacks.addressed(irc.nick, msg,
|
maybeAddressed = callbacks.addressed(irc.nick, msg,
|
||||||
@ -345,7 +345,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
'to the database since this plugin was loaded.' %
|
'to the database since this plugin was loaded.' %
|
||||||
(utils.nItems('request', self.db.getChangeCount()),
|
(utils.nItems('request', self.db.getChangeCount()),
|
||||||
utils.nItems('change', self.db.getResponseCount())))
|
utils.nItems('change', self.db.getResponseCount())))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class = Infobot
|
Class = Infobot
|
||||||
|
@ -94,8 +94,8 @@ class IrcHandler(logging.Handler):
|
|||||||
irc.sendMsg(msg)
|
irc.sendMsg(msg)
|
||||||
else:
|
else:
|
||||||
print '*** Not sending to %r' % target
|
print '*** Not sending to %r' % target
|
||||||
|
|
||||||
|
|
||||||
class IrcFormatter(log.Formatter):
|
class IrcFormatter(log.Formatter):
|
||||||
def formatException(self, (E, e, tb)):
|
def formatException(self, (E, e, tb)):
|
||||||
L = [utils.exnToString(e), '::']
|
L = [utils.exnToString(e), '::']
|
||||||
@ -225,7 +225,7 @@ class LogToIrc(callbacks.Privmsg):
|
|||||||
if ircutils.isChannel(target):
|
if ircutils.isChannel(target):
|
||||||
irc.queueMsg(ircmsgs.join(target))
|
irc.queueMsg(ircmsgs.join(target))
|
||||||
do377 = do422 = do376
|
do377 = do422 = do376
|
||||||
|
|
||||||
|
|
||||||
Class = LogToIrc
|
Class = LogToIrc
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ def configure(advanced):
|
|||||||
continue
|
continue
|
||||||
command = something('What would you like the command to be?')
|
command = something('What would you like the command to be?')
|
||||||
conf.registerGlobalValue(lookups,command, registry.String(filename,''))
|
conf.registerGlobalValue(lookups,command, registry.String(filename,''))
|
||||||
|
|
||||||
|
|
||||||
conf.registerPlugin('Lookup')
|
conf.registerPlugin('Lookup')
|
||||||
conf.registerGroup(conf.supybot.plugins.Lookup, 'lookups')
|
conf.registerGroup(conf.supybot.plugins.Lookup, 'lookups')
|
||||||
|
@ -50,7 +50,7 @@ import utils
|
|||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
import convertcore
|
import convertcore
|
||||||
|
|
||||||
|
|
||||||
class Math(callbacks.Privmsg):
|
class Math(callbacks.Privmsg):
|
||||||
@ -109,7 +109,7 @@ class Math(callbacks.Privmsg):
|
|||||||
return '-%s' % valStr
|
return '-%s' % valStr
|
||||||
else:
|
else:
|
||||||
return valStr
|
return valStr
|
||||||
|
|
||||||
def _convertBaseToBase(self, number, toBase, fromBase):
|
def _convertBaseToBase(self, number, toBase, fromBase):
|
||||||
"""
|
"""
|
||||||
Convert a number from any base, 2 through 36, to any other
|
Convert a number from any base, 2 through 36, to any other
|
||||||
@ -119,7 +119,7 @@ class Math(callbacks.Privmsg):
|
|||||||
if toBase == 10:
|
if toBase == 10:
|
||||||
return str(number)
|
return str(number)
|
||||||
return self._convertDecimalToBase(number, toBase)
|
return self._convertDecimalToBase(number, toBase)
|
||||||
|
|
||||||
_mathEnv = {'__builtins__': types.ModuleType('__builtins__'), 'i': 1j}
|
_mathEnv = {'__builtins__': types.ModuleType('__builtins__'), 'i': 1j}
|
||||||
_mathEnv.update(math.__dict__)
|
_mathEnv.update(math.__dict__)
|
||||||
_mathEnv.update(cmath.__dict__)
|
_mathEnv.update(cmath.__dict__)
|
||||||
@ -143,7 +143,7 @@ class Math(callbacks.Privmsg):
|
|||||||
return str(int(x))
|
return str(int(x))
|
||||||
else:
|
else:
|
||||||
return str(x)
|
return str(x)
|
||||||
|
|
||||||
def _complexToString(self, x):
|
def _complexToString(self, x):
|
||||||
realS = self._floatToString(x.real)
|
realS = self._floatToString(x.real)
|
||||||
imagS = self._floatToString(x.imag)
|
imagS = self._floatToString(x.imag)
|
||||||
@ -249,7 +249,7 @@ class Math(callbacks.Privmsg):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
irc.error(utils.exnToString(e))
|
irc.error(utils.exnToString(e))
|
||||||
icalc = privmsgs.checkCapability(icalc, 'trusted')
|
icalc = privmsgs.checkCapability(icalc, 'trusted')
|
||||||
|
|
||||||
_rpnEnv = {
|
_rpnEnv = {
|
||||||
'dup': lambda s: s.extend([s.pop()]*2),
|
'dup': lambda s: s.extend([s.pop()]*2),
|
||||||
'swap': lambda s: s.extend([s.pop(), s.pop()])
|
'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
|
Converts from <unit> to <other unit>. If number isn't given, it
|
||||||
defaults to 1. For unit information, see 'units' command.
|
defaults to 1. For unit information, see 'units' command.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# see if the first arg is a number of some sort
|
# see if the first arg is a number of some sort
|
||||||
if args:
|
if args:
|
||||||
try:
|
try:
|
||||||
num = float(args[0])
|
num = float(args[0])
|
||||||
args.pop(0)
|
args.pop(0)
|
||||||
@ -327,7 +327,7 @@ class Math(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
newNum = convertcore.convert(num, unit1, unit2)
|
newNum = convertcore.convert(num, unit1, unit2)
|
||||||
newNum = self._floatToString(newNum)
|
newNum = self._floatToString(newNum)
|
||||||
|
|
||||||
irc.reply('%s' % newNum)
|
irc.reply('%s' % newNum)
|
||||||
except convertcore.UnitDataError, ude:
|
except convertcore.UnitDataError, ude:
|
||||||
irc.error(str(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
|
passed as arguments. When called with a type as an argument, returns
|
||||||
the units of that type.
|
the units of that type.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
type = None
|
type = None
|
||||||
else:
|
else:
|
||||||
type = ' '.join(args)
|
type = ' '.join(args)
|
||||||
irc.reply(convertcore.units(type))
|
irc.reply(convertcore.units(type))
|
||||||
|
|
||||||
Class = Math
|
Class = Math
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -151,7 +151,7 @@ class MoobotDBHandler(plugins.DBHandler):
|
|||||||
db.commit()
|
db.commit()
|
||||||
return db
|
return db
|
||||||
|
|
||||||
|
|
||||||
class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||||
priority = 98
|
priority = 98
|
||||||
addressedRegexps = ['changeFactoid', 'augmentFactoid',
|
addressedRegexps = ['changeFactoid', 'augmentFactoid',
|
||||||
@ -197,7 +197,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
"""
|
"""
|
||||||
db = self.dbHandler.getDb()
|
db = self.dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""SELECT fact, key FROM factoids
|
cursor.execute("""SELECT fact, key FROM factoids
|
||||||
ORDER BY random() LIMIT 1""")
|
ORDER BY random() LIMIT 1""")
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error('No factoids in the database.')
|
irc.error('No factoids in the database.')
|
||||||
@ -269,7 +269,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
if cursor.rowcount != 0:
|
if cursor.rowcount != 0:
|
||||||
irc.error('Factoid "%s" already exists.' % key)
|
irc.error('Factoid "%s" already exists.' % key)
|
||||||
return
|
return
|
||||||
# Otherwise,
|
# Otherwise,
|
||||||
cursor.execute("""INSERT INTO factoids VALUES
|
cursor.execute("""INSERT INTO factoids VALUES
|
||||||
(%s, %s, %s, NULL, NULL, NULL, NULL, NULL, NULL,
|
(%s, %s, %s, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
%s, 0)""",
|
%s, 0)""",
|
||||||
@ -288,7 +288,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
key, regexp = match.groups()
|
key, regexp = match.groups()
|
||||||
db = self.dbHandler.getDb()
|
db = self.dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
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
|
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||||
WHERE key LIKE %s""", key)
|
WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
@ -305,9 +305,9 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.error('Invalid regexp: "%s"' % regexp)
|
irc.error('Invalid regexp: "%s"' % regexp)
|
||||||
return
|
return
|
||||||
new_fact = r(fact)
|
new_fact = r(fact)
|
||||||
cursor.execute("""UPDATE factoids
|
cursor.execute("""UPDATE factoids
|
||||||
SET fact = %s, modified_by = %s,
|
SET fact = %s, modified_by = %s,
|
||||||
modified_at = %s WHERE key = %s""",
|
modified_at = %s WHERE key = %s""",
|
||||||
new_fact, id, int(time.time()), key)
|
new_fact, id, int(time.time()), key)
|
||||||
db.commit()
|
db.commit()
|
||||||
@ -324,7 +324,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
key, new_text = match.groups()
|
key, new_text = match.groups()
|
||||||
db = self.dbHandler.getDb()
|
db = self.dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
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
|
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||||
WHERE key LIKE %s""", key)
|
WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
@ -360,7 +360,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
key = key.split(' ', 1)[1] # Take out everything to first space
|
key = key.split(' ', 1)[1] # Take out everything to first space
|
||||||
db = self.dbHandler.getDb()
|
db = self.dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
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
|
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||||
WHERE key LIKE %s""", key)
|
WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
@ -659,7 +659,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error('No such factoid: "%s"' % key)
|
irc.error('No such factoid: "%s"' % key)
|
||||||
return
|
return
|
||||||
(_, locked_at) = cursor.fetchone()
|
(_, locked_at) = cursor.fetchone()
|
||||||
if locked_at is not None:
|
if locked_at is not None:
|
||||||
irc.error("Factoid is locked, cannot remove.")
|
irc.error("Factoid is locked, cannot remove.")
|
||||||
return
|
return
|
||||||
@ -674,7 +674,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
"""
|
"""
|
||||||
db = self.dbHandler.getDb()
|
db = self.dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""SELECT fact, key FROM factoids
|
cursor.execute("""SELECT fact, key FROM factoids
|
||||||
ORDER BY random() LIMIT 1""")
|
ORDER BY random() LIMIT 1""")
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error('No factoids in the database.')
|
irc.error('No factoids in the database.')
|
||||||
|
@ -61,7 +61,7 @@ class Movies(callbacks.Privmsg):
|
|||||||
utils.pluralize('genre', len(movie.genres())),
|
utils.pluralize('genre', len(movie.genres())),
|
||||||
movie.rating(), movie.url)
|
movie.rating(), movie.url)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def imdb(self, irc, msg, args):
|
def imdb(self, irc, msg, args):
|
||||||
"""<movie title>
|
"""<movie title>
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class Network(callbacks.Privmsg):
|
|||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
except NameError, e:
|
except NameError, e:
|
||||||
irc.error('I couldn\'t find such a domain.')
|
irc.error('I couldn\'t find such a domain.')
|
||||||
|
|
||||||
|
|
||||||
Class = Network
|
Class = Network
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
db.commit()
|
db.commit()
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
remove = privmsgs.checkChannelCapability(remove, 'news')
|
remove = privmsgs.checkChannelCapability(remove, 'news')
|
||||||
|
|
||||||
def change(self, irc, msg, args, channel):
|
def change(self, irc, msg, args, channel):
|
||||||
"""[<channel>] <number> <regexp>
|
"""[<channel>] <number> <regexp>
|
||||||
|
|
||||||
@ -246,10 +246,10 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
return
|
return
|
||||||
subjects = ['#%s: %s' % (id, s) for (id, s) in cursor.fetchall()]
|
subjects = ['#%s: %s' % (id, s) for (id, s) in cursor.fetchall()]
|
||||||
irc.reply(utils.commaAndify(subjects))
|
irc.reply(utils.commaAndify(subjects))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class = News
|
Class = News
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/python
|
#!/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>
|
# Derived from work (c) 1998, Adam Spiers <adam.spiers@new.ox.ac.uk>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
@ -30,8 +30,8 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
###
|
###
|
||||||
# This algorithm is almost a direct from a the perl nickometer from
|
# 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
|
# 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
|
# the comments, I copy-pasted. As a matter of courtesy, the original copyright
|
||||||
# message follows:
|
# message follows:
|
||||||
#
|
#
|
||||||
@ -108,13 +108,13 @@ class Nickometer(callbacks.Privmsg):
|
|||||||
Tells you how lame said nick is.
|
Tells you how lame said nick is.
|
||||||
"""
|
"""
|
||||||
score = 0L
|
score = 0L
|
||||||
|
|
||||||
nick = privmsgs.getArgs(args)
|
nick = privmsgs.getArgs(args)
|
||||||
originalNick = nick
|
originalNick = nick
|
||||||
if not nick:
|
if not nick:
|
||||||
irc.error('Give me a nick to judge as the argument, please.')
|
irc.error('Give me a nick to judge as the argument, please.')
|
||||||
return
|
return
|
||||||
|
|
||||||
specialCost = [('69', 500),
|
specialCost = [('69', 500),
|
||||||
('dea?th', 500),
|
('dea?th', 500),
|
||||||
('dark', 400),
|
('dark', 400),
|
||||||
@ -142,9 +142,9 @@ class Nickometer(callbacks.Privmsg):
|
|||||||
tempNick = nick
|
tempNick = nick
|
||||||
if special[0][0] != '\\':
|
if special[0][0] != '\\':
|
||||||
tempNick = tempNick.translate(letterNumberTranslator)
|
tempNick = tempNick.translate(letterNumberTranslator)
|
||||||
|
|
||||||
if tempNick and re.search(special[0], tempNick, re.IGNORECASE):
|
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])
|
special[0])
|
||||||
|
|
||||||
# I don't really know about either of these next two statements,
|
# I don't really know about either of these next two statements,
|
||||||
@ -158,7 +158,7 @@ class Nickometer(callbacks.Privmsg):
|
|||||||
# Punish consecutive non-alphas
|
# Punish consecutive non-alphas
|
||||||
matches=re.findall('[^\w\d]{2,}',nick)
|
matches=re.findall('[^\w\d]{2,}',nick)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
score += self.punish(slowPow(10, len(match)),
|
score += self.punish(slowPow(10, len(match)),
|
||||||
'%s consecutive non-alphas ' % len(match))
|
'%s consecutive non-alphas ' % len(match))
|
||||||
|
|
||||||
# Remove balanced brackets ...
|
# Remove balanced brackets ...
|
||||||
@ -174,7 +174,7 @@ class Nickometer(callbacks.Privmsg):
|
|||||||
# ... and punish for unmatched brackets
|
# ... and punish for unmatched brackets
|
||||||
unmatched = re.findall('[][(){}]', nick)
|
unmatched = re.findall('[][(){}]', nick)
|
||||||
if len(unmatched) > 0:
|
if len(unmatched) > 0:
|
||||||
score += self.punish(slowPow(10, len(unmatched)),
|
score += self.punish(slowPow(10, len(unmatched)),
|
||||||
'%s unmatched parentheses' % len(unmatched))
|
'%s unmatched parentheses' % len(unmatched))
|
||||||
|
|
||||||
# Punish k3wlt0k
|
# Punish k3wlt0k
|
||||||
@ -202,7 +202,7 @@ class Nickometer(callbacks.Privmsg):
|
|||||||
|
|
||||||
# Punish uppercase to lowercase shifts and vice-versa, modulo
|
# Punish uppercase to lowercase shifts and vice-versa, modulo
|
||||||
# exceptions above
|
# exceptions above
|
||||||
|
|
||||||
# the commented line is the equivalent of the original, but i think
|
# the commented line is the equivalent of the original, but i think
|
||||||
# they intended my version, otherwise, the first caps alpha will
|
# they intended my version, otherwise, the first caps alpha will
|
||||||
# still be punished
|
# still be punished
|
||||||
@ -211,7 +211,7 @@ class Nickometer(callbacks.Privmsg):
|
|||||||
if cshifts > 1 and re.match('.*[A-Z].*', nick):
|
if cshifts > 1 and re.match('.*[A-Z].*', nick):
|
||||||
score += self.punish(slowPow(9, cshifts),
|
score += self.punish(slowPow(9, cshifts),
|
||||||
'%s case shifts' % cshifts)
|
'%s case shifts' % cshifts)
|
||||||
|
|
||||||
# Punish lame endings
|
# Punish lame endings
|
||||||
if re.match('.*[XZ][^a-zA-Z]*$', nickOriginalCase):
|
if re.match('.*[XZ][^a-zA-Z]*$', nickOriginalCase):
|
||||||
score += self.punish(50, 'the last alphanumeric character was lame')
|
score += self.punish(50, 'the last alphanumeric character was lame')
|
||||||
@ -226,7 +226,7 @@ class Nickometer(callbacks.Privmsg):
|
|||||||
caps = re.findall('[A-Z]', nick)
|
caps = re.findall('[A-Z]', nick)
|
||||||
if caps and len(caps) > 0:
|
if caps and len(caps) > 0:
|
||||||
score += self.punish(slowPow(7, len(caps)),
|
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-
|
# one trailing underscore is ok. i also added a - for parasite-
|
||||||
nick = re.sub('[-_]$','',nick)
|
nick = re.sub('[-_]$','',nick)
|
||||||
@ -235,7 +235,7 @@ class Nickometer(callbacks.Privmsg):
|
|||||||
remains = re.findall('[^a-zA-Z0-9]', nick)
|
remains = re.findall('[^a-zA-Z0-9]', nick)
|
||||||
if remains and len(remains) > 0:
|
if remains and len(remains) > 0:
|
||||||
score += self.punish(50*len(remains) + slowPow(9, len(remains)),
|
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)
|
# Use an appropriate function to map [0, +inf) to [0, 100)
|
||||||
percentage = 100 * (1 + math.tanh((score - 400.0) / 400.0)) * \
|
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
|
# if it's above 99.9%, show as many digits as is insteresting
|
||||||
score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',`percentage`)
|
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))
|
(originalNick, score_string))
|
||||||
|
|
||||||
self.log.debug('Calculated lameness score for %s as %s '
|
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):
|
def open(self, irc, msg, args):
|
||||||
"""[<channel>] <question>
|
"""[<channel>] <question>
|
||||||
|
|
||||||
Creates a new poll with the given question.
|
Creates a new poll with the given question.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
@ -144,7 +144,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
|||||||
|
|
||||||
def close(self, irc, msg, args):
|
def close(self, irc, msg, args):
|
||||||
"""[<channel>] <id>
|
"""[<channel>] <id>
|
||||||
|
|
||||||
Closes the poll with the given <id>; further votes will not be allowed.
|
Closes the poll with the given <id>; further votes will not be allowed.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
@ -166,7 +166,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
|||||||
|
|
||||||
def add(self, irc, msg, args):
|
def add(self, irc, msg, args):
|
||||||
"""[<channel>] <id> <option text>
|
"""[<channel>] <id> <option text>
|
||||||
|
|
||||||
Add an option with the given text to the poll with the given id.
|
Add an option with the given text to the poll with the given id.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
@ -213,7 +213,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
|||||||
|
|
||||||
def vote(self, irc, msg, args):
|
def vote(self, irc, msg, args):
|
||||||
"""[<channel>] <poll id> <option id>
|
"""[<channel>] <poll id> <option id>
|
||||||
|
|
||||||
Vote for the option with the given id on the poll with the given poll
|
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.
|
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):
|
def results(self, irc, msg, args):
|
||||||
"""[<channel>] <id>
|
"""[<channel>] <id>
|
||||||
|
|
||||||
Shows the results for the poll with the given id.
|
Shows the results for the poll with the given id.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
@ -291,7 +291,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
|||||||
(id, question, startedBy)
|
(id, question, startedBy)
|
||||||
cursor.execute("""SELECT count(user_id), option_id
|
cursor.execute("""SELECT count(user_id), option_id
|
||||||
FROM votes
|
FROM votes
|
||||||
WHERE poll_id=%s
|
WHERE poll_id=%s
|
||||||
GROUP BY option_id
|
GROUP BY option_id
|
||||||
UNION
|
UNION
|
||||||
SELECT 0, id AS option_id
|
SELECT 0, id AS option_id
|
||||||
@ -316,7 +316,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
|
|||||||
s = utils.commaAndify(results)
|
s = utils.commaAndify(results)
|
||||||
reply += ' - %s' % s
|
reply += ' - %s' % s
|
||||||
irc.reply(reply)
|
irc.reply(reply)
|
||||||
|
|
||||||
def list(self, irc, msg, args):
|
def list(self, irc, msg, args):
|
||||||
"""takes no arguments.
|
"""takes no arguments.
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class Python(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
newmodule = getModule(moduleName)
|
newmodule = getModule(moduleName)
|
||||||
if newmodule is None:
|
if newmodule is None:
|
||||||
irc.error('No module %s exists.' % moduleName)
|
irc.error('No module %s exists.' % moduleName)
|
||||||
else:
|
else:
|
||||||
if hasattr(newmodule, funcName):
|
if hasattr(newmodule, funcName):
|
||||||
f = getattr(newmodule, funcName)
|
f = getattr(newmodule, funcName)
|
||||||
if hasattr(f, '__doc__') and f.__doc__:
|
if hasattr(f, '__doc__') and f.__doc__:
|
||||||
@ -190,7 +190,7 @@ class Python(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
if resp:
|
if resp:
|
||||||
irc.reply('; '.join(resp), prefixName = False)
|
irc.reply('; '.join(resp), prefixName = False)
|
||||||
aspnRecipes = privmsgs.urlSnarfer(aspnRecipes)
|
aspnRecipes = privmsgs.urlSnarfer(aspnRecipes)
|
||||||
|
|
||||||
|
|
||||||
Class = Python
|
Class = Python
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class QuoteGrabs(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
db.create_function('nickeq', 2, p)
|
db.create_function('nickeq', 2, p)
|
||||||
db.commit()
|
db.commit()
|
||||||
return db
|
return db
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
if ircutils.isChannel(msg.args[0]):
|
if ircutils.isChannel(msg.args[0]):
|
||||||
(channel, payload) = msg.args
|
(channel, payload) = msg.args
|
||||||
@ -150,7 +150,7 @@ class QuoteGrabs(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
def _sendGrabMsg(self, irc, msg):
|
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))
|
irc.queueMsg(ircmsgs.action(msg.args[0], s))
|
||||||
|
|
||||||
def grab(self, irc, msg, args):
|
def grab(self, irc, msg, args):
|
||||||
@ -268,7 +268,7 @@ class QuoteGrabs(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
grabber = ircdb.users.getUser(grabber_mask).name
|
grabber = ircdb.users.getUser(grabber_mask).name
|
||||||
except:
|
except:
|
||||||
grabber = grabber_mask
|
grabber = grabber_mask
|
||||||
irc.reply('%s (Said by: %s; grabbed by %s at %s)' % \
|
irc.reply('%s (Said by: %s; grabbed by %s at %s)' % \
|
||||||
(quote, hostmask, grabber, time_str))
|
(quote, hostmask, grabber, time_str))
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ class Relay(callbacks.Privmsg):
|
|||||||
Owner.disambiguate(irc, args)
|
Owner.disambiguate(irc, args)
|
||||||
self.Proxy(otherIrc, msg, args)
|
self.Proxy(otherIrc, msg, args)
|
||||||
command = privmsgs.checkCapability(command, 'admin')
|
command = privmsgs.checkCapability(command, 'admin')
|
||||||
|
|
||||||
def say(self, irc, msg, args):
|
def say(self, irc, msg, args):
|
||||||
"""<network> [<channel>] <text>
|
"""<network> [<channel>] <text>
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ class Relay(callbacks.Privmsg):
|
|||||||
utils.sortBy(ircutils.toLower, usersS)
|
utils.sortBy(ircutils.toLower, usersS)
|
||||||
usersS = ', '.join(ifilter(None, imap(', '.join,
|
usersS = ', '.join(ifilter(None, imap(', '.join,
|
||||||
(ops,halfops,voices,usersS))))
|
(ops,halfops,voices,usersS))))
|
||||||
users.append('%s (%s): %s' %
|
users.append('%s (%s): %s' %
|
||||||
(ircutils.bold(abbreviation), numUsers, usersS))
|
(ircutils.bold(abbreviation), numUsers, usersS))
|
||||||
users.sort()
|
users.sort()
|
||||||
irc.reply('; '.join(users))
|
irc.reply('; '.join(users))
|
||||||
@ -506,7 +506,7 @@ class Relay(callbacks.Privmsg):
|
|||||||
self.relayedMsgs[msg] += 1
|
self.relayedMsgs[msg] += 1
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.relayedMsgs[msg] = 1
|
self.relayedMsgs[msg] = 1
|
||||||
|
|
||||||
def _sendToOthers(self, irc, msg):
|
def _sendToOthers(self, irc, msg):
|
||||||
assert msg.command == 'PRIVMSG' or msg.command == 'TOPIC'
|
assert msg.command == 'PRIVMSG' or msg.command == 'TOPIC'
|
||||||
for otherIrc in self.ircs.itervalues():
|
for otherIrc in self.ircs.itervalues():
|
||||||
@ -641,7 +641,7 @@ class Relay(callbacks.Privmsg):
|
|||||||
## text.startswith('mode change') or \
|
## text.startswith('mode change') or \
|
||||||
## text.startswith('nick change') or \
|
## text.startswith('nick change') or \
|
||||||
## text.startswith('topic change'))
|
## text.startswith('topic change'))
|
||||||
|
|
||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
if not self.started:
|
if not self.started:
|
||||||
return msg
|
return msg
|
||||||
|
@ -130,7 +130,7 @@ class Scheduler(callbacks.Privmsg):
|
|||||||
return
|
return
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
self.events[name] = command
|
self.events[name] = command
|
||||||
f = self._makeCommandFunction(irc, msg, command, remove=False)
|
f = self._makeCommandFunction(irc, msg, command, remove=False)
|
||||||
id = schedule.addPeriodicEvent(f, seconds, name)
|
id = schedule.addPeriodicEvent(f, seconds, name)
|
||||||
assert id == name
|
assert id == name
|
||||||
|
@ -62,10 +62,10 @@ def ircToLowerOrInt(x):
|
|||||||
return x
|
return x
|
||||||
else:
|
else:
|
||||||
return ircutils.toLower(x)
|
return ircutils.toLower(x)
|
||||||
|
|
||||||
class IrcStringAndIntDict(utils.InsensitivePreservingDict):
|
class IrcStringAndIntDict(utils.InsensitivePreservingDict):
|
||||||
key = staticmethod(ircToLowerOrInt)
|
key = staticmethod(ircToLowerOrInt)
|
||||||
|
|
||||||
class SeenDB(plugins.ChannelUserDB):
|
class SeenDB(plugins.ChannelUserDB):
|
||||||
IdDict = IrcStringAndIntDict
|
IdDict = IrcStringAndIntDict
|
||||||
def serialize(self, v):
|
def serialize(self, v):
|
||||||
@ -74,7 +74,7 @@ class SeenDB(plugins.ChannelUserDB):
|
|||||||
def deserialize(self, channel, id, L):
|
def deserialize(self, channel, id, L):
|
||||||
(seen, saying) = L
|
(seen, saying) = L
|
||||||
return (float(seen), saying)
|
return (float(seen), saying)
|
||||||
|
|
||||||
def update(self, channel, nickOrId, saying):
|
def update(self, channel, nickOrId, saying):
|
||||||
seen = time.time()
|
seen = time.time()
|
||||||
self[channel, nickOrId] = (seen, saying)
|
self[channel, nickOrId] = (seen, saying)
|
||||||
@ -84,7 +84,7 @@ class SeenDB(plugins.ChannelUserDB):
|
|||||||
return self[channel, nickOrId]
|
return self[channel, nickOrId]
|
||||||
|
|
||||||
filename = os.path.join(conf.supybot.directories.data(), 'Seen.db')
|
filename = os.path.join(conf.supybot.directories.data(), 'Seen.db')
|
||||||
|
|
||||||
class Seen(callbacks.Privmsg):
|
class Seen(callbacks.Privmsg):
|
||||||
noIgnore = True
|
noIgnore = True
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -99,7 +99,7 @@ class Seen(callbacks.Privmsg):
|
|||||||
self.log.debug('Odd, no flush in flushers: %r', world.flushers)
|
self.log.debug('Odd, no flush in flushers: %r', world.flushers)
|
||||||
self.db.close()
|
self.db.close()
|
||||||
callbacks.Privmsg.die(self)
|
callbacks.Privmsg.die(self)
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
if ircutils.isChannel(msg.args[0]):
|
if ircutils.isChannel(msg.args[0]):
|
||||||
said = ircmsgs.prettyPrint(msg)
|
said = ircmsgs.prettyPrint(msg)
|
||||||
@ -110,7 +110,7 @@ class Seen(callbacks.Privmsg):
|
|||||||
self.db.update(channel, id, said)
|
self.db.update(channel, id, said)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass # Not in the database.
|
pass # Not in the database.
|
||||||
|
|
||||||
def seen(self, irc, msg, args):
|
def seen(self, irc, msg, args):
|
||||||
"""[<channel>] [--user] [<name>]
|
"""[<channel>] [--user] [<name>]
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ class Seen(callbacks.Privmsg):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
(when, said) = self.db.seen(channel, nickOrId)
|
(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))
|
(name, utils.timeElapsed(time.time()-when), said))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.reply('I have not seen %s.' % name)
|
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
|
registry.Boolean(False, """Determines whether the bot will request to get
|
||||||
voiced by the ChanServ when it joins the channel."""))
|
voiced by the ChanServ when it joins the channel."""))
|
||||||
|
|
||||||
|
|
||||||
class Services(privmsgs.CapabilityCheckingPrivmsg):
|
class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
capability = 'admin'
|
capability = 'admin'
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -144,7 +144,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
if nick and irc.nick != nick:
|
if nick and irc.nick != nick:
|
||||||
if irc.afterConnect and not self.sentGhost:
|
if irc.afterConnect and not self.sentGhost:
|
||||||
irc.sendMsg(ircmsgs.nick(nick)) # The 433 is handled elsewhere.
|
irc.sendMsg(ircmsgs.nick(nick)) # The 433 is handled elsewhere.
|
||||||
|
|
||||||
def do001(self, irc, msg):
|
def do001(self, irc, msg):
|
||||||
# New connection, make sure sentGhost is False.
|
# New connection, make sure sentGhost is False.
|
||||||
self.sentGhost = False
|
self.sentGhost = False
|
||||||
@ -199,7 +199,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
nick = self.registryValue('nick')
|
nick = self.registryValue('nick')
|
||||||
lowered = s.lower()
|
lowered = s.lower()
|
||||||
return bool('killed' in lowered and (nick in s or 'ghost' in lowered))
|
return bool('killed' in lowered and (nick in s or 'ghost' in lowered))
|
||||||
|
|
||||||
def doNotice(self, irc, msg):
|
def doNotice(self, irc, msg):
|
||||||
if irc.afterConnect:
|
if irc.afterConnect:
|
||||||
nickserv = self.registryValue('NickServ')
|
nickserv = self.registryValue('NickServ')
|
||||||
@ -251,7 +251,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
self.log.info('Requesting voice from %s in %s',
|
self.log.info('Requesting voice from %s in %s',
|
||||||
chanserv, channel)
|
chanserv, channel)
|
||||||
irc.sendMsg(ircmsgs.privmsg(chanserv, 'voice %s' % channel))
|
irc.sendMsg(ircmsgs.privmsg(chanserv, 'voice %s' % channel))
|
||||||
|
|
||||||
def do366(self, irc, msg): # End of /NAMES list; finished joining a channel
|
def do366(self, irc, msg): # End of /NAMES list; finished joining a channel
|
||||||
if self.identified:
|
if self.identified:
|
||||||
channel = msg.args[1] # nick is msg.args[0].
|
channel = msg.args[1] # nick is msg.args[0].
|
||||||
|
@ -122,7 +122,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||||
self.__class__.sf = self.__class__.sourceforge
|
self.__class__.sf = self.__class__.sourceforge
|
||||||
|
|
||||||
def _formatResp(self, text, num=''):
|
def _formatResp(self, text, num=''):
|
||||||
"""
|
"""
|
||||||
Parses the Sourceforge query to return a list of tuples that
|
Parses the Sourceforge query to return a list of tuples that
|
||||||
@ -164,7 +164,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
conf.supybot.replies.possibleBug()
|
conf.supybot.replies.possibleBug()
|
||||||
except webutils.WebError, e:
|
except webutils.WebError, e:
|
||||||
raise callbacks.Error, str(e)
|
raise callbacks.Error, str(e)
|
||||||
|
|
||||||
_bold = lambda self, m: (ircutils.bold(m[0]),) + m[1:]
|
_bold = lambda self, m: (ircutils.bold(m[0]),) + m[1:]
|
||||||
_sfTitle = re.compile(r'Detail:(\d+) - ([^<]+)</title>', re.I)
|
_sfTitle = re.compile(r'Detail:(\d+) - ([^<]+)</title>', re.I)
|
||||||
_linkType = re.compile(r'(\w+ \w+|\w+): Tracker Detailed View', 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):
|
def do001(self, irc, msg):
|
||||||
self.connected[irc] = time.time()
|
self.connected[irc] = time.time()
|
||||||
|
|
||||||
def net(self, irc, msg, args):
|
def net(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class Status(callbacks.Privmsg):
|
|||||||
response = ('I have taken %.2f seconds of user time and %.2f seconds '
|
response = ('I have taken %.2f seconds of user time and %.2f seconds '
|
||||||
'of system time, for a total of %.2f seconds of CPU '
|
'of system time, for a total of %.2f seconds of CPU '
|
||||||
'time. %s'
|
'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,
|
(user, system, user + system, children,
|
||||||
utils.nItems('thread', world.threadsSpawned),
|
utils.nItems('thread', world.threadsSpawned),
|
||||||
activeThreads))
|
activeThreads))
|
||||||
|
@ -75,7 +75,7 @@ class TodoDB(plugins.DBHandler):
|
|||||||
db.commit()
|
db.commit()
|
||||||
return db
|
return db
|
||||||
|
|
||||||
|
|
||||||
class Todo(callbacks.Privmsg):
|
class Todo(callbacks.Privmsg):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
@ -138,7 +138,7 @@ class Todo(callbacks.Privmsg):
|
|||||||
irc.reply('That user has no todos.')
|
irc.reply('That user has no todos.')
|
||||||
return
|
return
|
||||||
L = ['#%s: %s' % (item[0], self._shrink(item[1]))
|
L = ['#%s: %s' % (item[0], self._shrink(item[1]))
|
||||||
for item in cursor.fetchall()]
|
for item in cursor.fetchall()]
|
||||||
if len(L) == 1:
|
if len(L) == 1:
|
||||||
s = 'Todo for %s: %s' % (arg, L[0])
|
s = 'Todo for %s: %s' % (arg, L[0])
|
||||||
else:
|
else:
|
||||||
@ -181,8 +181,8 @@ class Todo(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
irc.errorNotRegistered()
|
irc.errorNotRegistered()
|
||||||
return
|
return
|
||||||
(optlist, rest) = getopt.getopt(args, '', ['priority='])
|
(optlist, rest) = getopt.getopt(args, '', ['priority='])
|
||||||
priority = 0
|
priority = 0
|
||||||
for (option, arg) in optlist:
|
for (option, arg) in optlist:
|
||||||
if option == '--priority':
|
if option == '--priority':
|
||||||
try:
|
try:
|
||||||
@ -198,7 +198,7 @@ class Todo(callbacks.Privmsg):
|
|||||||
VALUES (NULL, %s, %s, %s, %s, 1)""",
|
VALUES (NULL, %s, %s, %s, %s, 1)""",
|
||||||
priority, now, id, text)
|
priority, now, id, text)
|
||||||
db.commit()
|
db.commit()
|
||||||
cursor.execute("""SELECT id FROM todo
|
cursor.execute("""SELECT id FROM todo
|
||||||
WHERE added_at=%s AND userid=%s""", now, id)
|
WHERE added_at=%s AND userid=%s""", now, id)
|
||||||
todoId = cursor.fetchone()[0]
|
todoId = cursor.fetchone()[0]
|
||||||
irc.replySuccess('(Todo #%s added)' % (todoId))
|
irc.replySuccess('(Todo #%s added)' % (todoId))
|
||||||
|
@ -62,7 +62,7 @@ class Topic(callbacks.Privmsg):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
self.lastTopics = ircutils.IrcDict()
|
self.lastTopics = ircutils.IrcDict()
|
||||||
|
|
||||||
def _splitTopic(self, topic, channel):
|
def _splitTopic(self, topic, channel):
|
||||||
separator = self.registryValue('separator', channel)
|
separator = self.registryValue('separator', channel)
|
||||||
return filter(None, topic.split(separator))
|
return filter(None, topic.split(separator))
|
||||||
@ -84,7 +84,7 @@ class Topic(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
name = msg.nick
|
name = msg.nick
|
||||||
return self.topicFormatter % (topic, name)
|
return self.topicFormatter % (topic, name)
|
||||||
|
|
||||||
def _sendTopic(self, irc, channel, topics):
|
def _sendTopic(self, irc, channel, topics):
|
||||||
topics = [s for s in topics if s and not s.isspace()]
|
topics = [s for s in topics if s and not s.isspace()]
|
||||||
self.lastTopics[channel] = topics
|
self.lastTopics[channel] = topics
|
||||||
|
@ -224,7 +224,7 @@ class URL(callbacks.PrivmsgCommandAndRegexp,
|
|||||||
s = 'Title: %s (at %s)' % (title, domain)
|
s = 'Title: %s (at %s)' % (title, domain)
|
||||||
irc.reply(s, prefixName=False)
|
irc.reply(s, prefixName=False)
|
||||||
titleSnarfer = privmsgs.urlSnarfer(titleSnarfer)
|
titleSnarfer = privmsgs.urlSnarfer(titleSnarfer)
|
||||||
|
|
||||||
def _updateTinyDb(self, url, tinyurl, channel):
|
def _updateTinyDb(self, url, tinyurl, channel):
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
|
@ -108,7 +108,7 @@ def pipeReadline(fd, timeout=2):
|
|||||||
return r[0].readline()
|
return r[0].readline()
|
||||||
else:
|
else:
|
||||||
raise TimeoutError
|
raise TimeoutError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Unix(callbacks.Privmsg):
|
class Unix(callbacks.Privmsg):
|
||||||
|
@ -62,7 +62,7 @@ class Utilities(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
text = privmsgs.getArgs(args)
|
text = privmsgs.getArgs(args)
|
||||||
irc.reply(text)
|
irc.reply(text)
|
||||||
|
|
||||||
def success(self, irc, msg, args):
|
def success(self, irc, msg, args):
|
||||||
"""[<text>]
|
"""[<text>]
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class Utilities(callbacks.Privmsg):
|
|||||||
irc.reply(args[-1])
|
irc.reply(args[-1])
|
||||||
else:
|
else:
|
||||||
raise callbacks.Error
|
raise callbacks.Error
|
||||||
|
|
||||||
def strjoin(self, irc, msg, args):
|
def strjoin(self, irc, msg, args):
|
||||||
"""<separator> <string 1> [<string> ...]
|
"""<separator> <string 1> [<string> ...]
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ class Utilities(callbacks.Privmsg):
|
|||||||
print '***', allTokens
|
print '***', allTokens
|
||||||
Owner = irc.getCallback('Owner')
|
Owner = irc.getCallback('Owner')
|
||||||
Owner.processTokens(irc, msg, allTokens)
|
Owner.processTokens(irc, msg, allTokens)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class = Utilities
|
Class = Utilities
|
||||||
|
@ -85,7 +85,7 @@ class WordStatsDB(plugins.ChannelUserDB):
|
|||||||
self.channelWords[channel].setdefault(word, 0)
|
self.channelWords[channel].setdefault(word, 0)
|
||||||
self.channelWords[channel][word] += count
|
self.channelWords[channel][word] += count
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def getWordCount(self, channel, id, word):
|
def getWordCount(self, channel, id, word):
|
||||||
return self[channel, id][word]
|
return self[channel, id][word]
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class WordStatsDB(plugins.ChannelUserDB):
|
|||||||
L = self.channelWords[channel].keys()
|
L = self.channelWords[channel].keys()
|
||||||
L.sort()
|
L.sort()
|
||||||
return L
|
return L
|
||||||
|
|
||||||
def getTotalWordCount(self, channel, word):
|
def getTotalWordCount(self, channel, word):
|
||||||
return self.channelWords[channel][word]
|
return self.channelWords[channel][word]
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ class WordStatsDB(plugins.ChannelUserDB):
|
|||||||
if ircutils.nickEqual(chan, channel):
|
if ircutils.nickEqual(chan, channel):
|
||||||
if word in d:
|
if word in d:
|
||||||
del d[word]
|
del d[word]
|
||||||
|
|
||||||
def addMsg(self, msg):
|
def addMsg(self, msg):
|
||||||
assert msg.command == 'PRIVMSG'
|
assert msg.command == 'PRIVMSG'
|
||||||
(channel, text) = msg.args
|
(channel, text) = msg.args
|
||||||
@ -168,7 +168,7 @@ class WordStatsDB(plugins.ChannelUserDB):
|
|||||||
if word not in self[channel, id]:
|
if word not in self[channel, id]:
|
||||||
self[channel, id][word] = 0
|
self[channel, id][word] = 0
|
||||||
self[channel, id][word] += 1
|
self[channel, id][word] += 1
|
||||||
|
|
||||||
|
|
||||||
filename=os.path.join(conf.supybot.directories.data(), 'WordStats.db')
|
filename=os.path.join(conf.supybot.directories.data(), 'WordStats.db')
|
||||||
class WordStats(callbacks.Privmsg):
|
class WordStats(callbacks.Privmsg):
|
||||||
@ -201,7 +201,7 @@ class WordStats(callbacks.Privmsg):
|
|||||||
self.log.debug('Queried and ignoring.')
|
self.log.debug('Queried and ignoring.')
|
||||||
finally:
|
finally:
|
||||||
self.queried = False
|
self.queried = False
|
||||||
|
|
||||||
def add(self, irc, msg, args):
|
def add(self, irc, msg, args):
|
||||||
"""[<channel>] <word>
|
"""[<channel>] <word>
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class HangmanGame:
|
|||||||
self.unused = ''
|
self.unused = ''
|
||||||
self.hidden = ''
|
self.hidden = ''
|
||||||
self.guess = ''
|
self.guess = ''
|
||||||
|
|
||||||
def getWord(self, dbHandler):
|
def getWord(self, dbHandler):
|
||||||
db = dbHandler.getDb()
|
db = dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
@ -229,7 +229,7 @@ class Words(callbacks.Privmsg):
|
|||||||
irc.reply(utils.commaAndify(words))
|
irc.reply(utils.commaAndify(words))
|
||||||
else:
|
else:
|
||||||
irc.reply('That word has no anagrams I could find.')
|
irc.reply('That word has no anagrams I could find.')
|
||||||
|
|
||||||
###
|
###
|
||||||
# HANGMAN
|
# HANGMAN
|
||||||
###
|
###
|
||||||
@ -360,11 +360,11 @@ class Words(callbacks.Privmsg):
|
|||||||
###
|
###
|
||||||
# END HANGMAN
|
# END HANGMAN
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|
||||||
Class = Words
|
Class = Words
|
||||||
|
|
||||||
### TODO: Write a script to make the database.
|
### TODO: Write a script to make the database.
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# 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',
|
self.log.warning('My flusher wasn\'t in world.flushers: %r',
|
||||||
world.flushers)
|
world.flushers)
|
||||||
self.fd.close()
|
self.fd.close()
|
||||||
|
|
||||||
def writeMsg(self, msg):
|
def writeMsg(self, msg):
|
||||||
pretty = self.registryValue('prettyPrint')
|
pretty = self.registryValue('prettyPrint')
|
||||||
includeTime = self.registryValue('includeTime')
|
includeTime = self.registryValue('includeTime')
|
||||||
|
@ -123,25 +123,25 @@ repliesStatement = [
|
|||||||
canonicalizeRe = [(re.compile(r[0], re.I), r[1]) for r in [
|
canonicalizeRe = [(re.compile(r[0], re.I), r[1]) for r in [
|
||||||
(r"(.*)", r" \1 "),
|
(r"(.*)", r" \1 "),
|
||||||
(r"\s\s+", r" "),
|
(r"\s\s+", r" "),
|
||||||
|
|
||||||
(r" si ", r" is "),
|
(r" si ", r" is "),
|
||||||
(r" teh ", r "the "),
|
(r" teh ", r "the "),
|
||||||
|
|
||||||
# where blah is -> where is blah
|
# where blah is -> where is blah
|
||||||
# XXX: Why two?
|
# XXX: Why two?
|
||||||
(r" (where|what|who) (\S+) (is|are) ", r" \1 \3 \2 "),
|
(r" (where|what|who) (\S+) (is|are) ", r" \1 \3 \2 "),
|
||||||
# XXX: Non greedy (.*) ?
|
# XXX: Non greedy (.*) ?
|
||||||
(r" (where|what|who) (.*) (is|are) ", r" \1 \3 \2 "),
|
(r" (where|what|who) (.*) (is|are) ", r" \1 \3 \2 "),
|
||||||
|
|
||||||
# XXX: Does absolutely nothing?
|
# XXX: Does absolutely nothing?
|
||||||
#(r"^\s*(.*?)\s*", r"\1"),
|
#(r"^\s*(.*?)\s*", r"\1"),
|
||||||
|
|
||||||
(r" be tellin'?g? ", r" tell "),
|
(r" be tellin'?g? ", r" tell "),
|
||||||
(r" '?bout ", r" about "),
|
(r" '?bout ", r" about "),
|
||||||
|
|
||||||
(r",? any(hoo?w?|ways?) ", r" "),
|
(r",? any(hoo?w?|ways?) ", r" "),
|
||||||
(r",?\s?(pretty )*please\?? $", r"\?"),
|
(r",?\s?(pretty )*please\?? $", r"\?"),
|
||||||
|
|
||||||
# Profanity filters; just delete it.
|
# 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" th(e|at|is) (((m(o|u)th(a|er) ?)?fuck(in'?g?)?|hell|heck|(god-?)?damn?(ed)?) ?)+ ", r" "),
|
||||||
(r" wtf ", r" where "),
|
(r" wtf ", r" where "),
|
||||||
@ -217,7 +217,7 @@ class InfobotDatabase(object):
|
|||||||
filename = 'Infobot.db'
|
filename = 'Infobot.db'
|
||||||
filename = os.path.join(conf.supybot.directories.data(), filename)
|
filename = os.path.join(conf.supybot.directories.data(), filename)
|
||||||
self._db = anydbm.open(filename, 'c')
|
self._db = anydbm.open(filename, 'c')
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
self._db.close()
|
self._db.close()
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ class InfobotDatabase(object):
|
|||||||
return
|
return
|
||||||
log.info('dup: %s !%s! %s' % (key, verb, value))
|
log.info('dup: %s !%s! %s' % (key, verb, value))
|
||||||
raise KeyError, key
|
raise KeyError, key
|
||||||
|
|
||||||
def setFactoid(self, key, verb, value):
|
def setFactoid(self, key, verb, value):
|
||||||
verb = verb.lower()
|
verb = verb.lower()
|
||||||
dbKey = key.lower()
|
dbKey = key.lower()
|
||||||
@ -277,23 +277,23 @@ class InfobotDatabase(object):
|
|||||||
newValue = '%s, or %s' % (currentValue, value)
|
newValue = '%s, or %s' % (currentValue, value)
|
||||||
self._db[dbKey] = newValue
|
self._db[dbKey] = newValue
|
||||||
log.info('add: %s +%s+ %s' % (key, verb, value))
|
log.info('add: %s +%s+ %s' % (key, verb, value))
|
||||||
|
|
||||||
def deleteFactoid(self, verb, key):
|
def deleteFactoid(self, verb, key):
|
||||||
verb = verb.lower()
|
verb = verb.lower()
|
||||||
dbKey = key.lower()
|
dbKey = key.lower()
|
||||||
dbKey = '%s %s' % (verb, dbKey)
|
dbKey = '%s %s' % (verb, dbKey)
|
||||||
del db[dbKey]
|
del db[dbKey]
|
||||||
log.info('forgot: %s' % key)
|
log.info('forgot: %s' % key)
|
||||||
|
|
||||||
def getNumberOfFactoids(self):
|
def getNumberOfFactoids(self):
|
||||||
return len(self._db)
|
return len(self._db)
|
||||||
|
|
||||||
|
|
||||||
class Infobot(callbacks.Privmsg):
|
class Infobot(callbacks.Privmsg):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
self.db = InfobotDatabase()
|
self.db = InfobotDatabase()
|
||||||
|
|
||||||
# Patterns for processing private messages.
|
# Patterns for processing private messages.
|
||||||
statementRe = re.compile(r'^(no[-:, ]+)?(.+?)\s+(is|are|was|were)'
|
statementRe = re.compile(r'^(no[-:, ]+)?(.+?)\s+(is|are|was|were)'
|
||||||
r'\s+(also\s+)?(.+)$', re.I)
|
r'\s+(also\s+)?(.+)$', re.I)
|
||||||
@ -335,7 +335,7 @@ class Infobot(callbacks.Privmsg):
|
|||||||
match = self.shortQuestionRe.search(s)
|
match = self.shortQuestionRe.search(s)
|
||||||
if match:
|
if match:
|
||||||
self.shortQuestion(proxy, match, addressed)
|
self.shortQuestion(proxy, match, addressed)
|
||||||
|
|
||||||
def statement(self, irc, match, addressed):
|
def statement(self, irc, match, addressed):
|
||||||
(correction, key, verb, addition, value) = match.groups()
|
(correction, key, verb, addition, value) = match.groups()
|
||||||
if self.db.hasFactoid(verb, key):
|
if self.db.hasFactoid(verb, key):
|
||||||
@ -383,10 +383,10 @@ class Infobot(callbacks.Privmsg):
|
|||||||
return
|
return
|
||||||
if addressed or self.registryValue('replyQuestionWhenNotAddressed'):
|
if addressed or self.registryValue('replyQuestionWhenNotAddressed'):
|
||||||
irc.reply(random.choice(repliesStatement) % factoid)
|
irc.reply(random.choice(repliesStatement) % factoid)
|
||||||
|
|
||||||
def forget(self, irc, msg, args):
|
def forget(self, irc, msg, args):
|
||||||
"""<factoid>
|
"""<factoid>
|
||||||
|
|
||||||
Make the bot forget about <factoid>."""
|
Make the bot forget about <factoid>."""
|
||||||
key = privmsgs.getArgs()
|
key = privmsgs.getArgs()
|
||||||
try:
|
try:
|
||||||
@ -401,7 +401,7 @@ class Infobot(callbacks.Privmsg):
|
|||||||
|
|
||||||
def whatis(self, irc, msg, args):
|
def whatis(self, irc, msg, args):
|
||||||
"""<factoid>
|
"""<factoid>
|
||||||
|
|
||||||
Explain what <factoid> is."""
|
Explain what <factoid> is."""
|
||||||
key = privmsgs.getArgs()
|
key = privmsgs.getArgs()
|
||||||
try:
|
try:
|
||||||
@ -416,7 +416,7 @@ class Infobot(callbacks.Privmsg):
|
|||||||
|
|
||||||
def stats(self, irc, msg, args):
|
def stats(self, irc, msg, args):
|
||||||
"""<requires no arguments>
|
"""<requires no arguments>
|
||||||
|
|
||||||
Display some statistics on the infobot database."""
|
Display some statistics on the infobot database."""
|
||||||
num = self.db.getNumberOfFactoids()
|
num = self.db.getNumberOfFactoids()
|
||||||
if self.registryValue('infobotStyleStatus'):
|
if self.registryValue('infobotStyleStatus'):
|
||||||
|
@ -72,18 +72,18 @@ class Markov(callbacks.Privmsg):
|
|||||||
filename = os.path.join(conf.supybot.directories.data(), filename)
|
filename = os.path.join(conf.supybot.directories.data(), filename)
|
||||||
self.dbCache[channel] = anydbm.open(filename, 'c')
|
self.dbCache[channel] = anydbm.open(filename, 'c')
|
||||||
return self.dbCache[channel]
|
return self.dbCache[channel]
|
||||||
|
|
||||||
def _getNumberOfPairs(self, db):
|
def _getNumberOfPairs(self, db):
|
||||||
# Minus one, because we have a key storing the first pairs.
|
# Minus one, because we have a key storing the first pairs.
|
||||||
return len(db) - 1
|
return len(db) - 1
|
||||||
|
|
||||||
def _getNumberOfFirstPairs(self, db):
|
def _getNumberOfFirstPairs(self, db):
|
||||||
try:
|
try:
|
||||||
pairs = db[''].split()
|
pairs = db[''].split()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return 0
|
return 0
|
||||||
return len(pairs)
|
return len(pairs)
|
||||||
|
|
||||||
def _getFirstPair(self, db):
|
def _getFirstPair(self, db):
|
||||||
try:
|
try:
|
||||||
pairs = db[''].split()
|
pairs = db[''].split()
|
||||||
@ -91,7 +91,7 @@ class Markov(callbacks.Privmsg):
|
|||||||
raise ValueError('No starting pairs in the database.')
|
raise ValueError('No starting pairs in the database.')
|
||||||
pair = random.choice(pairs)
|
pair = random.choice(pairs)
|
||||||
return pair.split('\x00', 1)
|
return pair.split('\x00', 1)
|
||||||
|
|
||||||
def _getFollower(self, db, first, second):
|
def _getFollower(self, db, first, second):
|
||||||
pair = '%s %s' % (first, second)
|
pair = '%s %s' % (first, second)
|
||||||
try:
|
try:
|
||||||
@ -99,7 +99,7 @@ class Markov(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return '\x00'
|
return '\x00'
|
||||||
return random.choice(followers)
|
return random.choice(followers)
|
||||||
|
|
||||||
def _addFirstPair(self, db, first, second):
|
def _addFirstPair(self, db, first, second):
|
||||||
pair = '%s\x00%s' % (first, second)
|
pair = '%s\x00%s' % (first, second)
|
||||||
try:
|
try:
|
||||||
@ -107,7 +107,7 @@ class Markov(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
startingPairs = ''
|
startingPairs = ''
|
||||||
db[''] = '%s%s ' % (startingPairs, pair)
|
db[''] = '%s%s ' % (startingPairs, pair)
|
||||||
|
|
||||||
def _addPair(self, db, first, second, follower):
|
def _addPair(self, db, first, second, follower):
|
||||||
pair = '%s %s' % (first, second)
|
pair = '%s %s' % (first, second)
|
||||||
try:
|
try:
|
||||||
|
2
setup.py
2
setup.py
@ -83,7 +83,7 @@ setup(
|
|||||||
'Operating System :: Microsoft :: Windows',
|
'Operating System :: Microsoft :: Windows',
|
||||||
'Programming Language :: Python',
|
'Programming Language :: Python',
|
||||||
],
|
],
|
||||||
|
|
||||||
# Installation data
|
# Installation data
|
||||||
packages=['supybot',
|
packages=['supybot',
|
||||||
'supybot.src',
|
'supybot.src',
|
||||||
|
14
src/Admin.py
14
src/Admin.py
@ -57,7 +57,7 @@ import privmsgs
|
|||||||
import schedule
|
import schedule
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
|
|
||||||
class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
capability = 'admin'
|
capability = 'admin'
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -81,7 +81,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
chans.append(channel)
|
chans.append(channel)
|
||||||
irc.queueMsg(ircmsgs.joins(chans, keys))
|
irc.queueMsg(ircmsgs.joins(chans, keys))
|
||||||
do422 = do377 = do376
|
do422 = do377 = do376
|
||||||
|
|
||||||
def do437(self, irc, msg):
|
def do437(self, irc, msg):
|
||||||
"""Nick/channel temporarily unavailable."""
|
"""Nick/channel temporarily unavailable."""
|
||||||
target = msg.args[0]
|
target = msg.args[0]
|
||||||
@ -119,7 +119,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
irc.error('Cannot join %s, it\'s banned me.' % channel)
|
irc.error('Cannot join %s, it\'s banned me.' % channel)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.log.debug('Got 474 without Admin.join being called.')
|
self.log.debug('Got 474 without Admin.join being called.')
|
||||||
|
|
||||||
def do475(self, irc, msg):
|
def do475(self, irc, msg):
|
||||||
try:
|
try:
|
||||||
channel = msg.args[1]
|
channel = msg.args[1]
|
||||||
@ -153,7 +153,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
self.log.info('Invited to %s by %s', channel, msg.prefix)
|
self.log.info('Invited to %s by %s', channel, msg.prefix)
|
||||||
irc.queueMsg(ircmsgs.join(channel))
|
irc.queueMsg(ircmsgs.join(channel))
|
||||||
conf.supybot.channels().add(channel)
|
conf.supybot.channels().add(channel)
|
||||||
|
|
||||||
def join(self, irc, msg, args):
|
def join(self, irc, msg, args):
|
||||||
"""<channel>[,<key>] [<channel>[,<key>] ...]
|
"""<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.')
|
'a channel I\'m in is +m and I\'m -v in it.')
|
||||||
else:
|
else:
|
||||||
self.log.debug('Got 438 without Admin.nick being called.')
|
self.log.debug('Got 438 without Admin.nick being called.')
|
||||||
|
|
||||||
def doNick(self, irc, msg):
|
def doNick(self, irc, msg):
|
||||||
if msg.nick == irc.nick or msg.args[0] == irc.nick:
|
if msg.nick == irc.nick or msg.args[0] == irc.nick:
|
||||||
try:
|
try:
|
||||||
del self.pendingNickChanges[irc]
|
del self.pendingNickChanges[irc]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.log.debug('Got NICK without Admin.nick being called.')
|
self.log.debug('Got NICK without Admin.nick being called.')
|
||||||
|
|
||||||
def nick(self, irc, msg, args):
|
def nick(self, irc, msg, args):
|
||||||
"""<nick>
|
"""<nick>
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('%s wasn\'t in the ignores database.' % hostmask)
|
irc.error('%s wasn\'t in the ignores database.' % hostmask)
|
||||||
|
|
||||||
def ignores(self, irc, msg, args):
|
def ignores(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ class Config(callbacks.Privmsg):
|
|||||||
registry.open(world.registryFilename)
|
registry.open(world.registryFilename)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
reload = privmsgs.checkCapability(reload, 'owner')
|
reload = privmsgs.checkCapability(reload, 'owner')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class = Config
|
Class = Config
|
||||||
|
@ -68,7 +68,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
if not isinstance(irc.irc, irclib.Irc):
|
if not isinstance(irc.irc, irclib.Irc):
|
||||||
brackets = conf.supybot.reply.brackets.get(msg.args[0])()
|
brackets = conf.supybot.reply.brackets.get(msg.args[0])()
|
||||||
irc.reply(''.join([brackets[0],' '.join(tokens), brackets[1]]))
|
irc.reply(''.join([brackets[0],' '.join(tokens), brackets[1]]))
|
||||||
|
|
||||||
def list(self, irc, msg, args):
|
def list(self, irc, msg, args):
|
||||||
"""[--private] [<module name>]
|
"""[--private] [<module name>]
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
irc.error('That plugin exists, but it has no '
|
irc.error('That plugin exists, but it has no '
|
||||||
'commands with help.')
|
'commands with help.')
|
||||||
|
|
||||||
def apropos(self, irc, msg, args):
|
def apropos(self, irc, msg, args):
|
||||||
"""<string>
|
"""<string>
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
return
|
return
|
||||||
command = callbacks.canonicalName(name)
|
command = callbacks.canonicalName(name)
|
||||||
# Users might expect "@help @list" to work.
|
# Users might expect "@help @list" to work.
|
||||||
command = command.lstrip(conf.supybot.prefixChars())
|
command = command.lstrip(conf.supybot.prefixChars())
|
||||||
cbs = callbacks.findCallbackForCommand(irc, command)
|
cbs = callbacks.findCallbackForCommand(irc, command)
|
||||||
if len(cbs) > 1:
|
if len(cbs) > 1:
|
||||||
tokens = [command]
|
tokens = [command]
|
||||||
@ -294,7 +294,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
break
|
break
|
||||||
L = ['%s: %s' % (k, v) for (k, v) in names.items() if v]
|
L = ['%s: %s' % (k, v) for (k, v) in names.items() if v]
|
||||||
irc.reply(utils.commaAndify(L))
|
irc.reply(utils.commaAndify(L))
|
||||||
|
|
||||||
def source(self, irc, msg, args):
|
def source(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
|
||||||
|
@ -550,7 +550,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except AttributeError: # There's a cleaner way to do this, but I'm lazy.
|
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.')
|
irc.error('I couldn\'t reconnect. You should restart me instead.')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class = Owner
|
Class = Owner
|
||||||
|
@ -187,7 +187,7 @@ class User(callbacks.Privmsg):
|
|||||||
user.name = newname
|
user.name = newname
|
||||||
ircdb.users.setUser(id, user)
|
ircdb.users.setUser(id, user)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
def addhostmask(self, irc, msg, args):
|
def addhostmask(self, irc, msg, args):
|
||||||
"""<name> <hostmask> [<password>]
|
"""<name> <hostmask> [<password>]
|
||||||
|
|
||||||
|
18
src/ircdb.py
18
src/ircdb.py
@ -154,7 +154,7 @@ class UserCapabilitySet(CapabilitySet):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.__parent = super(UserCapabilitySet, self)
|
self.__parent = super(UserCapabilitySet, self)
|
||||||
self.__parent.__init__(*args, **kwargs)
|
self.__parent.__init__(*args, **kwargs)
|
||||||
|
|
||||||
def __contains__(self, capability):
|
def __contains__(self, capability):
|
||||||
capability = ircutils.toLower(capability)
|
capability = ircutils.toLower(capability)
|
||||||
if capability == 'owner' or capability == antiOwner:
|
if capability == 'owner' or capability == antiOwner:
|
||||||
@ -423,12 +423,12 @@ class IrcChannel(object):
|
|||||||
for ignore in self.ignores:
|
for ignore in self.ignores:
|
||||||
write('ignore ' + ignore)
|
write('ignore ' + ignore)
|
||||||
fd.write(os.linesep)
|
fd.write(os.linesep)
|
||||||
|
|
||||||
|
|
||||||
class Creator(object):
|
class Creator(object):
|
||||||
def badCommand(self, command, rest, lineno):
|
def badCommand(self, command, rest, lineno):
|
||||||
raise ValueError, 'Invalid command on line %s: %s' % (lineno, command)
|
raise ValueError, 'Invalid command on line %s: %s' % (lineno, command)
|
||||||
|
|
||||||
class IrcUserCreator(Creator):
|
class IrcUserCreator(Creator):
|
||||||
id = None
|
id = None
|
||||||
def __init__(self, users):
|
def __init__(self, users):
|
||||||
@ -496,7 +496,7 @@ class IrcChannelCreator(Creator):
|
|||||||
if self.name is None:
|
if self.name is None:
|
||||||
raise ValueError, 'Unexpected channel description without channel.'
|
raise ValueError, 'Unexpected channel description without channel.'
|
||||||
self.c.lobotomized = bool(eval(rest))
|
self.c.lobotomized = bool(eval(rest))
|
||||||
|
|
||||||
def defaultallow(self, rest, lineno):
|
def defaultallow(self, rest, lineno):
|
||||||
if self.name is None:
|
if self.name is None:
|
||||||
raise ValueError, 'Unexpected channel description without channel.'
|
raise ValueError, 'Unexpected channel description without channel.'
|
||||||
@ -531,7 +531,7 @@ class IrcChannelCreator(Creator):
|
|||||||
if self.hadChannel:
|
if self.hadChannel:
|
||||||
self.channels.setChannel(self.name, self.c)
|
self.channels.setChannel(self.name, self.c)
|
||||||
IrcChannelCreator.name = None
|
IrcChannelCreator.name = None
|
||||||
|
|
||||||
|
|
||||||
class UsersDictionary(utils.IterableMap):
|
class UsersDictionary(utils.IterableMap):
|
||||||
"""A simple serialized-to-file User Database."""
|
"""A simple serialized-to-file User Database."""
|
||||||
@ -666,7 +666,7 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
for hostmask in self._hostmaskCache[id]:
|
for hostmask in self._hostmaskCache[id]:
|
||||||
del self._hostmaskCache[hostmask]
|
del self._hostmaskCache[hostmask]
|
||||||
del self._hostmaskCache[id]
|
del self._hostmaskCache[id]
|
||||||
|
|
||||||
def setUser(self, id, user):
|
def setUser(self, id, user):
|
||||||
"""Sets a user (given its id) to the IrcUser given it."""
|
"""Sets a user (given its id) to the IrcUser given it."""
|
||||||
assert isinstance(id, int), 'setUser takes an integer userId.'
|
assert isinstance(id, int), 'setUser takes an integer userId.'
|
||||||
@ -713,7 +713,7 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
self.users[id] = user
|
self.users[id] = user
|
||||||
self.flush()
|
self.flush()
|
||||||
return (id, user)
|
return (id, user)
|
||||||
|
|
||||||
|
|
||||||
class ChannelsDictionary(utils.IterableMap):
|
class ChannelsDictionary(utils.IterableMap):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -815,7 +815,7 @@ class IgnoresDB(object):
|
|||||||
log.warning('IgnoresDB.reload failed: %s', e)
|
log.warning('IgnoresDB.reload failed: %s', e)
|
||||||
else:
|
else:
|
||||||
log.warning('IgnoresDB.reload called without self.filename.')
|
log.warning('IgnoresDB.reload called without self.filename.')
|
||||||
|
|
||||||
def checkIgnored(self, prefix):
|
def checkIgnored(self, prefix):
|
||||||
for hostmask in self.hostmasks:
|
for hostmask in self.hostmasks:
|
||||||
if ircutils.hostmaskPatternEqual(hostmask, prefix):
|
if ircutils.hostmaskPatternEqual(hostmask, prefix):
|
||||||
@ -858,7 +858,7 @@ except EnvironmentError, e:
|
|||||||
world.flushers.append(users.flush)
|
world.flushers.append(users.flush)
|
||||||
world.flushers.append(ignores.flush)
|
world.flushers.append(ignores.flush)
|
||||||
world.flushers.append(channels.flush)
|
world.flushers.append(channels.flush)
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Useful functions for checking credentials.
|
# Useful functions for checking credentials.
|
||||||
|
@ -57,7 +57,7 @@ import utils
|
|||||||
def debug(s, *args):
|
def debug(s, *args):
|
||||||
"""Prints a debug string. Most likely replaced by our logging debug."""
|
"""Prints a debug string. Most likely replaced by our logging debug."""
|
||||||
print '***', s % args
|
print '***', s % args
|
||||||
|
|
||||||
def isUserHostmask(s):
|
def isUserHostmask(s):
|
||||||
"""Returns whether or not the string s is a valid User hostmask."""
|
"""Returns whether or not the string s is a valid User hostmask."""
|
||||||
p1 = s.find('!')
|
p1 = s.find('!')
|
||||||
@ -401,7 +401,7 @@ class IrcString(str):
|
|||||||
"""This class does case-insensitive comparison and hashing of nicks."""
|
"""This class does case-insensitive comparison and hashing of nicks."""
|
||||||
def __new__(cls, s=''):
|
def __new__(cls, s=''):
|
||||||
return str.__new__(cls, intern(s))
|
return str.__new__(cls, intern(s))
|
||||||
|
|
||||||
def __init__(self, s):
|
def __init__(self, s):
|
||||||
assert isinstance(s, basestring), \
|
assert isinstance(s, basestring), \
|
||||||
'Cannot make an IrcString from %s' % type(s)
|
'Cannot make an IrcString from %s' % type(s)
|
||||||
@ -432,7 +432,7 @@ class IrcSet(sets.Set):
|
|||||||
self.__parent.__init__()
|
self.__parent.__init__()
|
||||||
for elt in seq:
|
for elt in seq:
|
||||||
self.add(elt)
|
self.add(elt)
|
||||||
|
|
||||||
def add(self, s):
|
def add(self, s):
|
||||||
return self.__parent.add(IrcString(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()
|
self.disable()
|
||||||
error('Error logging to stdout. Removing stdout handler.')
|
error('Error logging to stdout. Removing stdout handler.')
|
||||||
exception('Uncaught exception in StdoutStreamHandler:')
|
exception('Uncaught exception in StdoutStreamHandler:')
|
||||||
|
|
||||||
|
|
||||||
class BetterFileHandler(logging.FileHandler):
|
class BetterFileHandler(logging.FileHandler):
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
@ -208,7 +208,7 @@ def firewall(f, errorHandler=None):
|
|||||||
errorHandler(self, *args, **kwargs)
|
errorHandler(self, *args, **kwargs)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logException(self, 'Uncaught exception in errorHandler')
|
logException(self, 'Uncaught exception in errorHandler')
|
||||||
|
|
||||||
m = utils.changeFunctionName(m, f.func_name, f.__doc__)
|
m = utils.changeFunctionName(m, f.func_name, f.__doc__)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
@ -245,14 +245,14 @@ class ValidLogLevel(registry.String):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return logging.getLevelName(self.value)
|
return logging.getLevelName(self.value)
|
||||||
|
|
||||||
class LogLevel(ValidLogLevel):
|
class LogLevel(ValidLogLevel):
|
||||||
"""Invalid log level. Value must be either DEBUG, INFO, WARNING, ERROR,
|
"""Invalid log level. Value must be either DEBUG, INFO, WARNING, ERROR,
|
||||||
or CRITICAL."""
|
or CRITICAL."""
|
||||||
def setValue(self, v):
|
def setValue(self, v):
|
||||||
ValidLogLevel.setValue(self, v)
|
ValidLogLevel.setValue(self, v)
|
||||||
_logger.setLevel(self.value) # _logger defined later.
|
_logger.setLevel(self.value) # _logger defined later.
|
||||||
|
|
||||||
conf.supybot.directories.register('log', registry.String('logs', """Determines
|
conf.supybot.directories.register('log', registry.String('logs', """Determines
|
||||||
what directory the bot will store its logfiles in."""))
|
what directory the bot will store its logfiles in."""))
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ class BooleanRequiredFalseOnWindows(registry.Boolean):
|
|||||||
registry.Boolean.set(self, s)
|
registry.Boolean.set(self, s)
|
||||||
if self.value and os.name == 'nt':
|
if self.value and os.name == 'nt':
|
||||||
raise InvalidRegistryValue, 'Value cannot be true on Windows.'
|
raise InvalidRegistryValue, 'Value cannot be true on Windows.'
|
||||||
|
|
||||||
conf.supybot.log.stdout.register('colorized',
|
conf.supybot.log.stdout.register('colorized',
|
||||||
BooleanRequiredFalseOnWindows(False, """Determines whether the bot's logs to
|
BooleanRequiredFalseOnWindows(False, """Determines whether the bot's logs to
|
||||||
stdout (if enabled) will be colorized with ANSI color."""))
|
stdout (if enabled) will be colorized with ANSI color."""))
|
||||||
|
@ -107,8 +107,8 @@ class DBHandler(object):
|
|||||||
if self.cachedDb is not None:
|
if self.cachedDb is not None:
|
||||||
self.cachedDb.die()
|
self.cachedDb.die()
|
||||||
del self.cachedDb
|
del self.cachedDb
|
||||||
|
|
||||||
|
|
||||||
# XXX: This shouldn't be a mixin. This should be contained by classes that
|
# 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
|
# want such behavior. But at this point, it wouldn't gain much for us
|
||||||
# to refactor it.
|
# to refactor it.
|
||||||
@ -174,18 +174,18 @@ class ChannelUserDictionary(UserDict.DictMixin):
|
|||||||
|
|
||||||
def __delitem__(self, (channel, id)):
|
def __delitem__(self, (channel, id)):
|
||||||
del self.channels[channel][id]
|
del self.channels[channel][id]
|
||||||
|
|
||||||
def iteritems(self):
|
def iteritems(self):
|
||||||
for (channel, ids) in self.channels.iteritems():
|
for (channel, ids) in self.channels.iteritems():
|
||||||
for (id, v) in ids.iteritems():
|
for (id, v) in ids.iteritems():
|
||||||
yield ((channel, id), v)
|
yield ((channel, id), v)
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
L = []
|
L = []
|
||||||
for (k, _) in self.iteritems():
|
for (k, _) in self.iteritems():
|
||||||
L.append(k)
|
L.append(k)
|
||||||
return L
|
return L
|
||||||
|
|
||||||
|
|
||||||
class ChannelUserDB(ChannelUserDictionary):
|
class ChannelUserDB(ChannelUserDictionary):
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
@ -347,7 +347,7 @@ class PeriodicFileDownloader(object):
|
|||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
t.start()
|
t.start()
|
||||||
world.threadsSpawned += 1
|
world.threadsSpawned += 1
|
||||||
|
|
||||||
|
|
||||||
_randomnickRe = re.compile(r'\$rand(?:om)?nick', re.I)
|
_randomnickRe = re.compile(r'\$rand(?:om)?nick', re.I)
|
||||||
_randomdateRe = re.compile(r'\$rand(?:om)?date', re.I)
|
_randomdateRe = re.compile(r'\$rand(?:om)?date', re.I)
|
||||||
@ -368,7 +368,7 @@ def standardSubstitute(irc, msg, text):
|
|||||||
def randInt(m):
|
def randInt(m):
|
||||||
return str(random.randint(-1000, 1000))
|
return str(random.randint(-1000, 1000))
|
||||||
def randDate(m):
|
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)
|
return time.ctime(t)
|
||||||
def randNick(m):
|
def randNick(m):
|
||||||
if channel != 'somewhere':
|
if channel != 'somewhere':
|
||||||
|
@ -141,7 +141,7 @@ def _threadedWrapMethod(f):
|
|||||||
finally:
|
finally:
|
||||||
self.threaded = originalThreaded
|
self.threaded = originalThreaded
|
||||||
return utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
return utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||||
|
|
||||||
def thread(f):
|
def thread(f):
|
||||||
"""Makes sure a command spawns a thread when called."""
|
"""Makes sure a command spawns a thread when called."""
|
||||||
f = _threadedWrapMethod(f)
|
f = _threadedWrapMethod(f)
|
||||||
@ -194,7 +194,7 @@ def urlSnarfer(f):
|
|||||||
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||||
newf.q = q # This isn't necessary, it's just for debugging.
|
newf.q = q # This isn't necessary, it's just for debugging.
|
||||||
return newf
|
return newf
|
||||||
|
|
||||||
|
|
||||||
class CapabilityCheckingPrivmsg(callbacks.Privmsg):
|
class CapabilityCheckingPrivmsg(callbacks.Privmsg):
|
||||||
"""A small subclass of callbacks.Privmsg that checks self.capability
|
"""A small subclass of callbacks.Privmsg that checks self.capability
|
||||||
|
@ -148,7 +148,7 @@ class Group(object):
|
|||||||
return self.__makeChild(attr, str(self))
|
return self.__makeChild(attr, str(self))
|
||||||
else:
|
else:
|
||||||
self.__nonExistentEntry(attr)
|
self.__nonExistentEntry(attr)
|
||||||
|
|
||||||
def get(self, attr):
|
def get(self, attr):
|
||||||
# Not getattr(self, attr) because some nodes might have groups that
|
# Not getattr(self, attr) because some nodes might have groups that
|
||||||
# are named the same as their methods.
|
# are named the same as their methods.
|
||||||
@ -167,7 +167,7 @@ class Group(object):
|
|||||||
except InvalidRegistryValue:
|
except InvalidRegistryValue:
|
||||||
# It's probably supposed to be registered later.
|
# It's probably supposed to be registered later.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def register(self, name, node=None):
|
def register(self, name, node=None):
|
||||||
if not isValidRegistryName(name):
|
if not isValidRegistryName(name):
|
||||||
raise InvalidRegistryName, name
|
raise InvalidRegistryName, name
|
||||||
@ -214,7 +214,7 @@ class Value(Group):
|
|||||||
private=False, showDefault=True, **kwargs):
|
private=False, showDefault=True, **kwargs):
|
||||||
Group.__init__(self, **kwargs)
|
Group.__init__(self, **kwargs)
|
||||||
self.default = default
|
self.default = default
|
||||||
self.private = private
|
self.private = private
|
||||||
self.showDefault = showDefault
|
self.showDefault = showDefault
|
||||||
self.help = utils.normalizeWhitespace(help.strip())
|
self.help = utils.normalizeWhitespace(help.strip())
|
||||||
self.setValue(default)
|
self.setValue(default)
|
||||||
@ -250,7 +250,7 @@ class Value(Group):
|
|||||||
for (name, v) in self.children.items():
|
for (name, v) in self.children.items():
|
||||||
if v.__class__ is self.X:
|
if v.__class__ is self.X:
|
||||||
self.unregister(name)
|
self.unregister(name)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self())
|
return repr(self())
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ class OnlySomeStrings(String):
|
|||||||
assert self.validStrings, 'There must be some valid strings. ' \
|
assert self.validStrings, 'There must be some valid strings. ' \
|
||||||
'This is a bug.'
|
'This is a bug.'
|
||||||
String.__init__(self, *args, **kwargs)
|
String.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
def error(self):
|
def error(self):
|
||||||
raise InvalidRegistryValue, \
|
raise InvalidRegistryValue, \
|
||||||
'That is not a valid value. Valid values include %s.' % \
|
'That is not a valid value. Valid values include %s.' % \
|
||||||
@ -348,14 +348,14 @@ class OnlySomeStrings(String):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
return s # This is handled in setValue.
|
return s # This is handled in setValue.
|
||||||
return self.validStrings[i]
|
return self.validStrings[i]
|
||||||
|
|
||||||
def setValue(self, s):
|
def setValue(self, s):
|
||||||
s = self.normalize(s)
|
s = self.normalize(s)
|
||||||
if s in self.validStrings:
|
if s in self.validStrings:
|
||||||
String.setValue(self, s)
|
String.setValue(self, s)
|
||||||
else:
|
else:
|
||||||
self.error()
|
self.error()
|
||||||
|
|
||||||
class NormalizedString(String):
|
class NormalizedString(String):
|
||||||
def set(self, s):
|
def set(self, s):
|
||||||
s = utils.normalizeWhitespace(s.strip())
|
s = utils.normalizeWhitespace(s.strip())
|
||||||
@ -376,7 +376,7 @@ class StringSurroundedBySpaces(String):
|
|||||||
if v.rstrip() == v:
|
if v.rstrip() == v:
|
||||||
v += ' '
|
v += ' '
|
||||||
String.setValue(self, v)
|
String.setValue(self, v)
|
||||||
|
|
||||||
class StringWithSpaceOnRight(String):
|
class StringWithSpaceOnRight(String):
|
||||||
def setValue(self, v):
|
def setValue(self, v):
|
||||||
if v.rstrip() == v:
|
if v.rstrip() == v:
|
||||||
@ -410,7 +410,7 @@ class Regexp(Value):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
self() # Gotta update if we've been reloaded.
|
self() # Gotta update if we've been reloaded.
|
||||||
return self.sr
|
return self.sr
|
||||||
|
|
||||||
class SeparatedListOf(Value):
|
class SeparatedListOf(Value):
|
||||||
List = list
|
List = list
|
||||||
Value = Value
|
Value = Value
|
||||||
@ -422,7 +422,7 @@ class SeparatedListOf(Value):
|
|||||||
def joiner(self, L):
|
def joiner(self, L):
|
||||||
"""Override this to join the internal list for output."""
|
"""Override this to join the internal list for output."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def set(self, s):
|
def set(self, s):
|
||||||
L = self.splitter(s)
|
L = self.splitter(s)
|
||||||
for (i, s) in enumerate(L):
|
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
|
# can run into issues showing users the value if they've disabled
|
||||||
# nick prefixes in any of the numerous ways possible. Since the
|
# nick prefixes in any of the numerous ways possible. Since the
|
||||||
# config parser doesn't care about this space, we'll use it :)
|
# config parser doesn't care about this space, we'll use it :)
|
||||||
return ' '
|
return ' '
|
||||||
|
|
||||||
class SpaceSeparatedListOf(SeparatedListOf):
|
class SpaceSeparatedListOf(SeparatedListOf):
|
||||||
def splitter(self, s):
|
def splitter(self, s):
|
||||||
return s.split()
|
return s.split()
|
||||||
joiner = ' '.join
|
joiner = ' '.join
|
||||||
|
|
||||||
class SpaceSeparatedListOfStrings(SpaceSeparatedListOf):
|
class SpaceSeparatedListOfStrings(SpaceSeparatedListOf):
|
||||||
Value = String
|
Value = String
|
||||||
|
|
||||||
@ -457,7 +457,7 @@ class CommaSeparatedListOfStrings(SeparatedListOf):
|
|||||||
def splitter(self, s):
|
def splitter(self, s):
|
||||||
return re.split(r'\s*,\s*', s)
|
return re.split(r'\s*,\s*', s)
|
||||||
joiner = ', '.join
|
joiner = ', '.join
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#if 1:
|
#if 1:
|
||||||
@ -496,7 +496,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
print supybot.throttleTime.help
|
print supybot.throttleTime.help
|
||||||
print supybot.plugins.topic.separator.help
|
print supybot.plugins.topic.separator.help
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ class queue(object):
|
|||||||
def reset(self):
|
def reset(self):
|
||||||
self.back[:] = []
|
self.back[:] = []
|
||||||
self.front[:] = []
|
self.front[:] = []
|
||||||
|
|
||||||
def enqueue(self, elt):
|
def enqueue(self, elt):
|
||||||
self.back.append(elt)
|
self.back.append(elt)
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ class TwoWayDictionary(dict):
|
|||||||
for (key, value) in kwargs.iteritems():
|
for (key, value) in kwargs.iteritems():
|
||||||
self[key] = value
|
self[key] = value
|
||||||
self[value] = key
|
self[value] = key
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
dict.__setitem__(self, key, value)
|
dict.__setitem__(self, key, value)
|
||||||
dict.__setitem__(self, value, key)
|
dict.__setitem__(self, value, key)
|
||||||
|
@ -101,7 +101,7 @@ class SupyReconnectingFactory(ReconnectingClientFactory):
|
|||||||
protocol = ReconnectingClientFactory.buildProtocol(self, addr)
|
protocol = ReconnectingClientFactory.buildProtocol(self, addr)
|
||||||
protocol.irc = self.irc
|
protocol.irc = self.irc
|
||||||
return protocol
|
return protocol
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@ class Reader(object):
|
|||||||
|
|
||||||
def normalizeCommand(self, s):
|
def normalizeCommand(self, s):
|
||||||
return s.lower()
|
return s.lower()
|
||||||
|
|
||||||
def readFile(self, filename):
|
def readFile(self, filename):
|
||||||
self.read(file(filename))
|
self.read(file(filename))
|
||||||
|
|
||||||
def read(self, fd):
|
def read(self, fd):
|
||||||
lineno = 0
|
lineno = 0
|
||||||
for line in fd:
|
for line in fd:
|
||||||
|
@ -335,11 +335,11 @@ def pluralize(s, i=2):
|
|||||||
lowered = s.lower()
|
lowered = s.lower()
|
||||||
# Exception dictionary
|
# Exception dictionary
|
||||||
if lowered in plurals:
|
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)
|
# Words ending with 'ch', 'sh' or 'ss' such as 'punch(es)', 'fish(es)
|
||||||
# and miss(es)
|
# and miss(es)
|
||||||
elif any(lowered.endswith, ['ch', 'sh', 'ss']):
|
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
|
# Words ending with a consonant followed by a 'y' such as
|
||||||
# 'try (tries)' or 'spy (spies)'
|
# 'try (tries)' or 'spy (spies)'
|
||||||
elif re.search(_pluralizeRegex, lowered):
|
elif re.search(_pluralizeRegex, lowered):
|
||||||
|
@ -36,7 +36,7 @@ import logging
|
|||||||
|
|
||||||
if not os.path.exists('test-conf'):
|
if not os.path.exists('test-conf'):
|
||||||
os.mkdir('test-conf')
|
os.mkdir('test-conf')
|
||||||
|
|
||||||
registryFilename = os.path.join('test-conf', 'test.conf')
|
registryFilename = os.path.join('test-conf', 'test.conf')
|
||||||
fd = file(registryFilename, 'w')
|
fd = file(registryFilename, 'w')
|
||||||
fd.write("""
|
fd.write("""
|
||||||
@ -94,7 +94,7 @@ if __name__ == '__main__':
|
|||||||
pluginLogDir = os.path.join(conf.supybot.directories.log(), 'plugins')
|
pluginLogDir = os.path.join(conf.supybot.directories.log(), 'plugins')
|
||||||
if not os.path.exists(pluginLogDir):
|
if not os.path.exists(pluginLogDir):
|
||||||
os.mkdir(pluginLogDir)
|
os.mkdir(pluginLogDir)
|
||||||
|
|
||||||
for filename in os.listdir(pluginLogDir):
|
for filename in os.listdir(pluginLogDir):
|
||||||
os.remove(os.path.join(pluginLogDir, filename))
|
os.remove(os.path.join(pluginLogDir, filename))
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class AdminTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testAddCapabilityOwner(self):
|
def testAddCapabilityOwner(self):
|
||||||
self.assertError('admin addcapability %s owner' % self.nick)
|
self.assertError('admin addcapability %s owner' % self.nick)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -69,14 +69,14 @@ class AliasTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
plugins = ('Alias', 'Filter', 'Utilities')
|
plugins = ('Alias', 'Filter', 'Utilities')
|
||||||
def testNoAliasWithNestedCommandName(self):
|
def testNoAliasWithNestedCommandName(self):
|
||||||
self.assertError('alias add foo "[bar] baz"')
|
self.assertError('alias add foo "[bar] baz"')
|
||||||
|
|
||||||
def testDoesNotOverwriteCommands(self):
|
def testDoesNotOverwriteCommands(self):
|
||||||
self.assertError('alias add alias "echo foo bar baz"')
|
self.assertError('alias add alias "echo foo bar baz"')
|
||||||
self.assertError('alias add add "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 remove "echo foo bar baz"')
|
||||||
self.assertError('alias add lock "echo foo bar baz"')
|
self.assertError('alias add lock "echo foo bar baz"')
|
||||||
self.assertError('alias add unlock "echo foo bar baz"')
|
self.assertError('alias add unlock "echo foo bar baz"')
|
||||||
|
|
||||||
def testAliasHelp(self):
|
def testAliasHelp(self):
|
||||||
self.assertNotError('alias add slashdot foo')
|
self.assertNotError('alias add slashdot foo')
|
||||||
self.assertRegexp('help slashdot', "Alias for 'foo.*'")
|
self.assertRegexp('help slashdot', "Alias for 'foo.*'")
|
||||||
@ -86,7 +86,7 @@ class AliasTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
self.assertResponse('foo', 'bar')
|
self.assertResponse('foo', 'bar')
|
||||||
self.assertNotError('alias remove foo')
|
self.assertNotError('alias remove foo')
|
||||||
self.assertNoResponse('foo', 2)
|
self.assertNoResponse('foo', 2)
|
||||||
|
|
||||||
def testDollars(self):
|
def testDollars(self):
|
||||||
self.assertNotError('alias add rot26 "rot13 [rot13 $1]"')
|
self.assertNotError('alias add rot26 "rot13 [rot13 $1]"')
|
||||||
self.assertResponse('rot26 foobar', 'foobar')
|
self.assertResponse('rot26 foobar', 'foobar')
|
||||||
@ -155,7 +155,7 @@ class AliasTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
def testSimpleAliasWithoutArgsImpliesDollarStar(self):
|
def testSimpleAliasWithoutArgsImpliesDollarStar(self):
|
||||||
self.assertNotError('alias add exo echo')
|
self.assertNotError('alias add exo echo')
|
||||||
self.assertResponse('exo foo bar baz', 'foo bar baz')
|
self.assertResponse('exo foo bar baz', 'foo bar baz')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# 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 %s' % word, word)
|
||||||
self.assertRegexp('echo foo%sbar' % word, word)
|
self.assertRegexp('echo foo%sbar' % word, word)
|
||||||
self.assertRegexp('echo [strjoin "" %s]' % ' '.join(word), word)
|
self.assertRegexp('echo [strjoin "" %s]' % ' '.join(word), word)
|
||||||
|
|
||||||
def testAddbadwords(self):
|
def testAddbadwords(self):
|
||||||
self.assertNotError('badwords add %s' % ' '.join(self.badwords))
|
self.assertNotError('badwords add %s' % ' '.join(self.badwords))
|
||||||
self._test()
|
self._test()
|
||||||
|
@ -51,7 +51,7 @@ if sqlite is not None:
|
|||||||
_ = self.irc.takeMsg()
|
_ = self.irc.takeMsg()
|
||||||
chanop = ircdb.makeChannelCapability(self.channel, 'op')
|
chanop = ircdb.makeChannelCapability(self.channel, 'op')
|
||||||
ircdb.users.getUser(self.nick).addCapability(chanop)
|
ircdb.users.getUser(self.nick).addCapability(chanop)
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
self.assertNotError('channelstats')
|
self.assertNotError('channelstats')
|
||||||
self.assertNotError('channelstats')
|
self.assertNotError('channelstats')
|
||||||
@ -79,7 +79,7 @@ if sqlite is not None:
|
|||||||
self.assertEqual(m1.args[1], m2.args[1])
|
self.assertEqual(m1.args[1], m2.args[1])
|
||||||
finally:
|
finally:
|
||||||
conf.supybot.plugins.ChannelStats.selfStats.setValue(True)
|
conf.supybot.plugins.ChannelStats.selfStats.setValue(True)
|
||||||
|
|
||||||
def testNoKeyErrorStats(self):
|
def testNoKeyErrorStats(self):
|
||||||
self.assertNotRegexp('stats sweede', 'KeyError')
|
self.assertNotRegexp('stats sweede', 'KeyError')
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class FunTest(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testPing(self):
|
def testPing(self):
|
||||||
self.assertResponse('ping', 'pong')
|
self.assertResponse('ping', 'pong')
|
||||||
|
|
||||||
def testNoErrors(self):
|
def testNoErrors(self):
|
||||||
self.assertNotError('objects')
|
self.assertNotError('objects')
|
||||||
self.assertNotError('levenshtein Python Perl')
|
self.assertNotError('levenshtein Python Perl')
|
||||||
|
@ -70,7 +70,7 @@ if network:
|
|||||||
conf.supybot.plugins.Gameknot.statSnarfer.setValue(True)
|
conf.supybot.plugins.Gameknot.statSnarfer.setValue(True)
|
||||||
self.assertNotError('http://gameknot.com/stats.pl?ironchefchess')
|
self.assertNotError('http://gameknot.com/stats.pl?ironchefchess')
|
||||||
self.assertNotError('http://gameknot.com/chess.pl?bd=907498')
|
self.assertNotError('http://gameknot.com/chess.pl?bd=907498')
|
||||||
|
|
||||||
|
|
||||||
def testSnarfer(self):
|
def testSnarfer(self):
|
||||||
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True)
|
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True)
|
||||||
|
@ -38,7 +38,7 @@ class GoogleTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
|
conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'google blah'))
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'google blah'))
|
||||||
self.assertNoResponse(' ')
|
self.assertNoResponse(' ')
|
||||||
|
|
||||||
def testGroupsSnarfer(self):
|
def testGroupsSnarfer(self):
|
||||||
conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
|
conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
|
||||||
self.assertRegexp('http://groups.google.com/groups?dq=&hl=en&'
|
self.assertRegexp('http://groups.google.com/groups?dq=&hl=en&'
|
||||||
|
@ -43,7 +43,7 @@ if network:
|
|||||||
def testHeaders(self):
|
def testHeaders(self):
|
||||||
self.assertError('headers ftp://ftp.cdrom.com/pub/linux')
|
self.assertError('headers ftp://ftp.cdrom.com/pub/linux')
|
||||||
self.assertNotError('headers http://www.slashdot.org/')
|
self.assertNotError('headers http://www.slashdot.org/')
|
||||||
|
|
||||||
def testDoctype(self):
|
def testDoctype(self):
|
||||||
self.assertError('doctype ftp://ftp.cdrom.com/pub/linux')
|
self.assertError('doctype ftp://ftp.cdrom.com/pub/linux')
|
||||||
self.assertNotError('doctype http://www.slashdot.org/')
|
self.assertNotError('doctype http://www.slashdot.org/')
|
||||||
|
@ -54,7 +54,7 @@ if sqlite:
|
|||||||
|
|
||||||
def testCantCreateLookupNamedLookup(self):
|
def testCantCreateLookupNamedLookup(self):
|
||||||
self.assertError('lookup add lookup foo.supyfact')
|
self.assertError('lookup add lookup foo.supyfact')
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
PluginTestCase.setUp(self)
|
PluginTestCase.setUp(self)
|
||||||
dataDir = conf.supybot.directories.data()
|
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 8 [base 8 76532]', '76532')
|
||||||
self.assertResponse('base 10 36 [base 36 csalnwea]', 'CSALNWEA')
|
self.assertResponse('base 10 36 [base 36 csalnwea]', 'CSALNWEA')
|
||||||
self.assertResponse('base 5 4 [base 4 5 212231]', '212231')
|
self.assertResponse('base 5 4 [base 4 5 212231]', '212231')
|
||||||
|
|
||||||
self.assertRegexp('base 37 1', 'between 2 and 36')
|
self.assertRegexp('base 37 1', 'between 2 and 36')
|
||||||
self.assertRegexp('base 1 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 12 1 1', 'between 2 and 36')
|
||||||
self.assertRegexp('base 1 12 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 1.0 12 1', 'between 2 and 36')
|
||||||
self.assertRegexp('base A 1', 'between 2 and 36')
|
self.assertRegexp('base A 1', 'between 2 and 36')
|
||||||
|
|
||||||
self.assertRegexp('base 4 4', 'Invalid <number>')
|
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
|
||||||
print "If we have not fixed a bug with Math.base, the following ",
|
print "If we have not fixed a bug with Math.base, the following ",
|
||||||
@ -125,7 +125,7 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testCalcFloorWorksWithSqrt(self):
|
def testCalcFloorWorksWithSqrt(self):
|
||||||
self.assertNotError('calc floor(sqrt(5))')
|
self.assertNotError('calc floor(sqrt(5))')
|
||||||
|
|
||||||
def testRpn(self):
|
def testRpn(self):
|
||||||
self.assertResponse('rpn 5 2 +', '7')
|
self.assertResponse('rpn 5 2 +', '7')
|
||||||
self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]')
|
self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]')
|
||||||
@ -138,7 +138,7 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testRpmNoSyntaxError(self):
|
def testRpmNoSyntaxError(self):
|
||||||
self.assertNotRegexp('rpn 2 3 foobar', 'SyntaxError')
|
self.assertNotRegexp('rpn 2 3 foobar', 'SyntaxError')
|
||||||
|
|
||||||
def testConvert(self):
|
def testConvert(self):
|
||||||
self.assertResponse('convert 1 m to cm', '100')
|
self.assertResponse('convert 1 m to cm', '100')
|
||||||
self.assertResponse('convert 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 F to C', '0')
|
||||||
self.assertResponse('convert 32 C to F', '89.6')
|
self.assertResponse('convert 32 C to F', '89.6')
|
||||||
self.assertResponse('convert [calc 2*pi] rad to degree', '360')
|
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')
|
'1')
|
||||||
self.assertResponse('convert [calc 2*pi] rad to circle', '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 gram to meatballs')
|
||||||
self.assertError('convert 1 mol to grams')
|
self.assertError('convert 1 mol to grams')
|
||||||
self.assertError('convert 1 m to kpa')
|
self.assertError('convert 1 m to kpa')
|
||||||
|
|
||||||
def testConvertSingularPlural(self):
|
def testConvertSingularPlural(self):
|
||||||
self.assertResponse('convert [calc 2*pi] rads to degrees',
|
self.assertResponse('convert [calc 2*pi] rads to degrees',
|
||||||
'360')
|
'360')
|
||||||
|
@ -68,7 +68,7 @@ class MiscTestCase(ChannelPluginTestCase):
|
|||||||
self.assertResponse('StRlEn foobar', '6')
|
self.assertResponse('StRlEn foobar', '6')
|
||||||
finally:
|
finally:
|
||||||
conf.supybot.reply.whenNotCommand.set(original)
|
conf.supybot.reply.whenNotCommand.set(original)
|
||||||
|
|
||||||
def testHelp(self):
|
def testHelp(self):
|
||||||
self.assertHelp('help list')
|
self.assertHelp('help list')
|
||||||
self.assertRegexp('help help', r'^\(\x02help')
|
self.assertRegexp('help help', r'^\(\x02help')
|
||||||
@ -171,11 +171,11 @@ class MiscTestCase(ChannelPluginTestCase):
|
|||||||
self.assertNotError('more %s' % nick)
|
self.assertNotError('more %s' % nick)
|
||||||
self.assertNotError('more %s' % nick.upper())
|
self.assertNotError('more %s' % nick.upper())
|
||||||
self.assertNotError('more %s' % nick.lower())
|
self.assertNotError('more %s' % nick.lower())
|
||||||
|
|
||||||
def testPrivate(self):
|
def testPrivate(self):
|
||||||
m = self.getMsg('private [list]')
|
m = self.getMsg('private [list]')
|
||||||
self.failIf(ircutils.isChannel(m.args[0]))
|
self.failIf(ircutils.isChannel(m.args[0]))
|
||||||
|
|
||||||
def testNotice(self):
|
def testNotice(self):
|
||||||
m = self.getMsg('notice [list]')
|
m = self.getMsg('notice [list]')
|
||||||
self.assertEqual(m.command, 'NOTICE')
|
self.assertEqual(m.command, 'NOTICE')
|
||||||
@ -211,7 +211,7 @@ class MiscTestCase(ChannelPluginTestCase):
|
|||||||
|
|
||||||
def testRevisionIsCaseInsensitive(self):
|
def testRevisionIsCaseInsensitive(self):
|
||||||
self.assertNotError('revision misc')
|
self.assertNotError('revision misc')
|
||||||
|
|
||||||
def testSeconds(self):
|
def testSeconds(self):
|
||||||
self.assertResponse('seconds 1s', '1')
|
self.assertResponse('seconds 1s', '1')
|
||||||
self.assertResponse('seconds 10s', '10')
|
self.assertResponse('seconds 10s', '10')
|
||||||
|
@ -53,7 +53,7 @@ if sqlite is not None:
|
|||||||
if option in L:
|
if option in L:
|
||||||
L.remove(option)
|
L.remove(option)
|
||||||
self.failIf(L, 'Some options never seen: %s' % L)
|
self.failIf(L, 'Some options never seen: %s' % L)
|
||||||
|
|
||||||
def testPickOptions(self):
|
def testPickOptions(self):
|
||||||
self._testOptions('(a|b)', ['a', 'b'])
|
self._testOptions('(a|b)', ['a', 'b'])
|
||||||
self._testOptions('a', ['a'])
|
self._testOptions('a', ['a'])
|
||||||
@ -76,7 +76,7 @@ if sqlite is not None:
|
|||||||
self.assertNotError('moo is foo')
|
self.assertNotError('moo is foo')
|
||||||
# Check stripping punctuation
|
# Check stripping punctuation
|
||||||
self.assertError('moo!? is foo') # 'moo' already exists
|
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.assertResponse('foo', 'foo is foo')
|
||||||
self.assertNotError('bar is <reply>moo is moo')
|
self.assertNotError('bar is <reply>moo is moo')
|
||||||
self.assertResponse('bar', '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 .*?, '
|
'Last requested by foo!bar@baz on .*?, '
|
||||||
'requested 2 times.$')
|
'requested 2 times.$')
|
||||||
# Make sure I solved this bug
|
# 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 is bar')
|
||||||
self.assertNotError('foo =~ s/bar/blah/')
|
self.assertNotError('foo =~ s/bar/blah/')
|
||||||
self.assertNotError('foo')
|
self.assertNotError('foo')
|
||||||
@ -183,7 +183,7 @@ if sqlite is not None:
|
|||||||
'^moo: Created by tester on.*?\.')
|
'^moo: Created by tester on.*?\.')
|
||||||
finally:
|
finally:
|
||||||
world.testing = True
|
world.testing = True
|
||||||
|
|
||||||
def testChangeFactoid(self):
|
def testChangeFactoid(self):
|
||||||
self.assertNotError('moo is <reply>moo')
|
self.assertNotError('moo is <reply>moo')
|
||||||
self.assertNotError('moo =~ s/moo/moos/')
|
self.assertNotError('moo =~ s/moo/moos/')
|
||||||
@ -214,8 +214,8 @@ if sqlite is not None:
|
|||||||
self.assertNotError('moogle is <reply>moo')
|
self.assertNotError('moogle is <reply>moo')
|
||||||
self.assertError('most popular')
|
self.assertError('most popular')
|
||||||
self.assertResponse('most authored',
|
self.assertResponse('most authored',
|
||||||
'Most prolific author: moo (1)')
|
'Most prolific author: moo (1)')
|
||||||
self.assertRegexp('most recent', "1 latest factoid:.*moogle")
|
self.assertRegexp('most recent', "1 latest factoid:.*moogle")
|
||||||
self.assertResponse('moogle', 'moo')
|
self.assertResponse('moogle', 'moo')
|
||||||
self.assertRegexp('most popular',
|
self.assertRegexp('most popular',
|
||||||
"Top 1 requested factoid:.*moogle.*(1)")
|
"Top 1 requested factoid:.*moogle.*(1)")
|
||||||
@ -223,9 +223,9 @@ if sqlite is not None:
|
|||||||
self.prefix = userPrefix2
|
self.prefix = userPrefix2
|
||||||
self.assertNotError('mogle is <reply>mo')
|
self.assertNotError('mogle is <reply>mo')
|
||||||
self.assertRegexp('most authored',
|
self.assertRegexp('most authored',
|
||||||
'Most prolific authors:.*moo.*(1).*boo.*(1)')
|
'Most prolific authors:.*moo.*(1).*boo.*(1)')
|
||||||
self.assertRegexp('most recent',
|
self.assertRegexp('most recent',
|
||||||
"2 latest factoids:.*mogle.*moogle.*")
|
"2 latest factoids:.*mogle.*moogle.*")
|
||||||
self.assertResponse('moogle', 'moo')
|
self.assertResponse('moogle', 'moo')
|
||||||
self.assertRegexp('most popular',
|
self.assertRegexp('most popular',
|
||||||
"Top 1 requested factoid:.*moogle.*(2)")
|
"Top 1 requested factoid:.*moogle.*(2)")
|
||||||
@ -339,6 +339,6 @@ if sqlite is not None:
|
|||||||
self.assertNotError('foo is <reply>bar')
|
self.assertNotError('foo is <reply>bar')
|
||||||
self.assertNotError('bar is <reply>baz')
|
self.assertNotError('bar is <reply>baz')
|
||||||
self.assertRegexp('randomfactoid', r'bar|baz')
|
self.assertRegexp('randomfactoid', r'bar|baz')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -85,7 +85,7 @@ if sqlite is not None:
|
|||||||
time.sleep(6)
|
time.sleep(6)
|
||||||
print 'Done sleeping.'
|
print 'Done sleeping.'
|
||||||
self.assertNotError('old')
|
self.assertNotError('old')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# 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')
|
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:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class OwnerTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
conf.allowEval = True
|
conf.allowEval = True
|
||||||
self.assertNotError('eval 100')
|
self.assertNotError('eval 100')
|
||||||
s = "[irc.__class__ for irc in " \
|
s = "[irc.__class__ for irc in " \
|
||||||
"irc.getCallback('Relay').ircstates.keys()]"
|
"irc.getCallback('Relay').ircstates.keys()]"
|
||||||
self.assertNotRegexp('eval ' + s, '^SyntaxError')
|
self.assertNotRegexp('eval ' + s, '^SyntaxError')
|
||||||
conf.allowEval = False
|
conf.allowEval = False
|
||||||
self.assertError('eval 100')
|
self.assertError('eval 100')
|
||||||
|
@ -68,9 +68,9 @@ class PythonTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
'Implementation of sets using sorted lists')
|
'Implementation of sets using sorted lists')
|
||||||
finally:
|
finally:
|
||||||
conf.supybot.plugins.Python.aspnSnarfer.setValue(False)
|
conf.supybot.plugins.Python.aspnSnarfer.setValue(False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ if sqlite:
|
|||||||
plugins = ('QuoteGrabs',)
|
plugins = ('QuoteGrabs',)
|
||||||
def testQuoteGrab(self):
|
def testQuoteGrab(self):
|
||||||
testPrefix = 'foo!bar@baz'
|
testPrefix = 'foo!bar@baz'
|
||||||
self.assertError('grab foo')
|
self.assertError('grab foo')
|
||||||
# Test join/part/notice (shouldn't grab)
|
# Test join/part/notice (shouldn't grab)
|
||||||
self.irc.feedMsg(ircmsgs.join(self.channel, prefix=testPrefix))
|
self.irc.feedMsg(ircmsgs.join(self.channel, prefix=testPrefix))
|
||||||
self.assertError('grab foo')
|
self.assertError('grab foo')
|
||||||
@ -53,7 +53,7 @@ if sqlite:
|
|||||||
# Test privmsgs
|
# Test privmsgs
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something',
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something',
|
||||||
prefix=testPrefix))
|
prefix=testPrefix))
|
||||||
self.assertNotError('grab foo')
|
self.assertNotError('grab foo')
|
||||||
self.assertResponse('quote foo', '<foo> something')
|
self.assertResponse('quote foo', '<foo> something')
|
||||||
# Test actions
|
# Test actions
|
||||||
self.irc.feedMsg(ircmsgs.action(self.channel, 'moos',
|
self.irc.feedMsg(ircmsgs.action(self.channel, 'moos',
|
||||||
@ -78,7 +78,7 @@ if sqlite:
|
|||||||
testPrefix = 'foo!bar@baz'
|
testPrefix = 'foo!bar@baz'
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
||||||
prefix=testPrefix))
|
prefix=testPrefix))
|
||||||
self.assertNotError('grab foo')
|
self.assertNotError('grab foo')
|
||||||
self.assertNotError('grab foo') # note:NOTanerror,stillwon'tdupe
|
self.assertNotError('grab foo') # note:NOTanerror,stillwon'tdupe
|
||||||
self.assertResponse('quotegrabs list foo', '#1: test')
|
self.assertResponse('quotegrabs list foo', '#1: test')
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ if sqlite is not None:
|
|||||||
self.assertRegexp('stats #foo', '0')
|
self.assertRegexp('stats #foo', '0')
|
||||||
self.assertError('random #foo')
|
self.assertError('random #foo')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
@ -63,12 +63,12 @@ class RootWarnerTestCase(PluginTestCase):
|
|||||||
finally:
|
finally:
|
||||||
conf.supybot.plugins.RootWarner.warn.setValue(True)
|
conf.supybot.plugins.RootWarner.warn.setValue(True)
|
||||||
conf.supybot.plugins.RootWarner.kick.setValue(False)
|
conf.supybot.plugins.RootWarner.kick.setValue(False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -38,7 +38,7 @@ class SchedulerTestCase(ChannelPluginTestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
schedule.schedule.reset()
|
schedule.schedule.reset()
|
||||||
ChannelPluginTestCase.tearDown(self)
|
ChannelPluginTestCase.tearDown(self)
|
||||||
|
|
||||||
def testAddRemove(self):
|
def testAddRemove(self):
|
||||||
self.assertRegexp('scheduler list', 'no.*commands')
|
self.assertRegexp('scheduler list', 'no.*commands')
|
||||||
m = self.assertNotError('scheduler add 5 echo testAddRemove')
|
m = self.assertNotError('scheduler add 5 echo testAddRemove')
|
||||||
|
@ -143,7 +143,7 @@ if network:
|
|||||||
'func=detail&aid=400942&group_id=235&'
|
'func=detail&aid=400942&group_id=235&'
|
||||||
'atid=390395',
|
'atid=390395',
|
||||||
s)
|
s)
|
||||||
|
|
||||||
# test that it works without index.php
|
# test that it works without index.php
|
||||||
self.assertNotError('http://sourceforge.net/tracker/?'
|
self.assertNotError('http://sourceforge.net/tracker/?'
|
||||||
'func=detail&aid=540223&group_id=235&'
|
'func=detail&aid=540223&group_id=235&'
|
||||||
|
@ -65,7 +65,7 @@ https://sourceforge.net/projects/pyrelaychecker/
|
|||||||
http://gameknot.com/tsignup.pl
|
http://gameknot.com/tsignup.pl
|
||||||
http://lambda.weblogs.com/xml/rss.xml
|
http://lambda.weblogs.com/xml/rss.xml
|
||||||
""".strip().splitlines()
|
""".strip().splitlines()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sqlite
|
import sqlite
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -77,7 +77,7 @@ if sqlite is not None:
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
ChannelPluginTestCase.setUp(self)
|
ChannelPluginTestCase.setUp(self)
|
||||||
conf.supybot.plugins.URL.tinyurlSnarfer.setValue(False)
|
conf.supybot.plugins.URL.tinyurlSnarfer.setValue(False)
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
counter = 0
|
counter = 0
|
||||||
self.assertNotError('url random')
|
self.assertNotError('url random')
|
||||||
|
@ -65,6 +65,6 @@ if os.name == 'posix':
|
|||||||
def testFortune(self):
|
def testFortune(self):
|
||||||
self.assertNotError('fortune')
|
self.assertNotError('fortune')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -45,7 +45,7 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
## self.assertNotError('register foo bar')
|
## self.assertNotError('register foo bar')
|
||||||
## self.prefix = original
|
## self.prefix = original
|
||||||
## self.assertRegexp('hostmasks foo', 'only.*your.*own')
|
## self.assertRegexp('hostmasks foo', 'only.*your.*own')
|
||||||
|
|
||||||
def testRegisterUnregister(self):
|
def testRegisterUnregister(self):
|
||||||
self.prefix = self.prefix1
|
self.prefix = self.prefix1
|
||||||
self.assertNotError('register foo bar')
|
self.assertNotError('register foo bar')
|
||||||
@ -75,7 +75,7 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertNotError('register Foo bar')
|
self.assertNotError('register Foo bar')
|
||||||
self.assertResponse('user list', 'Foo')
|
self.assertResponse('user list', 'Foo')
|
||||||
self.assertResponse('user list f*', 'Foo')
|
self.assertResponse('user list f*', 'Foo')
|
||||||
|
|
||||||
def testChangeUsername(self):
|
def testChangeUsername(self):
|
||||||
self.prefix = self.prefix1
|
self.prefix = self.prefix1
|
||||||
self.assertNotError('register foo bar')
|
self.assertNotError('register foo bar')
|
||||||
@ -93,7 +93,7 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertEqual(ircdb.users.getUser(self.prefix).password, 'baz')
|
self.assertEqual(ircdb.users.getUser(self.prefix).password, 'baz')
|
||||||
self.assertNotError('setpassword --hashed foo baz biff')
|
self.assertNotError('setpassword --hashed foo baz biff')
|
||||||
self.assertNotEqual(ircdb.users.getUser(self.prefix).password, 'biff')
|
self.assertNotEqual(ircdb.users.getUser(self.prefix).password, 'biff')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class UtilitiesTestCase(PluginTestCase):
|
|||||||
|
|
||||||
def testLast(self):
|
def testLast(self):
|
||||||
self.assertResponse('utilities last foo bar baz', 'baz')
|
self.assertResponse('utilities last foo bar baz', 'baz')
|
||||||
|
|
||||||
def testStrjoin(self):
|
def testStrjoin(self):
|
||||||
self.assertResponse('strjoin + foo bar baz', 'foo+bar+baz')
|
self.assertResponse('strjoin + foo bar baz', 'foo+bar+baz')
|
||||||
|
|
||||||
|
@ -129,13 +129,13 @@ class TokenizerTestCase(SupyTestCase):
|
|||||||
self.assertEqual(tokenize(s), [s])
|
self.assertEqual(tokenize(s), [s])
|
||||||
s = s[:-1] + '\x0f'
|
s = s[:-1] + '\x0f'
|
||||||
self.assertEqual(tokenize(s), [s])
|
self.assertEqual(tokenize(s), [s])
|
||||||
|
|
||||||
def testColor(self):
|
def testColor(self):
|
||||||
s = '\x032,3foo\x03'
|
s = '\x032,3foo\x03'
|
||||||
self.assertEqual(tokenize(s), [s])
|
self.assertEqual(tokenize(s), [s])
|
||||||
s = s[:-1] + '\x0f'
|
s = s[:-1] + '\x0f'
|
||||||
self.assertEqual(tokenize(s), [s])
|
self.assertEqual(tokenize(s), [s])
|
||||||
|
|
||||||
|
|
||||||
class FunctionsTestCase(SupyTestCase):
|
class FunctionsTestCase(SupyTestCase):
|
||||||
def testCanonicalName(self):
|
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('foo'), ['foo'])
|
self.assertEqual(callbacks.tokenize('foo'), ['foo'])
|
||||||
self.assertEqual(callbacks.tokenize('bar [baz]'), ['bar', ['baz']])
|
self.assertEqual(callbacks.tokenize('bar [baz]'), ['bar', ['baz']])
|
||||||
|
|
||||||
|
|
||||||
class PrivmsgTestCase(ChannelPluginTestCase):
|
class PrivmsgTestCase(ChannelPluginTestCase):
|
||||||
plugins = ('Utilities', 'Misc')
|
plugins = ('Utilities', 'Misc')
|
||||||
@ -295,7 +295,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
self.failIf(ircutils.isChannel(m.args[0]))
|
self.failIf(ircutils.isChannel(m.args[0]))
|
||||||
finally:
|
finally:
|
||||||
conf.supybot.reply.errorInPrivate.set(original)
|
conf.supybot.reply.errorInPrivate.set(original)
|
||||||
|
|
||||||
# Now for stuff not based on the plugins.
|
# Now for stuff not based on the plugins.
|
||||||
class First(callbacks.Privmsg):
|
class First(callbacks.Privmsg):
|
||||||
def firstcmd(self, irc, msg, args):
|
def firstcmd(self, irc, msg, args):
|
||||||
@ -347,7 +347,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
self.irc.addCallback(self.First())
|
self.irc.addCallback(self.First())
|
||||||
self.irc.addCallback(self.FirstRepeat())
|
self.irc.addCallback(self.FirstRepeat())
|
||||||
self.assertError('help first')
|
self.assertError('help first')
|
||||||
|
|
||||||
def testHelpDispatching(self):
|
def testHelpDispatching(self):
|
||||||
self.irc.addCallback(self.First())
|
self.irc.addCallback(self.First())
|
||||||
self.assertHelp('help firstcmd')
|
self.assertHelp('help firstcmd')
|
||||||
@ -413,7 +413,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
def invalidCommand(self, irc, msg, tokens):
|
def invalidCommand(self, irc, msg, tokens):
|
||||||
s = 'This shouldn\'t keep Misc.invalidCommand from being called'
|
s = 'This shouldn\'t keep Misc.invalidCommand from being called'
|
||||||
raise Exception, s
|
raise Exception, s
|
||||||
|
|
||||||
def testBadInvalidCommandDoesNotKillAll(self):
|
def testBadInvalidCommandDoesNotKillAll(self):
|
||||||
try:
|
try:
|
||||||
original = str(conf.supybot.reply.whenNotCommand)
|
original = str(conf.supybot.reply.whenNotCommand)
|
||||||
@ -422,7 +422,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
self.assertRegexp('asdfjkl', 'not a valid command')
|
self.assertRegexp('asdfjkl', 'not a valid command')
|
||||||
finally:
|
finally:
|
||||||
conf.supybot.reply.whenNotCommand.set(original)
|
conf.supybot.reply.whenNotCommand.set(original)
|
||||||
|
|
||||||
|
|
||||||
class PrivmsgCommandAndRegexpTestCase(PluginTestCase):
|
class PrivmsgCommandAndRegexpTestCase(PluginTestCase):
|
||||||
plugins = ()
|
plugins = ()
|
||||||
|
@ -90,7 +90,7 @@ class FunctionsTest(SupyTestCase):
|
|||||||
def testRsplit(self):
|
def testRsplit(self):
|
||||||
self.assertEqual(rsplit('foo bar baz'), 'foo bar baz'.split())
|
self.assertEqual(rsplit('foo bar baz'), 'foo bar baz'.split())
|
||||||
self.assertEqual(rsplit('foo bar baz', maxsplit=1),
|
self.assertEqual(rsplit('foo bar baz', maxsplit=1),
|
||||||
['foo bar', 'baz'])
|
['foo bar', 'baz'])
|
||||||
self.assertEqual(rsplit('foo bar baz', maxsplit=1),
|
self.assertEqual(rsplit('foo bar baz', maxsplit=1),
|
||||||
['foo bar', 'baz'])
|
['foo bar', 'baz'])
|
||||||
self.assertEqual(rsplit('foobarbaz', 'bar'), ['foo', 'baz'])
|
self.assertEqual(rsplit('foobarbaz', 'bar'), ['foo', 'baz'])
|
||||||
|
@ -53,7 +53,7 @@ class IrcMsgQueueTestCase(SupyTestCase):
|
|||||||
def testInit(self):
|
def testInit(self):
|
||||||
q = irclib.IrcMsgQueue([self.msg, self.topic, self.ping])
|
q = irclib.IrcMsgQueue([self.msg, self.topic, self.ping])
|
||||||
self.assertEqual(len(q), 3)
|
self.assertEqual(len(q), 3)
|
||||||
|
|
||||||
def testLen(self):
|
def testLen(self):
|
||||||
q = irclib.IrcMsgQueue()
|
q = irclib.IrcMsgQueue()
|
||||||
q.enqueue(self.msg)
|
q.enqueue(self.msg)
|
||||||
@ -262,7 +262,7 @@ class IrcStateTestCase(SupyTestCase):
|
|||||||
st.addMsg(self.irc, ircmsgs.quit(prefix='foo!bar@baz'))
|
st.addMsg(self.irc, ircmsgs.quit(prefix='foo!bar@baz'))
|
||||||
self.failIf('foo' in st.channels['#foo'].users)
|
self.failIf('foo' in st.channels['#foo'].users)
|
||||||
self.failUnless('foo' in st2.channels['#foo'].users)
|
self.failUnless('foo' in st2.channels['#foo'].users)
|
||||||
|
|
||||||
|
|
||||||
def testEq(self):
|
def testEq(self):
|
||||||
state1 = irclib.IrcState()
|
state1 = irclib.IrcState()
|
||||||
@ -314,7 +314,7 @@ class IrcTestCase(SupyTestCase):
|
|||||||
|
|
||||||
def test433Response(self):
|
def test433Response(self):
|
||||||
# This is necessary; it won't change nick if irc.originalName==irc.nick
|
# 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.feedMsg(ircmsgs.IrcMsg('433 * %s :Nickname already in use.' %\
|
||||||
self.irc.nick))
|
self.irc.nick))
|
||||||
msg = self.irc.takeMsg()
|
msg = self.irc.takeMsg()
|
||||||
|
@ -54,7 +54,7 @@ class FunctionsTestCase(SupyTestCase):
|
|||||||
s = 'jamessan|work!~jamessan@209-6-166-196.c3-0.' \
|
s = 'jamessan|work!~jamessan@209-6-166-196.c3-0.' \
|
||||||
'abr-ubr1.sbo-abr.ma.cable.rcn.com'
|
'abr-ubr1.sbo-abr.ma.cable.rcn.com'
|
||||||
self.failUnless(ircutils.hostmaskPatternEqual(s, s))
|
self.failUnless(ircutils.hostmaskPatternEqual(s, s))
|
||||||
|
|
||||||
def testIsUserHostmask(self):
|
def testIsUserHostmask(self):
|
||||||
self.failUnless(ircutils.isUserHostmask(self.hostmask))
|
self.failUnless(ircutils.isUserHostmask(self.hostmask))
|
||||||
self.failUnless(ircutils.isUserHostmask('a!b@c'))
|
self.failUnless(ircutils.isUserHostmask('a!b@c'))
|
||||||
@ -237,7 +237,7 @@ class FunctionsTestCase(SupyTestCase):
|
|||||||
for _ in range(100): # 100 should be good :)
|
for _ in range(100): # 100 should be good :)
|
||||||
ip = randomIP()
|
ip = randomIP()
|
||||||
self.assertEqual(ip, ircutils.unDccIP(ircutils.dccIP(ip)))
|
self.assertEqual(ip, ircutils.unDccIP(ircutils.dccIP(ip)))
|
||||||
|
|
||||||
|
|
||||||
class IrcDictTestCase(SupyTestCase):
|
class IrcDictTestCase(SupyTestCase):
|
||||||
def test(self):
|
def test(self):
|
||||||
|
@ -82,12 +82,12 @@ class FunctionsTestCase(SupyTestCase):
|
|||||||
self.failIf(all(L[0].__eq__, L), 'all $randomnicks were the same')
|
self.failIf(all(L[0].__eq__, L), 'all $randomnicks were the same')
|
||||||
c = plugins.standardSubstitute(self.irc, msg, '$channel')
|
c = plugins.standardSubstitute(self.irc, msg, '$channel')
|
||||||
self.assertEqual(c, msg.args[0])
|
self.assertEqual(c, msg.args[0])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class UrlSnarferTestCase(PluginTestCase):
|
|||||||
self.FCalled = False
|
self.FCalled = False
|
||||||
self.GCalled = False
|
self.GCalled = False
|
||||||
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||||
|
|
||||||
def F(self, irc, msg, match):
|
def F(self, irc, msg, match):
|
||||||
r"."
|
r"."
|
||||||
self.FCalled = True
|
self.FCalled = True
|
||||||
|
@ -131,6 +131,6 @@ class ValuesTestCase(SupyTestCase):
|
|||||||
self.assertEqual(v(), None)
|
self.assertEqual(v(), None)
|
||||||
self.assertRaises(registry.InvalidRegistryValue,
|
self.assertRaises(registry.InvalidRegistryValue,
|
||||||
v.setValue, re.compile(r'foo'))
|
v.setValue, re.compile(r'foo'))
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -205,7 +205,7 @@ class QueueTest(SupyTestCase):
|
|||||||
self.assertEqual(len(q), 1)
|
self.assertEqual(len(q), 1)
|
||||||
q.reset()
|
q.reset()
|
||||||
self.assertEqual(len(q), 0)
|
self.assertEqual(len(q), 0)
|
||||||
|
|
||||||
def testGetitem(self):
|
def testGetitem(self):
|
||||||
q = queue()
|
q = queue()
|
||||||
n = 10
|
n = 10
|
||||||
@ -370,7 +370,7 @@ class SmallQueueTest(SupyTestCase):
|
|||||||
self.assertEqual(len(q), 1)
|
self.assertEqual(len(q), 1)
|
||||||
q.reset()
|
q.reset()
|
||||||
self.assertEqual(len(q), 0)
|
self.assertEqual(len(q), 0)
|
||||||
|
|
||||||
def testGetitem(self):
|
def testGetitem(self):
|
||||||
q = queue()
|
q = queue()
|
||||||
n = 10
|
n = 10
|
||||||
@ -599,7 +599,7 @@ class PersistentDictionaryTestCase(SupyTestCase):
|
|||||||
d2 = PersistentDictionary('test.dict')
|
d2 = PersistentDictionary('test.dict')
|
||||||
self.failUnless(1 in d2)
|
self.failUnless(1 in d2)
|
||||||
self.assertEqual(d2[1], 2)
|
self.assertEqual(d2[1], 2)
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# 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