aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-09-05 18:05:50 +0100
committerGravatar jesopo2019-09-05 18:05:50 +0100
commit0563305b201341dfe88a946d108c9932d1e22514 (patch)
treea0672cb5cb30036de34a4b3326c49c375422f176 /modules
parentChange README.md to make it clear that I will add new networks for good people (diff)
signature
support searching for quote content in !quote
Diffstat (limited to 'modules')
-rw-r--r--modules/quotes.py14
1 files changed, 11 insertions, 3 deletions
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>
"""
- 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)