make ".quote #channel nick" work
This commit is contained in:
parent
8f1f2950cc
commit
c8b4d5e15a
|
@ -32,7 +32,7 @@ def format_quote(q, num, n_quotes):
|
|||
@hook.command('q')
|
||||
@hook.command
|
||||
def quote(inp, nick='', chan='', db=None):
|
||||
".q/.quote <nick|#chan> [#n]/.quote add <nick> <msg> -- gets " \
|
||||
".q/.quote [#chan] [nick] [#n]/.quote add <nick> <msg> -- gets " \
|
||||
"random or [#n]th quote by <nick> or from <#chan>/adds quote"
|
||||
|
||||
db.execute("create table if not exists quote"
|
||||
|
@ -42,6 +42,7 @@ def quote(inp, nick='', chan='', db=None):
|
|||
|
||||
add = re.match(r"add[^\w@]+(\S+?)>?\s+(.*)", inp, re.I)
|
||||
retrieve = re.match(r"(\S+)(?:\s+#?(-?\d+))?$", inp)
|
||||
retrieve_chan = re.match(r"(#\S+)\s+(\S+)(?:\s+#?(-?\d+))?$", inp)
|
||||
|
||||
if add:
|
||||
quoted_nick, msg = add.groups()
|
||||
|
@ -60,6 +61,12 @@ def quote(inp, nick='', chan='', db=None):
|
|||
quotes = get_quotes_by_chan(db, select)
|
||||
else:
|
||||
quotes = get_quotes_by_nick(db, chan, select)
|
||||
elif retrieve_chan:
|
||||
chan, nick, num = retrieve_chan.groups()
|
||||
|
||||
quotes = get_quotes_by_nick(db, chan, nick)
|
||||
else:
|
||||
return quote.__doc__
|
||||
|
||||
n_quotes = len(quotes)
|
||||
|
||||
|
|
Loading…
Reference in New Issue