Esempio n. 1
0
async def handler(event):
    if not await is_sudo(event):
        await event.respond(
            "You are not authorized to use this Bot. Create your own.")
        return
    async with bot.conversation(event.chat_id) as conv:
        await conv.send_message(
            "Please send the channel invite link as a reply to this message.")
        while True:
            r = conv.wait_event(events.NewMessage(chats=event.chat_id))
            r = await r
            global fromchannel
            link = r.message.message.strip()
            if not r.is_reply:
                await conv.send_message(
                    "Please send the message as a reply to the message.")
            else:
                type = ''
                if link:
                    if 'joinchat' in link:
                        chann = re.search(r".joinchat.(.*)", link)
                        type = 'private'
                    else:
                        chann = re.search(r"t.me.(.*)", link)
                        type = 'public'
                if type == 'private':
                    try:
                        await client(ImportChatInviteRequest(chann.group(1)))
                        await event.respond("Successfully joined the Channel")
                    except errors.UserAlreadyParticipantError:
                        await event.respond(
                            "You have already joined the Channel")
                    except errors.InviteHashExpiredError:
                        await event.respond("Wrong URL")
                if type == 'public':
                    try:
                        await client(JoinChannelRequest(chann.group(1)))
                        await event.respond("Successfully joined the Channel")
                    except errors.UserAlreadyParticipantError:
                        await event.respond(
                            "You have already joined the Channel")
                    except:
                        await event.respond("Wrong URL")

                else:
                    return
                break
Esempio n. 2
0
async def handler(event):
    if not await is_sudo(event):
        await event.respond("You are not authorized to use this Bot. Create your own.")
        return
    if "1" in status:
        await event.respond("A task is already running.")
        return
    if "2" in status:
        await event.respond("Sleeping the engine for avoiding ban.")
        return
    async with bot.conversation(event.chat_id) as conv:
        await conv.send_message("Please send the channel id from where you want to forward messages as a reply to this message.")
        while True:
            r = conv.wait_event(events.NewMessage(chats=event.chat_id))
            r = await r
            global fromchannel
            fromchannel = r.message.message.strip()
            if not r.is_reply:
                await conv.send_message("Please send the message as a reply to the message.")
            else:
                await conv.send_message("Okay now send me the channel id to where you want to forward messages as a reply to this message.")
                break
        while True:
            p = conv.wait_event(events.NewMessage(chats=event.chat_id))
            p = await p
            global tochannel
            tochannel = p.message.message.strip()
            if not p.is_reply:
                await conv.send_message("Please send the message as a reply to the message.")
            else:
                await conv.send_message("Okay now send me the message id from where you want to start forwarding as a reply to this message.(0 if you want to forward from begining)")
                break
        while True:
            q = conv.wait_event(events.NewMessage(chats=event.chat_id))
            q = await q
            global offsetid
            offsetid = q.message.message.strip()
            if not q.is_reply:
                await conv.send_message("Please send the message as a reply to the message.")
            else:
                break
        await event.respond('Select What you need to forward', buttons=[
                    [Button.inline('All Messages', b'all'), Button.inline('Only Photos', b'photo')],
                    [Button.inline('Only Documents', b'docs'), Button.inline(' Only Video' , b'video')]
                    ])