version-0.2.1

This commit is contained in:
2024-01-07 14:41:27 +03:00
parent a80727e97f
commit 02c4810437
4 changed files with 38 additions and 24 deletions

View File

@@ -7,22 +7,31 @@ logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
positive_reactions = [] # TODO: set positive reaction kinds
positive_reactions = ["👍", "", "🔥", "🥰", "👏", "🎉", "🙏", "👌", "🕊", "😍", "❤‍🔥", "🍓", "🍾", "💋", "😇", "🤝", "🤗", "💘", "😘"]
announced_message = {
"ru": "Запрос на вступление опубликован в чате, как только вас узнают и отреагируют - она будет принята",
"en": "The join request is posted in the chat, once you are recognized and someone reacted to - it will be accepted"
}
async def handle_join_request(join_request):
logger.info(f"handle join request {join_request}")
user = join_request["from"]
lang = user.get("language_code", "ru")
# показываем сообщение с кнопкой "поручиться"
# показываем анонс с заявкой
await show_announce(join_request)
# сообщаем пользователю, что опубликовали анонс его заявки
await telegram_api("sendMessage", chat_id=user['id'], text=announced_message[lang])
async def handle_reaction_on_request(update):
chat_id = str(update["chat"]["id"])
from_id = str(update["from"]["id"])
logger.debug(update)
reaction = None # TODO: get reaction kind from update
if reaction in positive_reactions:
reaction = update.get("message_reaction")
new_reaction = reaction.get("new_reaction")
if new_reaction.get("emoji") in positive_reactions:
# за пользователя поручились
r = await telegram_api("approveChatJoinRequest", chat_id=chat_id, from_id=from_id)
r = await telegram_api("approveChatJoinRequest", chat_id=chat_id, user_id=from_id)
logger.debug(r)