diff options
Diffstat (limited to 'handlers/member.py')
| -rw-r--r-- | handlers/member.py | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/handlers/member.py b/handlers/member.py index 3704c33..83fd39f 100644 --- a/handlers/member.py +++ b/handlers/member.py | |||
| @@ -3,38 +3,34 @@ from aiogram import types as t | |||
| 3 | from shared.instances import bot, dp | 3 | from shared.instances import bot, dp |
| 4 | from utils import filters as f | 4 | from utils import filters as f |
| 5 | 5 | ||
| 6 | request_queue: list[int] = [] | ||
| 7 | |||
| 8 | 6 | ||
| 9 | @dp.chat_join_request_handler() | 7 | @dp.chat_join_request_handler() |
| 10 | async def приём_запроса(cjr: t.ChatJoinRequest): | 8 | async def приём_запроса(cjr: t.ChatJoinRequest): |
| 11 | if cjr.from_user.id not in request_queue: | 9 | r = await bot.send_message( |
| 12 | request_queue.append(cjr.from_user.id) | 10 | cjr.chat.id, |
| 13 | r = await bot.send_message( | 11 | f'<a href="tg://user?id={cjr.from_user.id}">{cjr.from_user.mention}</a> хочет в чат', |
| 14 | cjr.chat.id, | 12 | parse_mode=t.ParseMode.HTML, |
| 15 | f'<a href="tg://user?id={cjr.from_user.id}">{cjr.from_user.mention}</a> хочет в чат', | 13 | ) |
| 16 | parse_mode=t.ParseMode.HTML, | 14 | await bot.send_poll( |
| 17 | ) | 15 | cjr.chat.id, |
| 18 | await bot.send_poll( | 16 | "Пускаем ?", |
| 19 | cjr.chat.id, | 17 | [ |
| 20 | "Пускаем ?", | 18 | "Да", |
| 21 | [ | 19 | "Нет", |
| 22 | "Да", | 20 | ], |
| 23 | "Нет", | 21 | False, |
| 24 | ], | 22 | reply_to_message_id=r.message_id, |
| 25 | False, | 23 | open_period=600, |
| 26 | reply_to_message_id=r.message_id, | 24 | reply_markup=t.InlineKeyboardMarkup().add( |
| 27 | open_period=600, | 25 | t.InlineKeyboardButton( |
| 28 | reply_markup=t.InlineKeyboardMarkup().add( | 26 | "Проверить опрос", |
| 29 | t.InlineKeyboardButton( | 27 | callback_data=f"check_request_poll:{cjr.from_user.id}", |
| 30 | "Проверить опрос", | 28 | ) |
| 31 | callback_data=f"check_request_poll:{cjr.from_user.id}", | 29 | ), |
| 32 | ) | 30 | ) |
| 33 | ), | 31 | await bot.send_message( |
| 34 | ) | 32 | cjr.from_user.id, "Заявка на вступление в группу будет вскоре рассмотрена" |
| 35 | await bot.send_message( | 33 | ) |
| 36 | cjr.from_user.id, "Заявка на вступление в группу будет вскоре рассмотрена" | ||
| 37 | ) | ||
| 38 | 34 | ||
| 39 | 35 | ||
| 40 | @dp.callback_query_handler( | 36 | @dp.callback_query_handler( |
| @@ -52,7 +48,6 @@ async def проверить_запрос(clb: t.CallbackQuery): | |||
| 52 | if not poll.is_closed: | 48 | if not poll.is_closed: |
| 53 | await bot.stop_poll(msg.chat.id, msg.message_id) | 49 | await bot.stop_poll(msg.chat.id, msg.message_id) |
| 54 | 50 | ||
| 55 | request_queue.remove(user_id) | ||
| 56 | yes = poll.options[0].voter_count | 51 | yes = poll.options[0].voter_count |
| 57 | no = poll.options[1].voter_count | 52 | no = poll.options[1].voter_count |
| 58 | win = max(yes, no) | 53 | win = max(yes, no) |
