mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 12:49:24 +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,
|
||||
doc=method._fake__doc__ % (s, s),
|
||||
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):
|
||||
db = self.getDb(channel)
|
||||
@ -328,7 +328,9 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
||||
counter = 0
|
||||
for (added_by, added_at) in factoids:
|
||||
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))
|
||||
factoids = '; '.join(L)
|
||||
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):
|
||||
db = self._getDb(channel)
|
||||
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))
|
||||
sql = """SELECT name, added-subtracted FROM karma
|
||||
WHERE %s ORDER BY added-subtracted DESC""" % criteria
|
||||
|
@ -1,5 +1,6 @@
|
||||
###
|
||||
# Copyright (c) 2004, Daniel DiPaolo
|
||||
# Copyright (c) 2008, James Vega
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -50,11 +51,9 @@ class QuoteGrabsRecord(dbi.Record):
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
at = time.strftime(conf.supybot.reply.format.time(),
|
||||
time.localtime(float(self.at)))
|
||||
grabber = plugins.getUserName(self.grabber)
|
||||
return '%s (Said by: %s; grabbed by %s at %s)' % \
|
||||
(self.text, self.hostmask, grabber, at)
|
||||
return format('%s (Said by: %s; grabbed by %s at %t)',
|
||||
self.text, self.hostmask, grabber, self.at)
|
||||
|
||||
class SqliteQuoteGrabsDB(object):
|
||||
def __init__(self, filename):
|
||||
@ -152,8 +151,7 @@ class SqliteQuoteGrabsDB(object):
|
||||
raise dbi.NoRecordError
|
||||
return cursor.fetchone()[0]
|
||||
|
||||
def add(self, msg, by):
|
||||
channel = msg.args[0]
|
||||
def add(self, channel, msg, by):
|
||||
db = self._getDb(channel)
|
||||
cursor = db.cursor()
|
||||
text = ircmsgs.prettyPrint(msg)
|
||||
@ -193,29 +191,27 @@ class QuoteGrabs(callbacks.Plugin):
|
||||
def doPrivmsg(self, irc, msg):
|
||||
irc = callbacks.SimpleProxy(irc, msg)
|
||||
if irc.isChannel(msg.args[0]):
|
||||
(channel, payload) = msg.args
|
||||
words = self.registryValue('randomGrabber.minimumWords',
|
||||
channel)
|
||||
length = self.registryValue('randomGrabber.minimumCharacters',
|
||||
channel)
|
||||
(chan, payload) = msg.args
|
||||
words = self.registryValue('randomGrabber.minimumWords', chan)
|
||||
length = self.registryValue('randomGrabber.minimumCharacters',chan)
|
||||
grabTime = \
|
||||
self.registryValue('randomGrabber.averageTimeBetweenGrabs',
|
||||
channel)
|
||||
if self.registryValue('randomGrabber', channel):
|
||||
self.registryValue('randomGrabber.averageTimeBetweenGrabs', chan)
|
||||
channel = plugins.getChannel(chan)
|
||||
if self.registryValue('randomGrabber', chan):
|
||||
if len(payload) > length and len(payload.split()) > words:
|
||||
try:
|
||||
last = int(self.db.select(channel, msg.nick))
|
||||
except dbi.NoRecordError:
|
||||
self._grab(irc, msg, irc.prefix)
|
||||
self._grab(irc, channel, msg, irc.prefix)
|
||||
self._sendGrabMsg(irc, msg)
|
||||
else:
|
||||
elapsed = int(time.time()) - last
|
||||
if random.random()*elapsed > grabTime/2:
|
||||
self._grab(irc, msg, irc.prefix)
|
||||
if (random.random() * elapsed) > (grabTime / 2):
|
||||
self._grab(channel, irc, msg, irc.prefix)
|
||||
self._sendGrabMsg(irc, msg)
|
||||
|
||||
def _grab(self, irc, msg, addedBy):
|
||||
self.db.add(msg, addedBy)
|
||||
def _grab(self, channel, irc, msg, addedBy):
|
||||
self.db.add(channel, msg, addedBy)
|
||||
|
||||
def _sendGrabMsg(self, irc, msg):
|
||||
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):
|
||||
if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick) \
|
||||
and ircutils.strEqual(m.args[0], chan):
|
||||
self._grab(irc, m, msg.prefix)
|
||||
self._grab(channel, irc, m, msg.prefix)
|
||||
irc.replySuccess()
|
||||
return
|
||||
irc.error('I couldn\'t find a proper message to grab.')
|
||||
|
@ -1,5 +1,6 @@
|
||||
###
|
||||
# Copyright (c) 2004, Daniel DiPaolo
|
||||
# Copyright (c) 2008, James Vega
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -52,28 +53,28 @@ class QuoteGrabsTestCase(ChannelPluginTestCase):
|
||||
|
||||
def testList(self):
|
||||
testPrefix = 'foo!bar@baz'
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testList',
|
||||
prefix=testPrefix))
|
||||
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,
|
||||
prefix=testPrefix))
|
||||
self.assertNotError('grab foo')
|
||||
self.assertResponse('quotegrabs list foo',
|
||||
'#2: %s... and #1: test' %\
|
||||
'#2: %s... and #1: testList' %\
|
||||
('a'*43)) # 50 - length of "#2: ..."
|
||||
|
||||
def testDuplicateGrabs(self):
|
||||
testPrefix = 'foo!bar@baz'
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testDupe',
|
||||
prefix=testPrefix))
|
||||
self.assertNotError('grab foo')
|
||||
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):
|
||||
testPrefix = 'foo!bar@baz'
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testCI',
|
||||
prefix=testPrefix))
|
||||
self.assertNotError('grab FOO')
|
||||
self.assertNotError('quote foo')
|
||||
@ -85,26 +86,26 @@ class QuoteGrabsTestCase(ChannelPluginTestCase):
|
||||
def testRandom(self):
|
||||
testPrefix = 'foo!bar@baz'
|
||||
self.assertError('random')
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testRandom',
|
||||
prefix=testPrefix))
|
||||
self.assertError('random') # still none in the db
|
||||
self.assertNotError('grab foo')
|
||||
self.assertResponse('random', '<foo> test')
|
||||
self.assertResponse('random foo', '<foo> test')
|
||||
self.assertResponse('random FOO', '<foo> test')
|
||||
self.assertResponse('random', '<foo> testRandom')
|
||||
self.assertResponse('random foo', '<foo> testRandom')
|
||||
self.assertResponse('random FOO', '<foo> testRandom')
|
||||
|
||||
def testGet(self):
|
||||
testPrefix= 'foo!bar@baz'
|
||||
self.assertError('quotegrabs get asdf')
|
||||
self.assertError('quotegrabs get 1')
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testGet',
|
||||
prefix=testPrefix))
|
||||
self.assertNotError('grab foo')
|
||||
self.assertNotError('quotegrabs get 1')
|
||||
|
||||
def testSearch(self):
|
||||
testPrefix= 'foo!bar@baz'
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'testSearch',
|
||||
prefix=testPrefix))
|
||||
self.assertError('quotegrabs search test') # still none in db
|
||||
self.assertNotError('grab foo')
|
||||
|
@ -123,7 +123,7 @@ def main():
|
||||
log.info('Total CPU time taken: %s seconds.', user+system)
|
||||
log.info('No more Irc objects, exiting.')
|
||||
|
||||
version = '0.83.3+svn'
|
||||
version = '0.83.3'
|
||||
if __name__ == '__main__':
|
||||
###
|
||||
# Options:
|
||||
|
2
setup.py
2
setup.py
@ -151,7 +151,7 @@ package_dir = {'supybot': 'src',
|
||||
for plugin in plugins:
|
||||
package_dir['supybot.plugins.' + plugin] = 'plugins/' + plugin
|
||||
|
||||
version = '0.83.3+svn'
|
||||
version = '0.83.3'
|
||||
setup(
|
||||
# Metadata
|
||||
name='supybot',
|
||||
|
@ -43,7 +43,7 @@ _pluginsDir = os.path.join(installDir, 'plugins')
|
||||
###
|
||||
# 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
|
||||
|
@ -65,15 +65,17 @@ def expect(prompt, possibilities, recursed=False, default=None,
|
||||
if len(prompt) > 70:
|
||||
prompt = '%s %s' % (originalPrompt, choices % '/ '.join(possibilities))
|
||||
if default is not None:
|
||||
if useBold:
|
||||
prompt = '%s %s(default: %s)' % (prompt, ansi.RESET, default)
|
||||
else:
|
||||
prompt = '%s (default: %s)' % (prompt, default)
|
||||
prompt = textwrap.fill(prompt)
|
||||
prompt = prompt.replace('/ ', '/')
|
||||
prompt = prompt.strip() + ' '
|
||||
if useBold:
|
||||
prompt += ansi.RESET
|
||||
print >>fd, ansi.BOLD,
|
||||
s = raw_input(prompt)
|
||||
if useBold:
|
||||
print >>fd, ansi.RESET
|
||||
s = s.strip()
|
||||
print >>fd
|
||||
if possibilities:
|
||||
@ -125,11 +127,10 @@ def getpass(prompt='Enter password: ', secondPrompt='Re-enter password: '):
|
||||
prompt += ' '
|
||||
while True:
|
||||
if useBold:
|
||||
prompt += ansi.RESET
|
||||
sys.stdout.write(ansi.BOLD)
|
||||
password = getPass(prompt)
|
||||
secondPassword = getPass(secondPrompt)
|
||||
if useBold:
|
||||
print ansi.RESET
|
||||
if password != secondPassword:
|
||||
output('Passwords don\'t match.')
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user