version-0.2.1
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user