Verified Commit a30915c0 authored by Mroik's avatar Mroik
Browse files

Check for status change

parent a1ca1739
DEBOUNCE_TIME = 2
\ No newline at end of file
......@@ -7,11 +7,13 @@ from telegram import Update, Message
import mt
from mt.const import OPEN, CLOSED
from tgbot.const import DEBOUNCE_TIME
from config import ADMIN_CHANNELS_PRIV, ADMIN_CHANNELS_FULL
LOGGER = logging.getLogger(__name__)
last_change = None
is_open = None
def on_message(update: Update, context: CallbackContext):
......@@ -42,16 +44,20 @@ def check_debounce():
last_change = datetime.now()
return True
else:
if datetime.now() - timedelta(seconds=2) < last_change:
if datetime.now() - timedelta(seconds=DEBOUNCE_TIME) < last_change:
return True
return False
def set_open(update: Update, context: CallbackContext):
if is_open:
return
set_status(True, update, context)
def set_closed(update: Update, context: CallbackContext):
if not is_open:
return
set_status(False, update, context)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment