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