add admin logic

This commit is contained in:
2025-02-23 00:37:04 +03:00
parent 8c191ca139
commit be24e124bb
9 changed files with 389 additions and 26 deletions
+23 -4
View File
@@ -2,11 +2,11 @@ import os
import sys
import telebot
import threading
from config import config, BotCommands, Messages
from config import config, Messages
from telebot import types
from plugin.user import User
from plugin.admin import Admin
from plugin.bot_instance import bot
from plugin.admin import Admin, AdminMessages
from plugin.bot_instance import bot, BotCommands
from plugin.register import start_reg_name
import time
@@ -14,8 +14,13 @@ import time
admin_id = config.ADMIN_ID
@bot.message_handler(commands=["start"])
@bot.message_handler(commands=BotCommands.Start)
def start_message(message: types.Message):
if Admin.is_admin(message.chat.id):
help_message(message)
return
if User(message.chat.id).name is not None:
user = User(message.chat.id)
markup = types.InlineKeyboardMarkup()
@@ -54,6 +59,20 @@ def start_message(message: types.Message):
return
@bot.message_handler(commands=BotCommands.Help)
def help_message(message: types.Message):
bot.send_message(
message.chat.id,
(
Messages.HELP
if not Admin.is_admin(message.chat.id)
else AdminMessages.ADMIN_HELP
),
)
return
if __name__ == "__main__":
print("/t--- Bot started ---")