Fixed error in quotes query
This commit is contained in:
parent
fa045886de
commit
6636d906fd
|
@ -14,6 +14,7 @@ from ..utils import parse_int
|
|||
class Quotes(DatabasePlugin):
|
||||
requires = [
|
||||
'irc3.plugins.command',
|
||||
'nxy.plugins.database',
|
||||
]
|
||||
|
||||
NICK_REGEX = re.compile(r'<?[~&@%+]?([a-zA-Z0-9_\-^`|\\\[\]{}]+)>?')
|
||||
|
@ -49,7 +50,7 @@ class Quotes(DatabasePlugin):
|
|||
self.bot.notice(mask.nick, 'Permission denied')
|
||||
else:
|
||||
index = args.get('<index>')
|
||||
binds = [nick]
|
||||
binds = [nick, nick, nick]
|
||||
if index:
|
||||
index = parse_int(index)
|
||||
if not index:
|
||||
|
@ -62,8 +63,9 @@ class Quotes(DatabasePlugin):
|
|||
order = 'random()'
|
||||
extra = ''
|
||||
self.cur.execute('''select nick, item,
|
||||
(select count(id) from quotes b where a.id >= b.id) as idx,
|
||||
(select count(id) from quotes) as len
|
||||
(select count(id) from quotes b where b.nick like ? and
|
||||
a.id >= b.id) as idx,
|
||||
(select count(id) from quotes where nick like ?) as len
|
||||
from quotes a where nick like ? order by {order} limit 1 {extra}
|
||||
'''.format(order=order, extra=extra), binds)
|
||||
result = self.cur.fetchone()
|
||||
|
|
Loading…
Reference in New Issue
Block a user