144 строки
3.4 KiB
Python
144 строки
3.4 KiB
Python
import asyncio
|
|
|
|
from aiogram import Bot, Dispatcher
|
|
from aiogram.client.default import DefaultBotProperties
|
|
from aiogram.enums import ParseMode
|
|
from aiogram.filters import CommandStart
|
|
from aiogram.types import Message, Poll, InputPollOption
|
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
|
|
|
import config
|
|
|
|
|
|
dp = Dispatcher()
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|
|
@dp.message(CommandStart())
|
|
async def command_start_handler(
|
|
message: Message,
|
|
):
|
|
print(message.chat.id)
|
|
await message.answer('Чат успешно зарегистрирован!')
|
|
|
|
|
|
bot = Bot(
|
|
token=config.Telegram.token,
|
|
default=DefaultBotProperties(
|
|
parse_mode=ParseMode.HTML,
|
|
),
|
|
)
|
|
|
|
scheduler = AsyncIOScheduler()
|
|
|
|
|
|
async def send_mood_poll() -> Poll:
|
|
await bot.send_poll(
|
|
chat_id=-1002246469549,
|
|
question='Оцените свое состояние на текущую минуту',
|
|
options=[
|
|
InputPollOption(
|
|
text='😄',
|
|
),
|
|
InputPollOption(
|
|
text='🤪',
|
|
),
|
|
InputPollOption(
|
|
text='🫠',
|
|
),
|
|
InputPollOption(
|
|
text='☠️',
|
|
),
|
|
InputPollOption(
|
|
text='🤡',
|
|
),
|
|
InputPollOption(
|
|
text='😟',
|
|
),
|
|
InputPollOption(
|
|
text='😩',
|
|
),
|
|
InputPollOption(
|
|
text='😡',
|
|
),
|
|
],
|
|
is_anonymous=False,
|
|
allows_multiple_answers=False,
|
|
is_closed=False,
|
|
disable_notification=True,
|
|
)
|
|
|
|
|
|
async def send_dinner_poll() -> Poll:
|
|
message = await bot.send_poll(
|
|
chat_id=-1002246469549,
|
|
question='Какие у вас планы на обед?',
|
|
options=[
|
|
InputPollOption(
|
|
text='🍽️ Пойду в общепит',
|
|
),
|
|
InputPollOption(
|
|
text='📦 Хочу заказать в офис',
|
|
),
|
|
InputPollOption(
|
|
text='🥪 Всё своё ношу с собой',
|
|
),
|
|
InputPollOption(
|
|
text='😴 Хочу спать',
|
|
),
|
|
],
|
|
is_anonymous=False,
|
|
allows_multiple_answers=False,
|
|
is_closed=False,
|
|
disable_notification=True,
|
|
)
|
|
return message.poll
|
|
|
|
|
|
async def send_dinner_delivery_poll() -> Poll:
|
|
await bot.send_poll(
|
|
chat_id=-1002246469549,
|
|
question='Где будем заказывать?',
|
|
options=[
|
|
InputPollOption(
|
|
text='Dark Side',
|
|
),
|
|
InputPollOption(
|
|
text='Самокат',
|
|
),
|
|
InputPollOption(
|
|
text='...',
|
|
),
|
|
InputPollOption(
|
|
text='...',
|
|
),
|
|
],
|
|
is_anonymous=False,
|
|
allows_multiple_answers=False,
|
|
is_closed=False,
|
|
disable_notification=True,
|
|
)
|
|
|
|
|
|
async def on_startup(
|
|
dispatcher: Dispatcher,
|
|
):
|
|
scheduler.add_job(
|
|
func=send_mood_poll,
|
|
trigger='cron',
|
|
day_of_week='mon-fri',
|
|
hour=17,
|
|
minute=14,
|
|
)
|
|
scheduler.add_job(
|
|
func=send_dinner_poll,
|
|
trigger='cron',
|
|
day_of_week='mon-fri',
|
|
hour=17,
|
|
minute=17,
|
|
)
|
|
scheduler.start()
|
|
|
|
|
|
dp.startup.register(on_startup)
|