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
eba32d5c
Verified
Commit
eba32d5c
authored
Oct 25, 2021
by
Mroik
Browse files
Small fixes
parent
f889c5fc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Dockerfile
View file @
eba32d5c
FROM
python:3.9.7-slim
COPY
requirements.txt /
RUN
pip
install
-r
requirements.txt
RUN
mkdir
bits-tgbot
COPY
. /bits-tgbot/
WORKDIR
/bits-tgbot
RUN
pip
install
-r
requirements.txt
ENTRYPOINT
["python", "main.py"]
config.py
View file @
eba32d5c
...
...
@@ -9,6 +9,8 @@ TG_KEY = environ.get("BITS_TG_KEY", default="")
ADMIN_CHANNELS_FULL
=
[]
# Channels that are allowed to change HQ's status
ADMIN_CHANNELS_PRIV
=
[]
# Channels that are allowed to change HQ's status
DEBUG
=
environ
.
get
(
"DEBUG"
,
default
=
None
)
for
chan
in
environ
.
get
(
"BITS_TG_GROUPS_FULL"
,
default
=
""
).
split
(
":"
):
ADMIN_CHANNELS_FULL
.
append
(
chan
)
for
chan
in
environ
.
get
(
"BITS_TG_GROUPS_PRIV"
,
default
=
""
).
split
(
":"
):
...
...
main.py
View file @
eba32d5c
...
...
@@ -7,13 +7,15 @@ from config import (
PORT
,
USERNAME
,
PASSWORD
,
DEBUG
,
)
LOGGER
=
logging
.
getLogger
(
__name__
)
def
main
():
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
# Uncomment for DUBUG
if
DEBUG
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
mt
.
bot
=
Bot
(
SERVER
,
PORT
)
mt
.
bot
.
start
(
USERNAME
,
PASSWORD
)
...
...
mt/handlers.py
View file @
eba32d5c
...
...
@@ -25,7 +25,6 @@ def on_message(client, userdata, msg):
payload
=
json
.
loads
(
msg
.
payload
.
decode
(
"utf-8"
))
if
msg
.
topic
!=
"sede/status"
:
return
return
if
payload
[
"status"
]
==
OPEN
:
for
id_
in
where_am_i
:
updater
.
bot
.
send_message
(
id_
,
"🟢🟢 Il POuL è aperto! 🟢🟢"
)
...
...
tgbot/handlers.py
View file @
eba32d5c
...
...
@@ -50,9 +50,11 @@ def check_debounce():
def
set_open
(
update
:
Update
,
context
:
CallbackContext
):
set_status
(
True
,
update
,
context
)
def
set_closed
(
update
:
Update
,
context
:
CallbackContext
):
set_status
(
False
,
update
,
context
)
def
set_status
(
status
:
bool
,
update
:
Update
,
context
:
CallbackContext
):
LOGGER
.
debug
(
f
"Trying to set status to
{
status
}
"
)
if
check_debounce
():
...
...
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