This commit is contained in:
2025-06-08 20:55:08 +09:00
parent f7e0d17829
commit 7a75f79413
139 changed files with 10619 additions and 2340 deletions

View File

@@ -0,0 +1,7 @@
from aiogram import Dispatcher
def register_handlers(dp: Dispatcher):
from . import start, admin, polls
start.register_handlers(dp)
admin.register_handlers(dp)
polls.register_handlers(dp)

View File

@@ -0,0 +1,13 @@
from aiogram import types, Dispatcher
from config import load_config
config = load_config()
async def admin_command(message: types.Message):
if message.from_user.id not in config['ADMINS']:
await message.reply("Вы не являетесь админом!")
return
await message.reply("Приветствую, повелитель!")
def register_handlers(dp: Dispatcher):
dp.register_message_handler(admin_command, commands=['admin'])

View File

@@ -0,0 +1,22 @@
from aiogram import types, Dispatcher
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from models.poll import Poll
from database import Session
async def create_poll(message: types.Message):
markup = InlineKeyboardMarkup()
markup.add(InlineKeyboardButton('Option 1', callback_data='vote_1'))
markup.add(InlineKeyboardButton('Option 2', callback_data='vote_2'))
await message.reply("Choose an option:", reply_markup=markup)
async def handle_vote(callback_query: types.CallbackQuery):
option = callback_query.data.split('_')[1]
with Session() as session:
poll = Poll(option=option)
session.add(poll)
session.commit()
await callback_query.answer(f"You voted for option {option}")
def register_handlers(dp: Dispatcher):
dp.register_message_handler(create_poll, commands=['poll'])
dp.register_callback_query_handler(handle_vote, lambda c: c.data.startswith('vote_'))

View File

@@ -0,0 +1,7 @@
from aiogram import types, Dispatcher
async def start_command(message: types.Message):
await message.reply("Приветсвие")
def register_handlers(dp: Dispatcher):
dp.register_message_handler(start_command, commands=['start'])