1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
from datetime import datetime, timedelta
from aiogram import types as t
from shared.instances import bot, dp
from utils import filters as f
pin_reply_markup = t.InlineKeyboardMarkup().add(
t.InlineKeyboardButton("Проверить сейчас", callback_data="check_pin_poll")
)
@dp.message_handler(f.message.is_chat, commands=["pin"])
async def закрепить_хуету(msg: t.Message):
await msg.delete()
if msg.reply_to_message:
await msg.reply_to_message.reply_poll(
"Закрепить ?",
["Да", "УДАЛИ НАХУЙ", "Нет"],
close_date=datetime.now() + timedelta(minutes=10),
reply_markup=pin_reply_markup,
)
else:
await msg.answer("Ты умник, ответь на сообщение")
@dp.callback_query_handler(f.message.is_chat, lambda clb: clb.data == "check_pin_poll")
async def проверить_закреп(clb: t.CallbackQuery):
poll = clb.message.poll
msg = clb.message
if poll.total_voter_count <= 0:
await clb.answer("Видишь голоса? Вот и я невижу")
elif poll.total_voter_count <= 2:
await clb.answer("Видишь голоса? Они есть, но их мало")
else:
if not poll.is_closed:
await bot.stop_poll(msg.chat.id, msg.message_id)
poll.is_closed = True
yes = poll.options[0].voter_count
delete = poll.options[1].voter_count
win = max(yes, delete)
if win == yes:
await msg.reply_to_message.pin()
elif win == delete:
await msg.reply_to_message.delete()
if poll.is_closed:
await msg.delete()
|