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
Projects
B.I.T.S. 4.0
bits-companion
Commits
1863a27c
Verified
Commit
1863a27c
authored
Oct 19, 2021
by
Mroik
Browse files
Added different type of admin chan
parent
c8247b24
Changes
2
Show whitespace changes
Inline
Side-by-side
config.py
View file @
1863a27c
...
...
@@ -6,7 +6,10 @@ PORT = int(environ.get("BITS_PORT", default=1883))
USERNAME
=
environ
.
get
(
"BITS_USER"
)
PASSWORD
=
environ
.
get
(
"BITS_PASSWORD"
,
default
=
""
)
TG_KEY
=
environ
.
get
(
"BITS_TG_KEY"
,
default
=
""
)
ADMIN_CHANNELS
=
[]
# Channels that are allowed to change HQ's status
ADMIN_CHANNELS_FULL
=
[]
# Channels that are allowed to change HQ's status
ADMIN_CHANNELS_PRIV
=
[]
# Channels that are allowed to change HQ's status
for
chan
in
environ
.
get
(
"BITS_TG_GROUPS"
,
default
=
""
).
split
(
":"
):
ADMIN_CHANNELS
.
append
(
chan
)
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
(
":"
):
ADMIN_CHANNELS_PRIV
.
append
(
chan
)
tgbot/handlers.py
View file @
1863a27c
...
...
@@ -7,7 +7,7 @@ from telegram import Update, Message
import
mt
from
mt.const
import
OPEN
,
CLOSED
from
config
import
ADMIN_CHANNELS
from
config
import
ADMIN_CHANNELS
_PRIV
,
ADMIN_CHANNELS_FULL
LOGGER
=
logging
.
getLogger
(
__name__
)
...
...
@@ -23,7 +23,9 @@ def on_message(update: Update, context: CallbackContext):
def
check_admin
(
update
:
Update
,
context
:
CallbackContext
):
if
str
(
update
.
message
.
chat
.
id
)
not
in
ADMIN_CHANNELS
:
if
str
(
update
.
message
.
chat
.
id
)
in
ADMIN_CHANNELS_FULL
:
return
True
if
str
(
update
.
message
.
chat
.
id
)
not
in
ADMIN_CHANNELS_PRIV
:
raise
DispatcherHandlerStop
is_admin
=
False
...
...
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