Encyclopedia: Add 'review' command to list edit requests.
This commit is contained in:
@ -24,7 +24,7 @@ import supybot
|
||||
import supybot.world as world
|
||||
from importlib import reload
|
||||
|
||||
__version__ = "3.9.0"
|
||||
__version__ = "4.0.0"
|
||||
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com")
|
||||
__contributors__ = {
|
||||
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],
|
||||
|
@ -806,7 +806,7 @@ class Encyclopedia(callbacks.Plugin):
|
||||
for r in res:
|
||||
ret.append(get_factoid_label(r[0], r[1]))
|
||||
if not ret:
|
||||
return "None found"
|
||||
return "No matches found"
|
||||
return 'Found: %s' % ', '.join(ret)
|
||||
|
||||
def sync(self, irc, msg, args, channel):
|
||||
@ -887,10 +887,10 @@ class Encyclopedia(callbacks.Plugin):
|
||||
return
|
||||
sync = wrap(sync, [optional("channel")])
|
||||
|
||||
def lookup(self, irc, msg, args, author, channel):
|
||||
"""[<author>] [<channel>]
|
||||
def lookup(self, irc, msg, args, channel, author):
|
||||
"""[<channel>] [<author>]
|
||||
|
||||
Looks up factoids created or edited by <author>,
|
||||
Lists factoids created or edited by <author>,
|
||||
<author> defaults to you.
|
||||
"""
|
||||
if not capab(msg.prefix, "editfactoids"):
|
||||
@ -915,19 +915,49 @@ class Encyclopedia(callbacks.Plugin):
|
||||
edit_ret.append(get_factoid_label(r[0], r[1]))
|
||||
|
||||
if not auth_ret:
|
||||
auth_rmsg = "Authored: None found"
|
||||
auth_rmsg = "Authored: (none)"
|
||||
else:
|
||||
auth_rmsg = 'Authored: %s' % ', '.join(auth_ret)
|
||||
if not edit_ret:
|
||||
edit_rmsg = "Edited: None found"
|
||||
edit_rmsg = "Edited: (none)"
|
||||
else:
|
||||
edit_rmsg = 'Edited: %s' % ', '.join(edit_ret)
|
||||
irc.reply("%s; %s" % (auth_rmsg, edit_rmsg))
|
||||
lookup = wrap(lookup, [optional("nick"), optional("channel")])
|
||||
lookup = wrap(lookup, [optional("channel"), optional("nick")])
|
||||
|
||||
def review(self, irc, msg, args, channel, reqid):
|
||||
"""[<channel>] [<id>]
|
||||
|
||||
Lists edit requests. If <id> is given, prints the suggested new value.
|
||||
"""
|
||||
if not capab(msg.prefix, "editfactoids"):
|
||||
irc.errorNoCapability("editfactoids")
|
||||
return
|
||||
db = self.get_db(channel)
|
||||
cur = db.cursor()
|
||||
if not reqid:
|
||||
cur.execute("SELECT id, type, name, requester, requested FROM requests ORDER BY id DESC LIMIT 15")
|
||||
res = cur.fetchall()
|
||||
ret = []
|
||||
for r in res:
|
||||
ret.append("[%s] %s (%s) by %s on %s" % (r[0], r[2], r[1], r[3][:r[3].find('!')], r[4][:r[4].rfind('.')]))
|
||||
if not ret:
|
||||
rmsg = "No requests found"
|
||||
else:
|
||||
rmsg = ', '.join(ret)
|
||||
else:
|
||||
cur.execute("SELECT value FROM requests WHERE id = ?", (reqid,))
|
||||
res = cur.fetchall()
|
||||
if not res:
|
||||
rmsg = "Request not found"
|
||||
else:
|
||||
rmsg = res[0][0]
|
||||
irc.reply(rmsg)
|
||||
review = wrap(review, [optional("channel"), optional("positiveInt")])
|
||||
|
||||
class ignore(callbacks.Commands):
|
||||
def add(self, irc, msg, args, banmask, expires, channel):
|
||||
"""<hostmask|nick> [<expires>] [<channel>]
|
||||
def add(self, irc, msg, args, channel, banmask, expires):
|
||||
"""[<channel>] <hostmask|nick> [<expires>]
|
||||
|
||||
Ignores commands/requests from <hostmask> or <nick>. If <expires> is
|
||||
given, the ignore will expire after that ammount of seconds.
|
||||
@ -944,10 +974,10 @@ class Encyclopedia(callbacks.Plugin):
|
||||
else:
|
||||
ircdb.ignores.add(banmask, expires)
|
||||
irc.replySuccess()
|
||||
add = wrap(add, ['hostmask', optional("expiry", 0), optional("channel")])
|
||||
add = wrap(add, [optional("channel"), 'hostmask', optional("expiry", 0)])
|
||||
|
||||
def remove(self, irc, msg, args, banmask, channel):
|
||||
"""<hostmask|nick> [<channel>]
|
||||
def remove(self, irc, msg, args, channel, banmask):
|
||||
"""[<channel>] <hostmask|nick>
|
||||
|
||||
Removes an ignore previously set by @ignore. If <channel> was
|
||||
given in the original @ignore command, it must be given here.
|
||||
@ -969,7 +999,7 @@ class Encyclopedia(callbacks.Plugin):
|
||||
irc.replySuccess()
|
||||
except KeyError:
|
||||
irc.error("That hostmask is not globally ignored")
|
||||
remove = wrap(remove, ['hostmask', optional("channel")])
|
||||
remove = wrap(remove, [optional("channel"), 'hostmask'])
|
||||
|
||||
def ignores(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
Reference in New Issue
Block a user