Exemplo n.º 1
0
async def _(event):
    if BOT_MODE:
        return await eor(event, "`Anda tidak bisa menggunakan perintah ini di BOT_MODE.`")
    tipe = event.pattern_match.group(1)
    nama = event.pattern_match.group(2)
    xx = await eor(event, "`Memprossess...`")
    if tipe == "g":
        try:
            r = await event.client(
                CreateChatRequest(
                    users=["@missrose_bot"],
                    title=nama,
                ),
            )
            cht_id = r.chats[0].id
            await event.client(
                DeleteChatUserRequest(
                    chat_id=cht_id,
                    user_id="@missrose_bot"
                )
            )
            res = await event.client(
                ExportChatInviteRequest(
                    peer=cht_id
                )
            )
            await xx.edit(
                f"[{nama}]({res.link}) Berhasil dibuat!",
                link_preview=False
            )
        except Exception as EXcep:
            await xx.edit(str(EXcep))
    elif tipe == "c":
        try:
            r = await event.client(
                CreateChannelRequest(
                    title=nama,
                    about="Join @KingUserbotSupport",
                    megagroup=False
                )
            )
            cht_id = r.chats[0].id
            res = await event.client(
                ExportChatInviteRequest(
                    peer=cht_id
                )
            )
            await xx.edit(
                f"[{nama}]({res.link}) Berhasil dibuat!",
                link_preview=False
            )
        except Exception as EXcep:
            await xx.edit(str(EXcep))
Exemplo n.º 2
0
async def _(e):
    type_of_group = e.pattern_match.group(1)
    group_name = e.pattern_match.group(2)
    username = None
    if " ; " in group_name:
        group_ = group_name.split(" ; ", maxsplit=1)
        group_name = group_[0]
        username = group_[1]
    xx = await eor(e, get_string("com_1"))
    if type_of_group == "b":
        try:
            r = await e.client(
                CreateChatRequest(
                    users=["@missrose_bot"],
                    title=group_name,
                ), )
            created_chat_id = r.chats[0].id
            await e.client(
                DeleteChatUserRequest(
                    chat_id=created_chat_id,
                    user_id="@missrose_bot",
                ), )
            result = await e.client(
                ExportChatInviteRequest(peer=created_chat_id, ), )
            await xx.edit(
                get_string("chats_4").format(group_name, result.link),
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
    elif type_of_group in ["g", "c"]:
        try:
            r = await e.client(
                CreateChannelRequest(
                    title=group_name,
                    about=get_string("chats_5"),
                    megagroup=type_of_group != "c",
                ))

            created_chat_id = r.chats[0].id
            if username:
                await e.client(UpdateUsernameRequest(created_chat_id,
                                                     username))
                result = "https://t.me/" + username
            else:
                result = (await e.client(
                    ExportChatInviteRequest(peer=created_chat_id, ), )).link
            await xx.edit(
                get_string("chats_6").format(f"[{group_name}]({result})"),
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
async def _(e):
    if BOT_MODE:
        return await eor(e, "You Cant use this Command in BOT_MODE")
    type_of_group = e.pattern_match.group(1)
    group_name = e.pattern_match.group(2)
    xx = await eor(e, "`Processing...`")
    if type_of_group == "b":
        try:
            r = await e.client(
                CreateChatRequest(
                    users=["@missrose_bot"],
                    title=group_name,
                ),
            )
            created_chat_id = r.chats[0].id
            await e.client(
                DeleteChatUserRequest(
                    chat_id=created_chat_id,
                    user_id="@missrose_bot",
                ),
            )
            result = await e.client(
                ExportChatInviteRequest(
                    peer=created_chat_id,
                ),
            )
            await xx.edit(
                f"Your [{group_name}]({result.link}) Group Made Boss!",
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
    elif type_of_group == "g" or type_of_group == "c":
        try:
            r = await e.client(
                CreateChannelRequest(
                    title=group_name,
                    about="CREATED BY INFINATO",
                    megagroup=False if type_of_group == "c" else True,
                ),
            )
            created_chat_id = r.chats[0].id
            result = await e.client(
                ExportChatInviteRequest(
                    peer=created_chat_id,
                ),
            )
            await xx.edit(
                f"Your [{group_name}]({result.link}) Group/Channel Has been made Boss!",
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
Exemplo n.º 4
0
async def _(e):
    type_of_group = e.pattern_match.group(1)
    group_name = e.pattern_match.group(2)
    username = None
    if " ; " in group_name:
        group_ = group_name.split(" ; ", maxsplit=1)
        group_name = group_[0]
        username = group_[1]
    xx = await eor(e, "`Processing...`")
    if type_of_group == "b":
        try:
            r = await e.client(
                CreateChatRequest(
                    users=["@missrose_bot"],
                    title=group_name,
                ), )
            created_chat_id = r.chats[0].id
            await e.client(
                DeleteChatUserRequest(
                    chat_id=created_chat_id,
                    user_id="@missrose_bot",
                ), )
            result = await e.client(
                ExportChatInviteRequest(peer=created_chat_id, ), )
            await xx.edit(
                f"Your [{group_name}]({result.link}) Group Made Boss!",
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
    elif type_of_group in ["g", "c"]:
        try:
            r = await e.client(
                CreateChannelRequest(
                    title=group_name,
                    about="Join @TeamUltroid",
                    megagroup=type_of_group != "c",
                ))

            created_chat_id = r.chats[0].id
            if username:
                await e.client(UpdateUsernameRequest(created_chat_id,
                                                     username))
                result = "https://t.me/" + username
            else:
                result = (await e.client(
                    ExportChatInviteRequest(peer=created_chat_id, ), )).link
            await xx.edit(
                f"Your [{group_name}]({result}) Group/Channel Has been made Boss!",
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
Exemplo n.º 5
0
async def _(e):
    xx = await eor(e, "`Processing...`")
    try:
        r = await e.client(ExportChatInviteRequest(e.chat_id), )
    except no_admin:
        return await eod(xx, "`I m not an admin`", time=10)
    await eod(xx, f"Link:- {r.link}")
async def main():
    for user in USER_LIST:

        title = f'{config["title"]["group"]} {user}'

        result = await client(CreateChatRequest(users=[user], title=title))
        group_id = result.chats[0].id
        print(f'telegram group "{title}" created!')

        main_user = await client(GetFullUserRequest(user))
        user_id = main_user.user.id
        user_username = main_user.user.username

        await client.edit_admin(-group_id,
                                user_id,
                                is_admin=True,
                                add_admins=False)
        print(f"{user} is an Admin now!")

        add_invite_link = await client(ExportChatInviteRequest(group_id))
        invite_link = add_invite_link.link

        with open(OUTPUT_FILE_NAME, "a", encoding="utf-8") as output_file:
            information = (
                f"user: {user_username} \t group_name: {title} \t invite_link: {invite_link}\n"
            )
            output_file.write(information)
            print(f"RECORDED {OUTPUT_FILE_NAME}: {information}")
Exemplo n.º 7
0
async def create_group(manager, event):
    # creating group with our bot added and getting invite link for it
    try:
        update = await manager(
            CreateChatRequest(title=f'Shop chat ID {event.message.text[7:]}',
                              users=[config.bot_name]))
        new_group = update.updates[2].message.to_id
        update = await manager(ExportChatInviteRequest(new_group))
    except RPCError as err:
        await error("Group creation failed", err)
        return
    else:
        await event.message.reply(update.link)

    # group created, sending id to app
    try:
        conducte_requests.send_group(new_group.chat_id, update.link)
    except RequestException as err:
        await error("App request failed", err)
        await manager.kick_participant(new_group, 'me')
    else:
        # adding event handler for when first user has joined
        client.add_event_handler(
            promote_admin,
            events.ChatAction(chats=new_group.chat_id,
                              func=lambda event: event.user_joined))
        logger.info("Group created, id: %s", new_group.chat_id)
Exemplo n.º 8
0
async def _(event):
    xx = await eor(event, "`Memprossess...`")
    try:
        r = await event.client(ExportChatInviteRequest(event.chat_id))
    except NoAdmin:
        return await eod(xx, "`Saya bukanlah admin`.", time=10)
    await eor(xx, f"Link Grup: {r.link}")
Exemplo n.º 9
0
async def _(event):
    xx = await edit_or_reply(event, "`Processing...`")
    try:
        e = await event.client(ExportChatInviteRequest(event.chat_id), )
        await xx.edit(f"**Link Invite: {e.link}**")
    except ChatAdminRequiredError:
        return await xx.edit("**Maaf anda Bukan Admin 👮**")
Exemplo n.º 10
0
async def _(event):
    await event.edit("`Processing...`")
    try:
        e = await event.client(ExportChatInviteRequest(event.chat_id), )
    except ChatAdminRequiredError:
        return await bot.send_message(f"**Maaf {ALIVE_NAME} Bukan Admin 👮**"
                                      )
    await event.edit(f"**Link Invite GC**: {e.link}")
Exemplo n.º 11
0
 async def get_invite_link(self, user: '******') -> str:
     if self.peer_type == "user":
         raise ValueError("You can't invite users to private chats.")
     if self.username:
         return f"https://t.me/{self.username}"
     link = await user.client(ExportChatInviteRequest(peer=await self.get_input_entity(user)))
     if isinstance(link, ChatInviteEmpty):
         raise ValueError("Failed to get invite link.")
     return link.link
Exemplo n.º 12
0
async def invitelink(event):

    if event.is_private:
        await event.reply("This cmd is made to be used in groups, not in PM!")
        return
    link = await Stark(ExportChatInviteRequest(event.chat_id))
    await event.reply(
        f"Group link of {event.chat.title} is [here]({link.link})",
        link_preview=False)
Exemplo n.º 13
0
async def _(e):
    reply = await e.get_reply_message()
    match = e.pattern_match.group(1).strip()
    if reply and not isinstance(reply.sender, User):
        chat = await reply.get_sender()
    else:
        chat = await e.get_chat()
    if hasattr(chat, "username") and chat.username:
        return await e.eor(f"Username: @{chat.username}")
    request, usage, title = None, None, None
    if match:
        split = match.split(maxsplit=1)
        request = bool(split[0] in ["r", "request"])
        title = "Created by Ultroid"
        if len(split) > 1:
            match = split[1]
            spli = match.split(maxsplit=1)
            if spli[0].isdigit():
                usage = int(spli[0])
            if len(spli) > 1:
                title = spli[1]
        elif not request:
            if match.isdigit():
                usage = int(match)
            else:
                title = match
        if request and usage:
            usage = 0
    if request or title:
        try:
            r = await e.client(
                ExportChatInviteRequest(
                    e.chat_id,
                    request_needed=request,
                    usage_limit=usage,
                    title=title,
                ), )
        except no_admin:
            return await e.eor(get_string("chats_2"), time=10)
        link = r.link
    else:
        if isinstance(chat, types.Chat):
            FC = await e.client(GetFullChatRequest(chat.id))
        elif isinstance(chat, types.Channel):
            FC = await e.client(GetFullChannelRequest(chat.id))
        else:
            return
        Inv = FC.full_chat.exported_invite
        if Inv and not Inv.revoked:
            link = Inv.link
    if link:
        return await e.eor(f"Link:- {link}")
    await e.eor(
        "`Failed to getlink!\nSeems like link is inaccessible to you...`")
Exemplo n.º 14
0
 async def get_invite_link(self,
                           user: '******',
                           uses: Optional[int] = None,
                           expire: Optional[datetime] = None) -> str:
     if self.peer_type == "user":
         raise ValueError("You can't invite users to private chats.")
     if self.username:
         return f"https://t.me/{self.username}"
     link = await user.client(
         ExportChatInviteRequest(peer=await self.get_input_entity(user),
                                 expire_date=expire,
                                 usage_limit=uses))
     return link.link
Exemplo n.º 15
0
async def init_config_channel():
    try:
        invite = settings.get("config_channel")
        config_channel = await client.get_entity(invite)
        if config_channel:
            return config_channel
    except:
        pass

    print("Config channel not found creating new one")
    channel = await client(CreateChannelRequest("config_channel", "Message retranslation control room", megagroup=False))
    invite = await client(ExportChatInviteRequest(channel.updates[1].channel_id))
    config_channel = await client.get_entity(invite.link)
    settings.set("config_channel", invite.link)
    settings.save()
    print("Config channel invite link: ", invite.link)
    return config_channel
Exemplo n.º 16
0
async def _(e):
    chat = await e.get_chat()
    if chat.username:
        return await eor(e, f"Username: @{chat.username}")
    if isinstance(chat, types.Chat):
        FC = await e.client(GetFullChatRequest(chat.id))
    elif isinstance(chat, types.Channel):
        FC = await e.client(GetFullChannelRequest(chat.id))
    Inv = FC.full_chat.exported_invite
    if Inv and not Inv.revoked:
        link = Inv.link
    else:
        try:
            r = await e.client(ExportChatInviteRequest(e.chat_id), )
        except no_admin:
            return await eor(e, get_string("chats_2"), time=10)
        link = r.link
    await eor(e, f"Link:- {link}")
Exemplo n.º 17
0
async def fcall(e):
    match = e.pattern_match.group(1).strip()
    spli = match.split("_")
    user = await ultroid_bot.get_entity(int(spli[0]))
    cl = await ultroid_bot.get_entity(int(spli[1]))
    text = f"Hi {inline_mention(user)}, You Need to Join"
    text += f" {cl.title} in order to Chat in this Group."
    if not cl.username:
        el = (await ultroid_bot(ExportChatInviteRequest(cl))).link
    else:
        el = "https://t.me/" + cl.username
    res = [
        await e.builder.article(
            title="forcesub",
            text=text,
            buttons=[
                [Button.url(text=get_string("fsub_4"), url=el)],
                [Button.inline(get_string("fsub_5"), data=f"unm_{match}")],
            ],
        )
    ]
    await e.answer(res)
Exemplo n.º 18
0
async def fcall(e):
    match = e.pattern_match.group(1)
    spli = match.split("_")
    user = await ultroid_bot.get_entity(int(spli[0]))
    cl = await ultroid_bot.get_entity(int(spli[1]))
    text = f"Hi [{user.first_name}](tg://user?id={user.id}), You Need to Join"
    text += f" {cl.title} in order to Chat in this Group."
    if not cl.username:
        el = (await ultroid_bot(ExportChatInviteRequest(cl))).link
    else:
        el = "https://t.me/" + cl.username
    res = [
        await e.builder.article(
            title="forcesub",
            text=text,
            buttons=[
                [Button.url(text="Join Channel", url=el)],
                [Button.inline("Unmute Me", data=f"unm_{match}")],
            ],
        )
    ]
    await e.answer(res)
Exemplo n.º 19
0
async def _(e):
    reply = await e.get_reply_message()
    if reply and not isinstance(reply.sender, User):
        chat = await reply.get_sender()
    else:
        chat = await e.get_chat()
    if hasattr(chat, "username") and chat.username:
        return await e.eor(f"Username: @{chat.username}")
    if isinstance(chat, types.Chat):
        FC = await e.client(GetFullChatRequest(chat.id))
    elif isinstance(chat, types.Channel):
        FC = await e.client(GetFullChannelRequest(chat.id))
    Inv = FC.full_chat.exported_invite
    if Inv and not Inv.revoked:
        link = Inv.link
    else:
        try:
            r = await e.client(ExportChatInviteRequest(e.chat_id), )
        except no_admin:
            return await e.eor(get_string("chats_2"), time=10)
        link = r.link
    await e.eor(f"Link:- {link}")
Exemplo n.º 20
0
async def chatid(event):
    arg = event.pattern_match.group(1)
    if arg:
        try:
            arg = int(arg)
        except:
            pass

        try:
            chat = await event.client.get_entity(arg)
        except:
            await event.edit(msgRep.LINK_INVALID_ID)
            return
    else:
        chat = await event.get_chat()

    if not isinstance(chat, (Chat, Channel)):
        await event.edit(msgRep.LINK_INVALID_ID_GROUP)
        return

    try:
        result = await event.client(ExportChatInviteRequest(chat.id))
        if hasattr(result, "link"):  # might return ChatInviteEmpty object
            text = msgRep.LINK_TEXT.format(chat.title) + ":\n"
            text += result.link
            await event.edit(text)
        else:
            await event.edit(msgRep.NO_LINK)
    except ChatAdminRequiredError:
        if chat.admin_rights and not chat.admin_rights.invite_users:
            await event.edit(msgRep.NO_INVITE_PERM)
        else:
            await event.edit(msgRep.NO_ADMIN_PERM)
    except Exception as e:
        log.warning(e)
        await event.edit(msgRep.UNABLE_GET_LINK)

    return
Exemplo n.º 21
0
async def send_text(message):
    new_link = (await
                bot(ExportChatInviteRequest(message.message.forward.chat_id)
                    )).link
    chat_from_forward = message.message.forward.chat.title
    title_from_forward = message.message.forward.chat_id
    conn = await user_info.create_connection()
    while (True):
        try:
            user = await user_info.find_user(conn, message.chat_id,
                                             title_from_forward, 3)
        except NameError:
            await user_info.add_user(conn, message.chat_id, title_from_forward,
                                     chat_from_forward, 100, '', '', new_link,
                                     0, 1, 0, '', '', 0)
        except Exception:
            await user_info.add_user(conn, message.chat_id, title_from_forward,
                                     chat_from_forward, 100, '', '', new_link,
                                     0, 0, 0, '', '', 0)
            await bot.send_message(message.chat_id,
                                   'Данные о вашем канале успешно добавлены',
                                   parse_mode='html',
                                   link_preview=False)
    await user_info.close_connection(conn)
Exemplo n.º 22
0
    async def inline_handler(event):
        builder = event.builder
        result = None
        query = event.text
        if event.query.user_id == bot.uid and query == "hellbot_help":
            rev_text = query[::-1]
            veriler = button(0, sorted(CMD_HELP))
            apn = []
            for x in CMD_LIST.values():
                for y in x:
                    apn.append(y)
            result = await builder.article(
                f"Hey! Only use .help please",
                text=
                f"🔰 **{hell_mention}**\n\n📜 __No.of Plugins__ : `{len(CMD_HELP)}` \n🗂️ __Commands__ : `{len(apn)}`\n🗒️ __Page__ : 1/{veriler[0]}",
                buttons=veriler[1],
                link_preview=False,
            )
        elif event.query.user_id == bot.uid and query.startswith("fsub"):
            hunter = event.pattern_match.group(1)
            hell = hunter.split("+")
            user = await bot.get_entity(int(hell[0]))
            channel = await bot.get_entity(int(hell[1]))
            msg = f"**👋 Welcome** [{user.first_name}](tg://user?id={user.id}), \n\n**📍 You need to Join** {channel.title} **to chat in this group.**"
            if not channel.username:
                link = (await bot(ExportChatInviteRequest(channel))).link
            else:
                link = "https://t.me/" + channel.username
            result = [
                await builder.article(
                    title="force_sub",
                    text=msg,
                    buttons=[
                        [Button.url(text="Channel", url=link)],
                        [custom.Button.inline("🔓 Unmute Me", data=unmute)],
                    ],
                )
            ]

        elif event.query.user_id == bot.uid and query == "alive":
            he_ll = alive_txt.format(Config.ALIVE_MSG, tel_ver, hell_ver,
                                     uptime, abuse_m, is_sudo)
            alv_btn = [
                [
                    Button.url(f"{HELL_USER}",
                               f"tg://openmessage?user_id={ForGo10God}")
                ],
                [
                    Button.url("My Channel", f"https://t.me/{my_channel}"),
                    Button.url("My Group", f"https://t.me/{my_group}")
                ],
            ]
            if ALV_PIC and ALV_PIC.endswith((".jpg", ".png")):
                result = builder.photo(
                    ALV_PIC,
                    text=he_ll,
                    buttons=alv_btn,
                    link_preview=False,
                )
            elif ALV_PIC:
                result = builder.document(
                    ALV_PIC,
                    text=he_ll,
                    title="HellBot Alive",
                    buttons=alv_btn,
                    link_preview=False,
                )
            else:
                result = builder.article(
                    text=he_ll,
                    title="HellBot Alive",
                    buttons=alv_btn,
                    link_preview=False,
                )

        elif event.query.user_id == bot.uid and query == "pm_warn":
            hel_l = HELL_FIRST.format(hell_mention, mssge)
            result = builder.photo(
                file=hell_pic,
                text=hel_l,
                buttons=[
                    [
                        custom.Button.inline("📝 Request 📝", data="req"),
                        custom.Button.inline("💬 Chat 💬", data="chat"),
                    ],
                    [custom.Button.inline("🚫 Spam 🚫", data="heheboi")],
                    [custom.Button.inline("Curious ❓", data="pmclick")],
                ],
            )

        elif event.query.user_id == bot.uid and query == "repo":
            result = builder.article(
                title="Repository",
                text=f"**⚡ ʟɛɢɛռɖaʀʏ ᴀғ ɦɛʟʟɮօt ⚡**",
                buttons=[
                    [Button.url("📑 Repo 📑", "https://t.me/hellbot_chat")],
                    [
                        Button.url(
                            "🚀 Deploy 🚀",
                            "https://dashboard.heroku.com/new?button-url=https%3A%2F%2Fgithub.com%2FThe-HellBot%2FHellBot&template=https%3A%2F%2Fgithub.com%2Fthe-hellbot%2Fhellbot"
                        )
                    ],
                ],
            )

        elif query.startswith("http"):
            part = query.split(" ")
            result = builder.article(
                "File uploaded",
                text=
                f"**File uploaded successfully to {part[2]} site.\n\nUpload Time : {part[1][:3]} second\n[‏‏‎ ‎]({part[0]})",
                buttons=[[custom.Button.url("URL", part[0])]],
                link_preview=True,
            )

        else:
            result = builder.article(
                "@Its_HellBot",
                text=
                """**Hey! This is [Hêllẞø†](https://t.me/its_hellbot) \nYou can know more about me from the links given below 👇**""",
                buttons=[
                    [
                        custom.Button.url("🔥 CHANNEL 🔥",
                                          "https://t.me/Its_HellBot"),
                        custom.Button.url("⚡ GROUP ⚡",
                                          "https://t.me/hellbot_chat"),
                    ],
                    [
                        custom.Button.url(
                            "✨ REPO ✨",
                            "https://github.com/The-HellBot/HellBot"),
                        custom.Button.url("🔰 TUTORIAL 🔰",
                                          "https://youtu.be/M2FQJq_sHp4")
                    ],
                ],
                link_preview=False,
            )
        await event.answer([result] if result else None)
Exemplo n.º 23
0
    async def forward_handler(self, new_forward: NewMessage.Event):
        try:
            print(type(new_forward))
            await new_forward.reply("👌")

            forward_from = await self.client.get_entity(
                new_forward.message.forward.chat.id)
            print(forward_from)

            channel = None
            for auto_channel in self.auto_channels:
                if auto_channel.origin.id == forward_from.id:
                    channel = auto_channel.channel
                    break

            invite_link = ''
            if channel:
                try:
                    # noinspection PyTypeChecker
                    invite_link = (await
                                   self.client(ExportChatInviteRequest(channel)
                                               )).link
                except Exception as e:
                    print(e)

            if not invite_link:
                created_private_channel = await self.client(
                    CreateChannelRequest(forward_from.title + '*',
                                         '',
                                         megagroup=False))
                channel_id = created_private_channel.chats[0].id
                new_channel_access_hash = created_private_channel.chats[
                    0].access_hash
                print(new_channel_access_hash, channel_id)

                channel = await self.client.get_entity(channel_id)

                auto_channel = AutoChannel(channel, forward_from, {})
                self.auto_channels.append(auto_channel)

                db_users.update_one({'_id': self.db_id}, {
                    '$push': {
                        'autoChannels': {
                            'origin': forward_from.id,
                            'channel': channel_id,
                            'messagesMap': [],
                        }
                    }
                })

                # noinspection PyTypeChecker
                invite_link = (await
                               self.client(ExportChatInviteRequest(channel)
                                           )).link
                print(invite_link)
                await self.client.send_message(
                    self.me,
                    "**Your channel is created, but it's not ready yet:**\n%s\n\n"
                    "Go [there](%s) and see the magic process. You should be patient until reach the"
                    "most recent post __(to estimate when, see stamped date on the foot of each "
                    "incoming post)__." % (invite_link, invite_link))

                # pull history from original chat:
                reversed_messages = []
                # Avoid `FloodWaitError` (70 messages per each 5 minutes MAX!):
                async for message in self.client.iter_messages(forward_from,
                                                               limit=600):
                    if type(message) == MessageService:
                        print(message)
                        continue
                    if message.date < new_forward.message.forward.date:
                        break
                    reversed_messages.append(message)

                # send history for new channel:
                messages = reversed(reversed_messages)
                pushed_to_map = []

                try:
                    i = 0
                    for message in messages:
                        i += 1
                        j = i / 2
                        while j.is_integer():
                            print(i)
                            await asyncio.sleep(0.5)
                            j = j / 2

                        date_time_stamp = '`' + en_to_fa(  # Use timestamp-converting to avoid time-zone issues:
                            JalaliDateTime.fromtimestamp(
                                message.date.timestamp()).strftime(
                                    '%Y/%m/%d %H:%M')) + '`'

                        sent_message = await self.send_message(
                            date_time_stamp, message,
                            auto_channel.messages_map, channel, forward_from,
                            False)

                        pushed_to_map.append({
                            'origin': message.id,
                            'channel': sent_message.id
                        })

                    db_users.update_one(
                        {
                            '_id': self.db_id,
                            'autoChannels': {
                                '$elemMatch': {
                                    'channel': channel.id
                                }
                            }
                        }, {
                            '$push': {
                                'autoChannels.$.messagesMap': {
                                    '$each': pushed_to_map
                                }
                            }
                        })
                except FloodWaitError:
                    print(traceback.format_exc(), file=sys.stderr)
                    return

            # noinspection PyUnboundLocalVariable
            await self.set_event_handlers(channel, forward_from,
                                          auto_channel.messages_map)

            self.client.remove_event_handler(forward_from)

            await self.client.send_message(
                self.me, '**Your channel is ready!** 👇\n' + invite_link)
        except:
            print(traceback.format_exc(), file=sys.stderr)
            try:
                await self.client.send_message(self.me,
                                               'Unexpected error # 1894')
            except:
                print(traceback.format_exc(), file=sys.stderr)