🏡 index : ~doyle/dave.git

author Jordan Doyle <jordan@doyle.wf> 2017-07-31 20:16:25.0 +01:00:00
committer GitHub <noreply@github.com> 2017-07-31 20:16:25.0 +01:00:00
commit
a56f474ec63603c55cde86b0b286d1a96abd18be [patch]
tree
fedbfdf92cf9d0fac95575d66311d9836c1ebd19
parent
9c39d2e62d5763f0f5442890a243e583cd3a5ba1
download
a56f474ec63603c55cde86b0b286d1a96abd18be.tar.gz

Rate-limiting for quote commands



Diff

 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.")