mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 14:10:41 +01:00
Just chop off the extra if everything is too big; also allow specification of the dictionary.
This commit is contained in:
parent
56e6fbd21c
commit
2e23c68afb
@ -717,7 +717,7 @@ class FunCommands(callbacks.Privmsg):
|
|||||||
s = eval(funcname + '.__doc__')
|
s = eval(funcname + '.__doc__')
|
||||||
s = s.replace('\n\n', '. ')
|
s = s.replace('\n\n', '. ')
|
||||||
s = ' '.join(s.split())
|
s = ' '.join(s.split())
|
||||||
except NameError:
|
except (SyntaxError, NameError):
|
||||||
irc.error(msg, 'No such function exists.')
|
irc.error(msg, 'No such function exists.')
|
||||||
return
|
return
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -796,13 +796,15 @@ class FunCommands(callbacks.Privmsg):
|
|||||||
dns = privmsgs.thread(dns)
|
dns = privmsgs.thread(dns)
|
||||||
|
|
||||||
def dict(self, irc, msg, args):
|
def dict(self, irc, msg, args):
|
||||||
"""<word>
|
"""<word> [<dictionary>]
|
||||||
|
|
||||||
Looks up the definition of <word> on dict.org's dictd server.
|
Looks up the definition of <word> on dict.org's dictd server.
|
||||||
"""
|
"""
|
||||||
word = privmsgs.getArgs(args)
|
(word, dictionary) = privmsgs.getArgs(args, optional=1)
|
||||||
|
if not dictionary:
|
||||||
|
dictionary = '*'
|
||||||
conn = dictclient.Connection('dict.org')
|
conn = dictclient.Connection('dict.org')
|
||||||
definitions = conn.define('*', word)
|
definitions = conn.define(dictionary, word)
|
||||||
if not definitions:
|
if not definitions:
|
||||||
irc.reply(msg, 'No definition for %r could be found.' % word)
|
irc.reply(msg, 'No definition for %r could be found.' % word)
|
||||||
return
|
return
|
||||||
@ -813,10 +815,12 @@ class FunCommands(callbacks.Privmsg):
|
|||||||
s = utils.normalizeWhitespace(s).rstrip(';.,')
|
s = utils.normalizeWhitespace(s).rstrip(';.,')
|
||||||
L.append('%s: %s' % (db, s))
|
L.append('%s: %s' % (db, s))
|
||||||
utils.sortBy(len, L)
|
utils.sortBy(len, L)
|
||||||
|
originalFirst = L[0]
|
||||||
ircutils.shrinkList(L, '; ')
|
ircutils.shrinkList(L, '; ')
|
||||||
if not L:
|
if not L:
|
||||||
irc.reply(msg, 'No definitions small enough to fit into an IRC ' \
|
irc.reply(msg, 'No definitions small enough to fit into an IRC ' \
|
||||||
'message were found.')
|
'message were found. Here\'s a chopped version: ' \
|
||||||
|
+ originalFirst[:375])
|
||||||
return
|
return
|
||||||
s = '%s, %s shown: %s' % \
|
s = '%s, %s shown: %s' % \
|
||||||
(utils.nItems(len(definitions), 'result'), len(L), '; '.join(L))
|
(utils.nItems(len(definitions), 'result'), len(L), '; '.join(L))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user