From a56f474ec63603c55cde86b0b286d1a96abd18be Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Mon, 31 Jul 2017 20:16:25 +0100 Subject: [PATCH] Rate-limiting for quote commands --- dave/modules/quote.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dave/modules/quote.py b/dave/modules/quote.py index 56f0f6a..ccff063 100644 --- a/dave/modules/quote.py +++ a/dave/modules/quote.py @@ -9,6 +9,7 @@ @dave.module.help("Syntax: aq [quote] (-- attribute). Add a quote.") @dave.module.command(["aq", "addquote"], "(.*?)(?: (?:--|—) ?(.+?))?$") +@dave.module.ratelimit(1, 2) def add_quote(bot, args, sender, source): generated_uuid = str(uuid.uuid4()) quote = Quote(id=generated_uuid, quote=args[0], attributed=args[1], added_by=sender) @@ -23,6 +24,7 @@ @dave.module.help("Syntax: q. Return a random quote.") @dave.module.command(["q", "quote"]) +@dave.module.ratelimit(1, 1) def quote(bot, args, sender, source): query = dave.config.session.query(Quote) @@ -40,6 +42,7 @@ @dave.module.help("Syntax: fq [search]. Search for a quote.") @dave.module.command(["fq", "findquote"], "(.*)$") +@dave.module.ratelimit(1, 3) def find_quote(bot, args, sender, source): try: quotes = dave.config.session.query(Quote).filter( @@ -65,6 +68,7 @@ @dave.module.help("Syntax: dq [uuid]. Allow the quote owner to delete a quote.") @dave.module.command(["dq", "deletequote"], "(.*)$") +@dave.module.ratelimit(1, 1) def delete_quote(bot, args, sender, source): query = dave.config.session.query(Quote).filter(Quote.id == args[0]) @@ -73,4 +77,4 @@ return query.delete() - bot.reply(source, sender, "Successfully deleted quote.")+ bot.reply(source, sender, "Successfully deleted quote.") -- rgit 0.1.3