From e7c9c5bc269c30c7e159bc567102d0231cdcd72d Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 22 Nov 2020 15:22:20 -0500 Subject: [PATCH] [+] Implement test command --- src/commands.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/commands.py b/src/commands.py index 004c4e5..c9279f8 100644 --- a/src/commands.py +++ b/src/commands.py @@ -1,4 +1,5 @@ import re +from io import BytesIO from src.database import Database from src.utils import toJson, create @@ -110,6 +111,24 @@ def test(update, context): chat = update.effective_chat user = database.checkUser(chat.id) + # No args + if len(context.args) != 1: + return "Usage: /test " + + # Check if name exists + name = context.args[0] + if name not in database.userRequests[user]: + return "*Error:* %s doesn't exist." % name + + # Run + r = create(database.userRequests[user][name]) + body = r.text + if len(body) > 60000: + return "File too large (>60kb)." + + context.bot.send_document(chat_id=chat.id, document=BytesIO(bytes(r.text, 'utf-8')), filename=name + '.txt') + return 'Done!' + def interval(update, context): chat = update.effective_chat