It's version 0.7 I upgrade watcher_service.py
This commit is contained in:
+56
-56
@@ -34,59 +34,59 @@ def register_handlers(dp: Dispatcher, state: BotState, bot: Bot):
|
||||
except Exception as e:
|
||||
logger.error(f"Ошибка при отправке в чат {chat_id}: {e}")
|
||||
|
||||
@dp.poll_answer()
|
||||
async def handle_poll_answer(poll_answer: PollAnswer):
|
||||
user = poll_answer.user
|
||||
option_ids = poll_answer.option_ids
|
||||
|
||||
# username или fallback на имя
|
||||
username = f"@{user.username}" if user.username else user.first_name
|
||||
|
||||
# всегда пишем в первый чат из Config.CHAT_IDS
|
||||
# 6394047531
|
||||
#850906163
|
||||
STARAST = 6394047531
|
||||
|
||||
if not option_ids:
|
||||
msg = await bot.send_message(
|
||||
chat_id=STARAST, text=f"{username} Отменил свой голос"
|
||||
)
|
||||
save_message(msg.chat.id, msg.message_id)
|
||||
elif option_ids and option_ids[0] == 0:
|
||||
msg = await bot.send_message(
|
||||
chat_id=STARAST, text=f"{username} опоздает"
|
||||
)
|
||||
save_message(msg.chat.id, msg.message_id)
|
||||
elif option_ids and option_ids[0] == 1:
|
||||
msg = await bot.send_message(
|
||||
chat_id=STARAST, text=f"{username} сильно опоздает"
|
||||
)
|
||||
save_message(msg.chat.id, msg.message_id)
|
||||
elif option_ids and option_ids[0] == 2:
|
||||
msg = await bot.send_message(
|
||||
chat_id=STARAST, text=f"{username} Пиздец опоздает"
|
||||
)
|
||||
save_message(msg.chat.id, msg.message_id)
|
||||
elif option_ids[0] == 3:
|
||||
msg = await bot.send_message(
|
||||
chat_id=STARAST, text=f"{username} возможно опоздает"
|
||||
)
|
||||
save_message(msg.chat.id, msg.message_id)
|
||||
|
||||
elif option_ids[0] == 4:
|
||||
photo = FSInputFile("/Users/mac/myfirstprogramm/addons/poll/img.png")
|
||||
msg = await bot.send_photo(
|
||||
chat_id=STARAST, photo=photo, caption=f"{username} ДОЛБОЯЩЕР"
|
||||
)
|
||||
save_message(msg.chat.id, msg.message_id)
|
||||
|
||||
elif option_ids[0] == 5:
|
||||
msg = await bot.send_message(
|
||||
chat_id=STARAST, text=f"{username} не опоздает"
|
||||
)
|
||||
save_message(msg.chat.id, msg.message_id)
|
||||
else:
|
||||
msg = await bot.send_message(
|
||||
chat_id=STARAST, text=f"{username} выбрал вариант {option_ids}"
|
||||
)
|
||||
save_message(msg.chat.id, msg.message_id)
|
||||
# @dp.poll_answer()
|
||||
# async def handle_poll_answer(poll_answer: PollAnswer):
|
||||
# user = poll_answer.user
|
||||
# option_ids = poll_answer.option_ids
|
||||
#
|
||||
# # username или fallback на имя
|
||||
# username = f"@{user.username}" if user.username else user.first_name
|
||||
#
|
||||
# # всегда пишем в первый чат из Config.CHAT_IDS
|
||||
# # 6394047531
|
||||
# #850906163
|
||||
# STARAST = 6394047531
|
||||
#
|
||||
# if not option_ids:
|
||||
# msg = await bot.send_message(
|
||||
# chat_id=STARAST, text=f"{username} Отменил свой голос"
|
||||
# )
|
||||
# save_message(msg.chat.id, msg.message_id)
|
||||
# elif option_ids and option_ids[0] == 0:
|
||||
# msg = await bot.send_message(
|
||||
# chat_id=STARAST, text=f"{username} опоздает"
|
||||
# )
|
||||
# save_message(msg.chat.id, msg.message_id)
|
||||
# elif option_ids and option_ids[0] == 1:
|
||||
# msg = await bot.send_message(
|
||||
# chat_id=STARAST, text=f"{username} сильно опоздает"
|
||||
# )
|
||||
# save_message(msg.chat.id, msg.message_id)
|
||||
# elif option_ids and option_ids[0] == 2:
|
||||
# msg = await bot.send_message(
|
||||
# chat_id=STARAST, text=f"{username} Пиздец опоздает"
|
||||
# )
|
||||
# save_message(msg.chat.id, msg.message_id)
|
||||
# elif option_ids[0] == 3:
|
||||
# msg = await bot.send_message(
|
||||
# chat_id=STARAST, text=f"{username} возможно опоздает"
|
||||
# )
|
||||
# save_message(msg.chat.id, msg.message_id)
|
||||
#
|
||||
# elif option_ids[0] == 4:
|
||||
# photo = FSInputFile("/Users/mac/myfirstprogramm/addons/poll/img.png")
|
||||
# msg = await bot.send_photo(
|
||||
# chat_id=STARAST, photo=photo, caption=f"{username} ДОЛБОЯЩЕР"
|
||||
# )
|
||||
# save_message(msg.chat.id, msg.message_id)
|
||||
#
|
||||
# elif option_ids[0] == 5:
|
||||
# msg = await bot.send_message(
|
||||
# chat_id=STARAST, text=f"{username} не опоздает"
|
||||
# )
|
||||
# save_message(msg.chat.id, msg.message_id)
|
||||
# else:
|
||||
# msg = await bot.send_message(
|
||||
# chat_id=STARAST, text=f"{username} выбрал вариант {option_ids}"
|
||||
# )
|
||||
# save_message(msg.chat.id, msg.message_id)
|
||||
|
||||
Reference in New Issue
Block a user