mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Add .gitignore
Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
parent
4de0bb31f9
commit
46a4076988
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
build
|
||||||
|
test-data
|
||||||
|
test-conf
|
||||||
|
test-logs
|
@ -110,7 +110,7 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
return help(method,
|
return help(method,
|
||||||
doc=method._fake__doc__ % (s, s),
|
doc=method._fake__doc__ % (s, s),
|
||||||
name=callbacks.formatCommand(command))
|
name=callbacks.formatCommand(command))
|
||||||
return self.__parent.getCommandHelp(command)
|
return super(Factoids, self).getCommandHelp(self, command)
|
||||||
|
|
||||||
def learn(self, irc, msg, args, channel, key, factoid):
|
def learn(self, irc, msg, args, channel, key, factoid):
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
@ -328,7 +328,9 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
counter = 0
|
counter = 0
|
||||||
for (added_by, added_at) in factoids:
|
for (added_by, added_at) in factoids:
|
||||||
counter += 1
|
counter += 1
|
||||||
L.append(format('#%i was added by %s at %t',
|
added_at = time.strftime(conf.supybot.reply.format.time(),
|
||||||
|
time.localtime(int(added_at)))
|
||||||
|
L.append(format('#%i was added by %s at %s',
|
||||||
counter, added_by, added_at))
|
counter, added_by, added_at))
|
||||||
factoids = '; '.join(L)
|
factoids = '; '.join(L)
|
||||||
s = format('Key %q is %s and has %n associated with it: %s',
|
s = format('Key %q is %s and has %n associated with it: %s',
|
||||||
|
@ -90,7 +90,7 @@ class SqliteKarmaDB(object):
|
|||||||
def gets(self, channel, things):
|
def gets(self, channel, things):
|
||||||
db = self._getDb(channel)
|
db = self._getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
normalizedThings = dict(zip(map(str.lower, things), things))
|
normalizedThings = dict(zip(map(lambda s: s.lower(), things), things))
|
||||||
criteria = ' OR '.join(['normalized=%s'] * len(normalizedThings))
|
criteria = ' OR '.join(['normalized=%s'] * len(normalizedThings))
|
||||||
sql = """SELECT name, added-subtracted FROM karma
|
sql = """SELECT name, added-subtracted FROM karma
|
||||||
WHERE %s ORDER BY added-subtracted DESC""" % criteria
|
WHERE %s ORDER BY added-subtracted DESC""" % criteria
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2004, Daniel DiPaolo
|
# Copyright (c) 2004, Daniel DiPaolo
|
||||||
|
# Copyright (c) 2008, James Vega
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -50,11 +51,9 @@ class QuoteGrabsRecord(dbi.Record):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
at = time.strftime(conf.supybot.reply.format.time(),
|
|
||||||
time.localtime(float(self.at)))
|
|
||||||
grabber = plugins.getUserName(self.grabber)
|
grabber = plugins.getUserName(self.grabber)
|
||||||
return '%s (Said by: %s; grabbed by %s at %s)' % \
|
return format('%s (Said by: %s; grabbed by %s at %t)',
|
||||||
(self.text, self.hostmask, grabber, at)
|
self.text, self.hostmask, grabber, self.at)
|
||||||
|
|
||||||
class SqliteQuoteGrabsDB(object):
|
class SqliteQuoteGrabsDB(object):
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
@ -152,8 +151,7 @@ class SqliteQuoteGrabsDB(object):
|
|||||||
raise dbi.NoRecordError
|
raise dbi.NoRecordError
|
||||||
return cursor.fetchone()[0]
|
return cursor.fetchone()[0]
|
||||||
|
|
||||||
def add(self, msg, by):
|
def add(self, channel, msg, by):
|
||||||
channel = msg.args[0]
|
|
||||||
db = self._getDb(channel)
|
db = self._getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
text = ircmsgs.prettyPrint(msg)
|
text = ircmsgs.prettyPrint(msg)
|
||||||
@ -193,29 +191,27 @@ class QuoteGrabs(callbacks.Plugin):
|
|||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
irc = callbacks.SimpleProxy(irc, msg)
|
irc = callbacks.SimpleProxy(irc, msg)
|
||||||
if irc.isChannel(msg.args[0]):
|
if irc.isChannel(msg.args[0]):
|
||||||
(channel, payload) = msg.args
|
(chan, payload) = msg.args
|
||||||
words = self.registryValue('randomGrabber.minimumWords',
|
words = self.registryValue('randomGrabber.minimumWords', chan)
|
||||||
channel)
|
length = self.registryValue('randomGrabber.minimumCharacters',chan)
|
||||||
length = self.registryValue('randomGrabber.minimumCharacters',
|
|
||||||
channel)
|
|
||||||
grabTime = \
|
grabTime = \
|
||||||
self.registryValue('randomGrabber.averageTimeBetweenGrabs',
|
self.registryValue('randomGrabber.averageTimeBetweenGrabs', chan)
|
||||||
channel)
|
channel = plugins.getChannel(chan)
|
||||||
if self.registryValue('randomGrabber', channel):
|
if self.registryValue('randomGrabber', chan):
|
||||||
if len(payload) > length and len(payload.split()) > words:
|
if len(payload) > length and len(payload.split()) > words:
|
||||||
try:
|
try:
|
||||||
last = int(self.db.select(channel, msg.nick))
|
last = int(self.db.select(channel, msg.nick))
|
||||||
except dbi.NoRecordError:
|
except dbi.NoRecordError:
|
||||||
self._grab(irc, msg, irc.prefix)
|
self._grab(irc, channel, msg, irc.prefix)
|
||||||
self._sendGrabMsg(irc, msg)
|
self._sendGrabMsg(irc, msg)
|
||||||
else:
|
else:
|
||||||
elapsed = int(time.time()) - last
|
elapsed = int(time.time()) - last
|
||||||
if random.random()*elapsed > grabTime/2:
|
if (random.random() * elapsed) > (grabTime / 2):
|
||||||
self._grab(irc, msg, irc.prefix)
|
self._grab(channel, irc, msg, irc.prefix)
|
||||||
self._sendGrabMsg(irc, msg)
|
self._sendGrabMsg(irc, msg)
|
||||||
|
|
||||||
def _grab(self, irc, msg, addedBy):
|
def _grab(self, channel, irc, msg, addedBy):
|
||||||
self.db.add(msg, addedBy)
|
self.db.add(channel, msg, addedBy)
|
||||||
|
|
||||||
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
|
||||||
@ -239,7 +235,7 @@ class QuoteGrabs(callbacks.Plugin):
|
|||||||
for m in reversed(irc.state.history):
|
for m in reversed(irc.state.history):
|
||||||
if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick) \
|
if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick) \
|
||||||
and ircutils.strEqual(m.args[0], chan):
|
and ircutils.strEqual(m.args[0], chan):
|
||||||
self._grab(irc, m, msg.prefix)
|
self._grab(channel, irc, m, msg.prefix)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
return
|
return
|
||||||
irc.error('I couldn\'t find a proper message to grab.')
|
irc.error('I couldn\'t find a proper message to grab.')
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2004, Daniel DiPaolo
|
# Copyright (c) 2004, Daniel DiPaolo
|
||||||
|
# Copyright (c) 2008, James Vega
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -52,28 +53,28 @@ class QuoteGrabsTestCase(ChannelPluginTestCase):
|
|||||||
|
|
||||||
def testList(self):
|
def testList(self):
|
||||||
testPrefix = 'foo!bar@baz'
|
testPrefix = 'foo!bar@baz'
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testList',
|
||||||
prefix=testPrefix))
|
prefix=testPrefix))
|
||||||
self.assertNotError('grab foo')
|
self.assertNotError('grab foo')
|
||||||
self.assertResponse('quotegrabs list foo', '#1: test')
|
self.assertResponse('quotegrabs list foo', '#1: testList')
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'a' * 80,
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'a' * 80,
|
||||||
prefix=testPrefix))
|
prefix=testPrefix))
|
||||||
self.assertNotError('grab foo')
|
self.assertNotError('grab foo')
|
||||||
self.assertResponse('quotegrabs list foo',
|
self.assertResponse('quotegrabs list foo',
|
||||||
'#2: %s... and #1: test' %\
|
'#2: %s... and #1: testList' %\
|
||||||
('a'*43)) # 50 - length of "#2: ..."
|
('a'*43)) # 50 - length of "#2: ..."
|
||||||
|
|
||||||
def testDuplicateGrabs(self):
|
def testDuplicateGrabs(self):
|
||||||
testPrefix = 'foo!bar@baz'
|
testPrefix = 'foo!bar@baz'
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testDupe',
|
||||||
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: testDupe')
|
||||||
|
|
||||||
def testCaseInsensitivity(self):
|
def testCaseInsensitivity(self):
|
||||||
testPrefix = 'foo!bar@baz'
|
testPrefix = 'foo!bar@baz'
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testCI',
|
||||||
prefix=testPrefix))
|
prefix=testPrefix))
|
||||||
self.assertNotError('grab FOO')
|
self.assertNotError('grab FOO')
|
||||||
self.assertNotError('quote foo')
|
self.assertNotError('quote foo')
|
||||||
@ -85,26 +86,26 @@ class QuoteGrabsTestCase(ChannelPluginTestCase):
|
|||||||
def testRandom(self):
|
def testRandom(self):
|
||||||
testPrefix = 'foo!bar@baz'
|
testPrefix = 'foo!bar@baz'
|
||||||
self.assertError('random')
|
self.assertError('random')
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testRandom',
|
||||||
prefix=testPrefix))
|
prefix=testPrefix))
|
||||||
self.assertError('random') # still none in the db
|
self.assertError('random') # still none in the db
|
||||||
self.assertNotError('grab foo')
|
self.assertNotError('grab foo')
|
||||||
self.assertResponse('random', '<foo> test')
|
self.assertResponse('random', '<foo> testRandom')
|
||||||
self.assertResponse('random foo', '<foo> test')
|
self.assertResponse('random foo', '<foo> testRandom')
|
||||||
self.assertResponse('random FOO', '<foo> test')
|
self.assertResponse('random FOO', '<foo> testRandom')
|
||||||
|
|
||||||
def testGet(self):
|
def testGet(self):
|
||||||
testPrefix= 'foo!bar@baz'
|
testPrefix= 'foo!bar@baz'
|
||||||
self.assertError('quotegrabs get asdf')
|
self.assertError('quotegrabs get asdf')
|
||||||
self.assertError('quotegrabs get 1')
|
self.assertError('quotegrabs get 1')
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testGet',
|
||||||
prefix=testPrefix))
|
prefix=testPrefix))
|
||||||
self.assertNotError('grab foo')
|
self.assertNotError('grab foo')
|
||||||
self.assertNotError('quotegrabs get 1')
|
self.assertNotError('quotegrabs get 1')
|
||||||
|
|
||||||
def testSearch(self):
|
def testSearch(self):
|
||||||
testPrefix= 'foo!bar@baz'
|
testPrefix= 'foo!bar@baz'
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testSearch',
|
||||||
prefix=testPrefix))
|
prefix=testPrefix))
|
||||||
self.assertError('quotegrabs search test') # still none in db
|
self.assertError('quotegrabs search test') # still none in db
|
||||||
self.assertNotError('grab foo')
|
self.assertNotError('grab foo')
|
||||||
|
@ -123,7 +123,7 @@ def main():
|
|||||||
log.info('Total CPU time taken: %s seconds.', user+system)
|
log.info('Total CPU time taken: %s seconds.', user+system)
|
||||||
log.info('No more Irc objects, exiting.')
|
log.info('No more Irc objects, exiting.')
|
||||||
|
|
||||||
version = '0.83.3+svn'
|
version = '0.83.3'
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
###
|
###
|
||||||
# Options:
|
# Options:
|
||||||
|
2
setup.py
2
setup.py
@ -151,7 +151,7 @@ package_dir = {'supybot': 'src',
|
|||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
package_dir['supybot.plugins.' + plugin] = 'plugins/' + plugin
|
package_dir['supybot.plugins.' + plugin] = 'plugins/' + plugin
|
||||||
|
|
||||||
version = '0.83.3+svn'
|
version = '0.83.3'
|
||||||
setup(
|
setup(
|
||||||
# Metadata
|
# Metadata
|
||||||
name='supybot',
|
name='supybot',
|
||||||
|
@ -43,7 +43,7 @@ _pluginsDir = os.path.join(installDir, 'plugins')
|
|||||||
###
|
###
|
||||||
# version: This should be pretty obvious.
|
# version: This should be pretty obvious.
|
||||||
###
|
###
|
||||||
version = '0.83.3+svn'
|
version = '0.83.3'
|
||||||
|
|
||||||
###
|
###
|
||||||
# *** The following variables are affected by command-line options. They are
|
# *** The following variables are affected by command-line options. They are
|
||||||
|
@ -65,15 +65,17 @@ def expect(prompt, possibilities, recursed=False, default=None,
|
|||||||
if len(prompt) > 70:
|
if len(prompt) > 70:
|
||||||
prompt = '%s %s' % (originalPrompt, choices % '/ '.join(possibilities))
|
prompt = '%s %s' % (originalPrompt, choices % '/ '.join(possibilities))
|
||||||
if default is not None:
|
if default is not None:
|
||||||
prompt = '%s (default: %s)' % (prompt, default)
|
if useBold:
|
||||||
|
prompt = '%s %s(default: %s)' % (prompt, ansi.RESET, default)
|
||||||
|
else:
|
||||||
|
prompt = '%s (default: %s)' % (prompt, default)
|
||||||
prompt = textwrap.fill(prompt)
|
prompt = textwrap.fill(prompt)
|
||||||
prompt = prompt.replace('/ ', '/')
|
prompt = prompt.replace('/ ', '/')
|
||||||
prompt = prompt.strip() + ' '
|
prompt = prompt.strip() + ' '
|
||||||
if useBold:
|
if useBold:
|
||||||
|
prompt += ansi.RESET
|
||||||
print >>fd, ansi.BOLD,
|
print >>fd, ansi.BOLD,
|
||||||
s = raw_input(prompt)
|
s = raw_input(prompt)
|
||||||
if useBold:
|
|
||||||
print >>fd, ansi.RESET
|
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
print >>fd
|
print >>fd
|
||||||
if possibilities:
|
if possibilities:
|
||||||
@ -125,11 +127,10 @@ def getpass(prompt='Enter password: ', secondPrompt='Re-enter password: '):
|
|||||||
prompt += ' '
|
prompt += ' '
|
||||||
while True:
|
while True:
|
||||||
if useBold:
|
if useBold:
|
||||||
|
prompt += ansi.RESET
|
||||||
sys.stdout.write(ansi.BOLD)
|
sys.stdout.write(ansi.BOLD)
|
||||||
password = getPass(prompt)
|
password = getPass(prompt)
|
||||||
secondPassword = getPass(secondPrompt)
|
secondPassword = getPass(secondPrompt)
|
||||||
if useBold:
|
|
||||||
print ansi.RESET
|
|
||||||
if password != secondPassword:
|
if password != secondPassword:
|
||||||
output('Passwords don\'t match.')
|
output('Passwords don\'t match.')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user