Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pitte
bits-companion
Commits
a30915c0
Verified
Commit
a30915c0
authored
Oct 26, 2021
by
Mroik
Browse files
Check for status change
parent
a1ca1739
Changes
2
Hide whitespace changes
Inline
Side-by-side
tgbot/const.py
0 → 100644
View file @
a30915c0
DEBOUNCE_TIME
=
2
\ No newline at end of file
tgbot/handlers.py
View file @
a30915c0
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment