Ejemplo n.º 1
0
async def _(event):
    send = await event.get_sender()
    sender = await tbot.get_entity(send)

    approved_userss = approved_users.find({})
    for ch in approved_userss:
        iid = ch['id']
        userss = ch['user']

    if event.is_group:
        if (await is_register_admin(event.input_chat,
                                    event.message.sender_id)):
            pass
        elif event.chat_id == iid and event.sender_id == userss:
            pass
        else:
            return
    else:
        return

    res = sql.rm_afk(sender.id)
    if res:

        firstname = sender.first_name
        try:
            text = "**{} is no longer AFK !**".format(firstname)
            await event.reply(text, parse_mode="markdown")
        except BaseException:
            return
Ejemplo n.º 2
0
async def _(event):
    sender = await event.get_sender()
    approved_userss = approved_users.find({})
    for ch in approved_userss:
        iid = ch["id"]
        userss = ch["user"]
    if event.is_group:
        if await is_register_admin(event.input_chat, event.message.sender_id):
            pass
        elif event.chat_id == iid and event.sender_id == userss:
            pass
        else:
            return

    if event.text.startswith("/afk"):
        cmd = event.text[len("/afk "):]
        if cmd is not None:
            reason = cmd
        else:
            reason = ""
        fname = sender.first_name
        # print(reason)
        start_time = time.time()
        sql.set_afk(sender.id, reason, start_time)
        await event.reply("**{} is now AFK !**".format(fname),
                          parse_mode="markdown")
        return

    if sql.is_afk(sender.id):
        res = sql.rm_afk(sender.id)
        if res:
            firstname = sender.first_name
            text = "**{} is no longer AFK !**".format(firstname)
            await event.reply(text, parse_mode="markdown")
Ejemplo n.º 3
0
def no_longer_afk(update: Update, context: CallbackContext):
    user = update.effective_user
    message = update.effective_message

    if not user:  # ignore channels
        return

    res = sql.rm_afk(user.id)
    if res:
        if message.new_chat_members:  # dont say msg
            return
        firstname = update.effective_user.first_name
        try:
            text = "*{} is no longer AFK !*".format(firstname)
            update.effective_message.reply_text(text,
                                                parse_mode=ParseMode.MARKDOWN)
        except BaseException:
            return