Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features-C3-AdminPanelPreview #12

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GoogleSheets/Google_sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def rating_update():
worksheet.sort((4, 'des'))

def rating_update_over_time():
schedule.every(1).hour.do(rating_update)
schedule.every(20).seconds.do(rating_update)
while True:
schedule.run_pending()

Expand Down
1 change: 0 additions & 1 deletion buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
rkbm.row(khelp,kliderboard)

#admin buttons
admin_list=['5617565289']
admrkbm = ReplyKeyboardMarkup(resize_keyboard=True)
admk_user_editor = KeyboardButton(text="⚙️Изменить пользователя")
admk_event_creation = KeyboardButton(text="🛠️Создать мероприятие")
Expand Down
24 changes: 23 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Optional
from aiogram.dispatcher.filters import Command
from aiogram.dispatcher.filters.state import State, StatesGroup
from buttons import ikbg, rkbm, ikbmrating
from buttons import ikbg, rkbm, ikbmrating, admrkbm
from Database.DataUsers import get_user_state_by_id, update_user_state_by_id, supabase,delete_user_data_by_id, get_user_info_by_id

from GoogleSheets.Google_sheets import rating_update_start_thread
Expand Down Expand Up @@ -46,6 +46,28 @@ class MenuStates(StatesGroup):
help = State()
rating = State()

class AdminPanel(StatesGroup):
admin_menu = State()
change_user = State()
add_event = State()
add_task = State()
backward = State()
rating_board = State()

# Хендлер для команды /admin
@dp.message_handler(commands=['admin'], state='*')
async def admin_command(message: types.Message, state: FSMContext):

# Проверка, что пользователь в списке админов
admin_list = ['5617565289', '415378656']
if str(message.from_user.id) not in admin_list:
await message.reply("У вас нет прав администратора!")
return

# Установка состояния и вывод кнопок админки
await AdminPanel.admin_menu.set()
update_user_state_by_id(message.chat.id, str(AdminPanel.admin_menu))
await message.reply("Вы вошли в панель администратора", reply_markup=admrkbm)

@dp.message_handler(Command('start'), state=None)
async def start_command(message: types.Message, state: FSMContext):
Expand Down