From 93f19492ca6c2a55324bb9f5ef22d9ef41d68fea Mon Sep 17 00:00:00 2001 From: Daniel DiPaolo Date: Wed, 22 Oct 2003 16:01:05 +0000 Subject: [PATCH] Could have sworn I committed this already... turns on globbing by default (I think .. too lazy to diff and see if that's what changed) --- plugins/MoobotFactoids.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/plugins/MoobotFactoids.py b/plugins/MoobotFactoids.py index e88da13ea..a750a212e 100644 --- a/plugins/MoobotFactoids.py +++ b/plugins/MoobotFactoids.py @@ -505,43 +505,44 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): (author, len(keys), utils.commaAndify(keys)) irc.reply(msg, s) - _sqlTrans = string.maketrans('*?', '%_') def listkeys(self, irc, msg, args): - """ + """ - Lists the keys of the factoids whose key matches the provided glob. + Lists the keys of the factoids whose key contains the provided text. """ - glob = privmsgs.getArgs(args, needed=1) + search = privmsgs.getArgs(args, needed=1) + glob = '%' + search + '%' cursor = self.db.cursor() cursor.execute("""SELECT key FROM factoids WHERE key LIKE %s ORDER BY key""", - glob.translate(self._sqlTrans)) + glob) if cursor.rowcount == 0: - irc.reply(msg, "No keys matching %r found." % glob) + irc.reply(msg, "No keys matching %r found." % search) return keys = [repr(tup[0]) for tup in cursor.fetchall()] s = "Key search for %r (%d found): %s" % \ - (glob, len(keys), utils.commaAndify(keys)) + (search, len(keys), utils.commaAndify(keys)) irc.reply(msg, s) def listvalues(self, irc, msg, args): - """ + """ - Lists the keys of the factoids whose value matches the provided glob. + Lists the keys of the factoids whose value contains the provided text. """ - glob = privmsgs.getArgs(args, needed=1) + search = privmsgs.getArgs(args, needed=1) + glob = '%' + search + '%' cursor = self.db.cursor() cursor.execute("""SELECT key FROM factoids WHERE fact LIKE %s ORDER BY key""", - glob.translate(self._sqlTrans)) + glob) if cursor.rowcount == 0: - irc.reply(msg, "No values matching %r found." % glob) + irc.reply(msg, "No values matching %r found." % search) return keys = [repr(tup[0]) for tup in cursor.fetchall()] s = "Value search for %r (%d found): %s" % \ - (glob, len(keys), utils.commaAndify(keys)) + (search, len(keys), utils.commaAndify(keys)) irc.reply(msg, s) def delete(self, irc, msg, args): @@ -574,7 +575,8 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): """ Adds as a "dunno" to be used as a random response when no - command or factoid key matches. + command or factoid key matches. Can optionally contain '$who', which + will be replaced by the user's name when the dunno is displayed. """ # Must be registered to use this try: