Example #1
0
            f"welcome security failed due to {error.args[0]}")

    redis.set(f"welcome_security_users:{user_id}:{chat_id}", msg.id)

    if raw_time := db_item["welcome_security"].get("expire", None):
        time = convert_time(raw_time)
    else:
        time = convert_time(get_str_key("JOIN_CONFIRM_DURATION"))

    scheduler.add_job(
        join_expired,
        "date",
        id=f"wc_expire:{chat_id}:{user_id}",
        run_date=datetime.utcnow() + time,
        kwargs={
            "chat_id": chat_id,
            "user_id": user_id,
            "message_id": msg.id,
            "wlkm_msg_id": message.message_id,
        },
        replace_existing=True,
    )


async def join_expired(chat_id, user_id, message_id, wlkm_msg_id):
    user = await bot.get_chat_member(chat_id, user_id)
    if user.status != "restricted":
        return

    bot_user = await bot.get_chat_member(chat_id, BOT_ID)
    if ("can_restrict_members" not in bot_user
Example #2
0
        return await message.reply(
            f'welcome security failed due to {error.args[0]}')

    redis.set(f'welcome_security_users:{user_id}:{chat_id}', msg.id)

    if raw_time := db_item['welcome_security'].get('expire', None):
        time = convert_time(raw_time)
    else:
        time = convert_time(get_str_key('JOIN_CONFIRM_DURATION'))

    scheduler.add_job(join_expired,
                      "date",
                      id=f"wc_expire:{chat_id}:{user_id}",
                      run_date=datetime.utcnow() + time,
                      kwargs={
                          'chat_id': chat_id,
                          'user_id': user_id,
                          'message_id': msg.id,
                          'wlkm_msg_id': message.message_id
                      },
                      replace_existing=True)


async def join_expired(chat_id, user_id, message_id, wlkm_msg_id):
    user = await bot.get_chat_member(chat_id, user_id)
    if user.status != 'restricted':
        return

    bot_user = await bot.get_chat_member(chat_id, BOT_ID)
    if 'can_restrict_members' not in bot_user or bot_user[
            'can_restrict_members'] is False: