add debug mode option to disable the bot when developing locally

This commit is contained in:
lza_menace 2020-08-06 13:40:03 -07:00
parent eca06caf75
commit 928f7b00af
8 changed files with 29 additions and 7 deletions

View file

@ -1,9 +1,24 @@
import logging
from functools import wraps
from tipbot import wownero
from tipbot import db
from functools import wraps
from tipbot import config
from tipbot.helpers.utils import is_tg_admin
def check_debug(f):
@wraps(f)
def decorated_function(*args, **kwargs):
msg = args[0].message
is_admin = is_tg_admin(msg.from_user["id"])
is_debug = getattr(config, 'DEBUG', True) == True
if is_debug:
if not is_admin:
msg.reply_text('I am in debug mode by my admin. Commands are disabled at the moment. Try again later.')
return False
return f(*args, **kwargs)
return decorated_function
def log_event(f):
@wraps(f)
def decorated_function(*args, **kwargs):