From 0563305b201341dfe88a946d108c9932d1e22514 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 5 Sep 2019 18:05:50 +0100 Subject: support searching for quote content in !quote --- modules/quotes.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/quotes.py b/modules/quotes.py index db0abe5e..6e114c2d 100644 --- a/modules/quotes.py +++ b/modules/quotes.py @@ -97,14 +97,22 @@ class Module(ModuleManager.BaseModule): :help: Get a random quote from a category :usage: """ - category = event["args"].strip().lower() + category, search = self.category_and_quote(event["args"]) quotes = event["server"].get_setting("quotes-%s" % category, []) + if search: + search_lower = search.lower() + quotes = [q for q in quotes if search_lower in q[-1].lower()] + if quotes: index = random.randint(0, len(quotes)-1) nickname, time_added, quote = quotes[index] - event["stdout"].write("%s: %s" % (category, quote)) + + category_str = category + if search: + category_str = "%s (%s)" % (category_str, search) + event["stdout"].write("%s: %s" % (category_str, quote)) else: - event["stderr"].write("There are no quotes for this category") + event["stderr"].write("No matching quotes") @utils.hook("received.command.grab", alias_of="quotegrab") @utils.hook("received.command.quotegrab", min_args=1, channel_only=True) -- cgit v1.3.1-10-gc9f91