Ejemplo n.º 1
0
async def set_afk(event):
    global IS_AFK
    global AFK_TIME
    global AFK_REASON

    last_seen_status = await event.client(
        GetPrivacyRequest(InputPrivacyKeyStatusTimestamp()))
    for rule in last_seen_status.rules:
        if isinstance(rule, PrivacyValueAllowAll):
            AFK_TIME = datetime.datetime.now()
        IS_AFK = True
    if event.args.reason:
        AFK_REASON = event.args.reason

    await event.edit("<b>I will be afk for a while!</b>" +
                     "\n<i>Reason:</i> {}".format(AFK_REASON)
                     if AFK_REASON else "<b>I will be afk for a while!</b>")
    raise StopPropagation
Ejemplo n.º 2
0
async def afk(event):
    global afk_time
    global ALLOW_SEEN_STATUS

    reason = None
    split_text = event.text.split(None, 1)

    if len(split_text) > 1:
        reason = split_text[1]

    if not USER_AFK:
        last_seen_status = await client(GetPrivacyRequest(InputPrivacyKeyStatusTimestamp()))
        if last_seen_status.rules or not isinstance(last_seen_status.rules, PrivacyValueAllowContacts):
            afk_time = datetime.datetime.now()

        USER_AFK.update({"yes": reason})
        if reason:
            await client.update_message(event, f"**I will be afk for a while.** \n __Reason__: {reason}")
            return

        await client.update_message(event, f"**I will be afk for a while.**")
Ejemplo n.º 3
0
async def _(event):
    reply = await event.get_reply_message()
    global USER_AFK
    global afk_time
    global last_afk_message
    global last_afk_msg
    global afk_start
    global afk_end
    global reason
    global pic
    USER_AFK = {}
    afk_time = None
    last_afk_message = {}
    last_afk_msg = {}
    afk_end = back
    start_1 = datetime.now()
    afk_start = start_1.replace(microsecond=0)
    reason = event.pattern_match.group(1)
    if reply:
        pic = await event.client.download_media(reply)
    else:
        pic = None
    if not USER_AFK:
        last_seen_status = await ultroid_bot(
            GetPrivacyRequest(InputPrivacyKeyStatusTimestamp()), )
        if isinstance(last_seen_status.rules, PrivacyValueAllowAll):
            afk_time = datetime.datetime.now()
        USER_AFK = f"yes: {reason} {pic}"
        if reason:
            try:
                if pic.endswith((".tgs", ".webp")):
                    await ultroid_bot.send_message(event.chat_id, file=pic)
                    await ultroid_bot.send_message(
                        event.chat_id,
                        get_string("afk_5").format(reason),
                    )
                else:
                    await ultroid_bot.send_message(
                        event.chat_id,
                        get_string("afk_5").format(reason),
                        file=pic,
                    )
            except BaseException:
                await ultroid_bot.send_message(
                    event.chat_id,
                    get_string("afk_5").format(reason),
                )
        else:
            try:
                if pic.endswith((".tgs", ".webp")):
                    await ultroid_bot.send_message(event.chat_id, file=pic)
                    await ultroid_bot.send_message(event.chat_id,
                                                   get_string("afk_6"))
                else:
                    await ultroid_bot.send_message(
                        event.chat_id,
                        get_string("afk_6"),
                        file=pic,
                    )
            except BaseException:
                await ultroid_bot.send_message(event.chat_id,
                                               get_string("afk_6"))
        await event.delete()
        try:
            if reason and pic:
                if pic.endswith((".tgs", ".webp")):
                    await ultroid_bot.send_message(LOG, file=pic)
                    await ultroid_bot.send_message(
                        LOG,
                        get_string("afk_7").format(reason),
                    )
                else:
                    await ultroid_bot.send_message(
                        LOG,
                        get_string("afk_7").format(reason),
                        file=pic,
                    )
            elif reason:
                await ultroid_bot.send_message(
                    LOG,
                    get_string("afk_7").format(reason))
            elif pic:
                if pic.endswith((".tgs", ".webp")):
                    await ultroid_bot.send_message(LOG, file=pic)
                    await ultroid_bot.send_message(LOG, get_string("afk_8"))
                else:
                    await ultroid_bot.send_message(LOG,
                                                   get_string("afk_8"),
                                                   file=pic)
            else:
                await ultroid_bot.send_message(LOG, get_string("afk_8"))
        except BaseException:
            pass