mirror of
https://git.wownero.com/lza_menace/tg-bot.git
synced 2024-08-15 00:23:12 +00:00
add debug mode option to disable the bot when developing locally
This commit is contained in:
parent
eca06caf75
commit
928f7b00af
8 changed files with 29 additions and 7 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue