From e52a4a4f37fd4f0c157dcd60471a517d699411ba Mon Sep 17 00:00:00 2001 From: Phash Date: Thu, 29 Sep 2016 00:45:50 +0300 Subject: [PATCH] /delbot command --- webhook_master_bot.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/webhook_master_bot.py b/webhook_master_bot.py index bbf33c7..c8d923b 100644 --- a/webhook_master_bot.py +++ b/webhook_master_bot.py @@ -28,7 +28,7 @@ def __init__(self, token, server, baseurl, cert=None): except Exception: db.bots.delete(b.id) continue - sleep(10) + sleep(1) sub_bot.set_webhook( url=baseurl + 'proxybot/' + sub_bot.token, certificate=cert @@ -63,6 +63,17 @@ def start(message): Semd me api_token and I will spawn an proxy_bot for you. More info at https://github.com/p-hash/proxybot''') + @bot.message_handler(commands=['delbot']) + def del_bot(message): + b = db.bots.get_by_master(message.from_user.id) + if b: + sub_bots.pop(b.token, None) + db.bots.delete(b.id) + bot.reply_to(message, "Your bot was deleted. If you still cant create new one -- contact @phash_bot") + else: + bot.reply_to(message, "You dont have your own ProxyBot yet.") + + @bot.message_handler() def check_token(message): if message.chat.type != 'private':