Skip to content

Commit 13cf730

Browse files
committed
TASK: Extract method to check if user is admin
1 parent f9cc05b commit 13cf730

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def answer(bot, update):
224224
text = str(update.message.text[8:])
225225
db = DBwrapper.get_instance()
226226

227-
if sender_id not in db.get_admins():
227+
if not sender_is_admin(sender_id):
228228
return
229229

230230
if reply_to_message is None:
@@ -242,6 +242,9 @@ def answer(bot, update):
242242
bot.sendMessage(chat_id=sender_id, text="Message sent!")
243243

244244

245+
def sender_is_admin(user_id: int) -> bool:
246+
db = DBwrapper.get_instance()
247+
return user_id in db.get_admins()
245248

246249

247250
# -----------------

0 commit comments

Comments
 (0)