add admin logic
This commit is contained in:
+23
-4
@@ -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 ---")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user