Ejemplo n.º 1
0
def afk(update: Update, context: CallbackContext):
    args = update.effective_message.text.split(None, 1)
    user = update.effective_user

    if not user:  # ignore channels
        return

    if user.id == 777000:
        return
    fname = update.effective_user.first_name
    notice = ""
    if len(args) >= 2:
        reason = args[1]
        if len(reason) > 100:
            reason = reason[:100]
            notice = "{fname} your afk reason was shortened to 100 characters."
    else:
        reason = ""
    start_time = time.time()
    sql.set_afk(update.effective_user.id, reason, start_time)
    fname = update.effective_user.first_name
    try:
        update.effective_message.reply_text("*{} is now AFK !*\n\n{}".format(
            fname, notice),
                                            parse_mode=ParseMode.MARKDOWN)
    except BadRequest:
        pass
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
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

    cmd = event.pattern_match.group(1)

    if cmd is not None:
        reason = cmd
    else:
        reason = ""

    fname = sender.first_name

    notice = ""
    if len(reason) > 100:
        reason = reason[:100]
        notice = "{fname} your afk reason was shortened to 100 characters."
    else:
        reason = cmd

    # print(reason)
    start_time = time.time()
    sql.set_afk(sender.id, reason, start_time)

    try:
        await event.reply(
            "**{} is now AFK !**\n\n{}".format(fname, notice),
            parse_mode="markdown",
        )
    except Exception:
        pass