2024-01-07 09:19:46 +00:00
|
|
|
|
from bot.api import telegram_api
|
|
|
|
|
from bot.announce import show_announce
|
2023-04-23 16:54:58 +00:00
|
|
|
|
|
2023-09-18 07:50:48 +00:00
|
|
|
|
import logging
|
2024-01-07 09:19:46 +00:00
|
|
|
|
|
2023-09-18 07:50:48 +00:00
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
2023-04-23 16:54:58 +00:00
|
|
|
|
|
2024-01-07 09:19:46 +00:00
|
|
|
|
|
|
|
|
|
positive_reactions = [] # TODO: set positive reaction kinds
|
|
|
|
|
|
2023-09-18 13:23:32 +00:00
|
|
|
|
async def handle_join_request(join_request):
|
|
|
|
|
logger.info(f"handle join request {join_request}")
|
2024-01-07 09:19:46 +00:00
|
|
|
|
|
|
|
|
|
# показываем сообщение с кнопкой "поручиться"
|
|
|
|
|
await show_announce(join_request)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
# за пользователя поручились
|
|
|
|
|
r = await telegram_api("approveChatJoinRequest", chat_id=chat_id, from_id=from_id)
|
2023-09-18 07:50:48 +00:00
|
|
|
|
logger.debug(r)
|