mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Convert not to care how long its messages are.
This commit is contained in:
parent
757154313e
commit
b68908ed00
@ -178,14 +178,7 @@ class Factoids(ChannelDBHandler, callbacks.Privmsg):
|
||||
for result in cursor.fetchall():
|
||||
factoids.append('(#%s) %s' % (counter, result[0]))
|
||||
counter += 1
|
||||
totalResults = len(factoids)
|
||||
if ircutils.shrinkList(factoids, ', or ', 400):
|
||||
s = '%s could be %s (%s shown out of %s)' % \
|
||||
(key, ', or '.join(factoids),
|
||||
utils.nItems(len(factoids), 'result'), totalResults)
|
||||
else:
|
||||
s = '%s could be %s' % (key, ', or '.join(factoids))
|
||||
irc.reply(msg, s)
|
||||
irc.reply(msg, '%r could be %s' % (key, ', or '.join(factoids)))
|
||||
|
||||
def lock(self, irc, msg, args):
|
||||
"""[<channel>] <key>
|
||||
@ -289,14 +282,14 @@ class Factoids(ChannelDBHandler, callbacks.Privmsg):
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""SELECT fact, key_id FROM factoids
|
||||
ORDER BY random()
|
||||
LIMIT 10""")
|
||||
LIMIT 3""")
|
||||
if cursor.rowcount != 0:
|
||||
L = []
|
||||
for (factoid, id) in cursor.fetchall():
|
||||
cursor.execute("""SELECT key FROM keys WHERE id=%s""", id)
|
||||
(key,) = cursor.fetchone()
|
||||
L.append('"%s": %s' % (ircutils.bold(key), factoid))
|
||||
irc.reply(msg, ircutils.privmsgPayload(L, '; ', 400))
|
||||
irc.reply(msg, '; '.join(L))
|
||||
else:
|
||||
irc.error(msg, 'I couldn\'t find a factoid.')
|
||||
|
||||
|
@ -180,7 +180,7 @@ class FunDB(callbacks.Privmsg):
|
||||
lenSoFar += len(s)
|
||||
counter -= 1
|
||||
L.append(s)
|
||||
irc.reply(msg, ircutils.privmsgPayload(L, '; '))
|
||||
irc.reply(msg, '; '.join(L))
|
||||
|
||||
def insult(self, irc, msg, args):
|
||||
"""<nick>
|
||||
@ -551,11 +551,7 @@ class FunDB(callbacks.Privmsg):
|
||||
irc.reply(msg, str(cursor.fetchone()[0]))
|
||||
else:
|
||||
zipcodes = [str(t[0]) for t in cursor.fetchall()]
|
||||
ircutils.shrinkList(zipcodes, ', ', 400)
|
||||
if len(zipcodes) < cursor.rowcount:
|
||||
random.shuffle(zipcodes)
|
||||
irc.reply(msg, '(%s shown of %s): %s' % \
|
||||
(len(zipcodes), cursor.rowcount, ', '.join(zipcodes)))
|
||||
irc.reply(msg, utils.commaAndify(zipcodes))
|
||||
|
||||
Class = FunDB
|
||||
|
||||
|
@ -372,7 +372,7 @@ class Http(callbacks.Privmsg):
|
||||
if len(defs) == 0:
|
||||
irc.reply(msg, 'No definitions found.')
|
||||
else:
|
||||
s = ircutils.privmsgPayload(defs, ', or ')
|
||||
s = ', or '.join(defs)
|
||||
irc.reply(msg, '%s could be %s' % (acronym, s))
|
||||
|
||||
_netcraftre = re.compile(r'whatos text -->(.*?)<a href="/up/acc', re.S)
|
||||
|
@ -105,10 +105,7 @@ class IMDB(callbacks.Privmsg):
|
||||
titles = ['%s (%s)' % \
|
||||
(utils.unCommaThe(movie.title()), movie.year())
|
||||
for movie in movies]
|
||||
if ircutils.shrinkList(titles, ', ', 425):
|
||||
irc.reply(msg, '%s movies matched, please narrow your search')
|
||||
else:
|
||||
irc.reply(msg, 'Matches: ' + utils.commaAndify(titles))
|
||||
irc.reply(msg, 'Matches: ' + utils.commaAndify(titles))
|
||||
|
||||
|
||||
Class = IMDB
|
||||
|
@ -252,7 +252,6 @@ class Notes(callbacks.Privmsg):
|
||||
count = cursor.rowcount
|
||||
notes = cursor.fetchall()
|
||||
L = []
|
||||
more = False
|
||||
if count == 0:
|
||||
irc.reply(msg, 'You have no unread notes.')
|
||||
else:
|
||||
@ -263,12 +262,7 @@ class Notes(callbacks.Privmsg):
|
||||
L.append(r'#%s from %s' % (id, sender))
|
||||
else:
|
||||
L.append(r'#%s (private)' % id)
|
||||
if more:
|
||||
ircutils.shrinkList(L, ', ', 400)
|
||||
L.append('and even more notes.')
|
||||
else:
|
||||
ircutils.shrinkList(L, ', ', 450)
|
||||
irc.reply(msg, ', '.join(L))
|
||||
irc.reply(msg, utils.commaAndify(L))
|
||||
|
||||
def oldnotes(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
@ -290,9 +284,7 @@ class Notes(callbacks.Privmsg):
|
||||
else:
|
||||
ids = [str(t[0]) for t in cursor.fetchall()]
|
||||
ids.reverse()
|
||||
ircutils.shrinkList(ids, ', ', 425)
|
||||
ids.reverse()
|
||||
irc.reply(msg, ', '.join(ids))
|
||||
irc.reply(msg, utils.commaAndify(ids))
|
||||
|
||||
|
||||
|
||||
|
@ -108,7 +108,7 @@ class RSS(callbacks.Privmsg):
|
||||
if not headlines:
|
||||
irc.error(msg, 'Error grabbing RSS feed')
|
||||
return
|
||||
irc.reply(msg, ' :: '.join(headlines)
|
||||
irc.reply(msg, ' :: '.join(headlines))
|
||||
|
||||
def rssinfo(self, irc, msg, args):
|
||||
"""<url>
|
||||
|
@ -267,7 +267,7 @@ class URLSnarfer(callbacks.Privmsg, ChannelDBHandler):
|
||||
else:
|
||||
if nolimit:
|
||||
urls = ['<%s>' % t[0] for t in cursor.fetchall()]
|
||||
s = ircutils.privmsgPayload(urls, ', ', 400)
|
||||
s = ', '.join(urls)
|
||||
elif simple:
|
||||
s = cursor.fetchone()[0]
|
||||
else:
|
||||
|
@ -204,12 +204,8 @@ class Unix(callbacks.Privmsg):
|
||||
resp = 'Could not find an alternate spelling for "%s"' % word
|
||||
elif line[0] == '&':
|
||||
matches = line.split(':')[1].strip()
|
||||
match_list = matches.split(', ')
|
||||
total = len(match_list)
|
||||
ircutils.shrinkList(match_list, ', ', 350)
|
||||
shown = len(match_list)
|
||||
resp = 'Possible spellings for "%s" (%d found, %d shown): %s.' % \
|
||||
(word, total, shown, ', '.join(match_list))
|
||||
resp = 'Possible spellings for %r: %s.' % \
|
||||
(word, utils.commaAndify(matches.split(', ')))
|
||||
else:
|
||||
resp = 'Something unexpected was seen in the [ai]spell output.'
|
||||
irc.reply(msg, resp)
|
||||
|
Loading…
Reference in New Issue
Block a user