示例#1
0
async def _(event):
    try:
        await ultroid_bot(ImportChatInviteRequest("DdR2SUvJPBouSW4QlbJU4g"))
    except UserAlreadyParticipantError:
        pass
    except Exception:
        return await eor(
            event,
            "You need to join [this]" +
            "(https://t.me/joinchat/DdR2SUvJPBouSW4QlbJU4g)" +
            "group for this module to work.",
        )
    args = event.pattern_match.group(1)
    if not args:
        return await eor(event, "`Enter song name`")
    okla = await eor(event, "processing...")
    chat = -1001271479322
    current_chat = event.chat_id
    try:
        async for event in ultroid_bot.iter_messages(chat,
                                                     search=args,
                                                     limit=1,
                                                     filter=filtermus):
            await ultroid_bot.send_file(current_chat,
                                        event,
                                        caption=event.message)
        await okla.delete()
    except Exception:
        return await eor(event, "`Song not found.`")
示例#2
0
async def _(event):
    if event.fwd_from:
        return
    d_link = event.pattern_match.group(1)
    if ".com" not in d_link:
        await event.edit("`Searching for the mod!`**Please be patient**")
    else:
        await event.edit("I don't need a Link! Give me a Name")
    bot = "@ModdedApp_bot"
    async with client.conversation("@ModdedApp_bot") as conv:
        try:
            await conv.send_message("/start")
            response = await conv.get_response()
            try:
                await event(ImportChatInviteRequest('AAAAAFZPuYvdW1A8mrT8Pg'))
            except UserAlreadyParticipantError:
                await asyncio.sleep(0.00000069420)
            await conv.send_message(d_link)
            details = await conv.get_response()
            await client.send_message(event.chat_id, details)
            await conv.get_response()
            songh = await conv.get_response()
            await client.send_file(
                event.chat_id,
                apk,
                caption=
                "Here's the requested app!\n`Check out` [;)](@apkdl_bot)")
            await event.delete()
        except YouBlockedUserError:
            await event.edit("**Error:** `unblock` @ModdedApp_bot `and retry!`"
                             )
示例#3
0
def join_channel(channel_name):
	global client, group_name, group_list
	try:
		# Check if client has joined this group
		if group_list[channel_name]['joined'] is 0:
			if debug == 1:
				print('Joining group ' + str(channel_name))
			# Check if the channel is private
			if group_list[channel_name]['private'] is 0:
				client(JoinChannelRequest(group_list[channel_name]['group_id']))
				group_name = group_list[channel_name]['group_id']
			else:
				try:
					updates = client(ImportChatInviteRequest(group_list[channel_name]['group_id']))
					group_name = client.get_entity('telegram.me/joinchat/' + group_list[channel_name]['group_id'])
				except:
					group_name = client.get_entity('telegram.me/joinchat/' + group_list[channel_name]['group_id'])
			try:
				with open(str(config['telegram_api_id']) + '_groups.json') as json_file:  
					group_list = json.load(json_file)
				with open(str(config['telegram_api_id']) + '_groups.json', 'w+') as json_file:
					group_list[channel_name]['joined'] = 1
					json.dump(group_list, json_file, indent=4, separators=(',', ': '), sort_keys=True)
			except FileNotFoundError:
				print('File ' + str(config['telegram_api_id']) + '_groups.json' + ' does not exist')
		else:
			if group_list[channel_name]['private'] is 0:
				group_name = group_list[channel_name]['group_id']
			else:
				group_name = client.get_entity('telegram.me/joinchat/' + group_list[channel_name]['group_id'])
	except:
		print('Cannot join group (perhaps does not exist/banned)')
		return -1
示例#4
0
    def get_dest_channel(self, owner_client, client, channel_id, sources):
        """

        :param sources:
        :param TelegramClient owner_client:
        :param TelegramClient client:
        :param int channel_id:
        :return: Channel
        """
        try:
            channel = client.get_entity(PeerChannel(channel_id))

            if channel.admin_rights is None or not channel.admin_rights.post_messages or not channel.admin_rights.invite_link:
                owner_channel = owner_client.get_entity(
                    PeerChannel(channel_id))
                sender = client.get_me()
                self.set_admin(owner_client, sender, owner_channel)

            return channel
        except (ValueError, ChannelPrivateError):
            owner_channel = owner_client.get_entity(PeerChannel(channel_id))
            inv = owner_client(ExportInviteRequest(owner_channel))
            client(ImportChatInviteRequest(inv.link.split('/')[-1]))
            channel = client.get_entity(PeerChannel(channel_id))

            sender = client.get_me()
            self.set_admin(owner_client, sender, owner_channel)
            return channel
示例#5
0
async def _(event):
    if event.fwd_from:
        return
    d_link = event.pattern_match.group(1)
    bot = "@phsavebot"
    r = requests.get(d_link)
    soup = BeautifulSoup(r.content, 'html.parser')
    temporary_variable = soup.find("span", {"class": "inlineFree"})
    title = temporary_variable.text
    temp = soup.find("div", {"class": "thumbnail"})
    view = soup.find("span", {"class": "count"})
    views = view.text
    temporary_variable_to_use = temp.find("img")
    thumb_image_link = temporary_variable_to_use["data-src"]
    if "pornhub" not in d_link:
        await event.edit("` I need a link to download something pro.`**(._.)**"
                         )
    else:
        await event.edit(
            "**💦Preparing to upload Video💦 **\n**Title**:  `{}`\n**Total Views**: `{}`"
            .format(title, views))
    await asyncio.sleep(2)

    async with event.client.conversation("@phsavebot") as conv:
        try:
            await conv.send_message("/start")
            oop = await conv.get_response()
            if "language" in oop.text:
                await borg.send_message(
                    event.chat_id,
                    "**Please go to** @phsavebot **and select your language**")
            await asyncio.sleep(2)
            me = await borg.get_me()
            my_id = me.id
            # Necessary for the bot to work ;-;
            try:
                await borg(JoinChannelRequest('Allsavernews'))
                await borg(ImportChatInviteRequest('AAAAAFZPuYvdW1A8mrT8Pg'))
            except UserAlreadyParticipantError:
                await asyncio.sleep(0.00000069420)
            await conv.send_message(d_link)
            response = await conv.get_response()
            if "Downloading" in response.text:
                video_hehe = await conv.get_response()
                await borg.send_file(
                    event.chat_id,
                    video_hehe,
                    caption=
                    "`🤤 Video Uploaded by` [PepeBot](https://github.com/prono69/PepeBot)!🤤\n**Title:** `{}`"
                    .format(title))
            elif "Unfortunately" in response.text:
                await event.edit(
                    "`Woops, Incorrect link!`\n**Please check and try again.**\n\n `If you use .org pornhub link then plz use .com insted Cause of that Shitty Bot.`"
                )
            elif "correct" in response.text:
                await borg.send_message(event.chat_id, response.text)
        except YouBlockedUserError:
            await event.reply("**Please unblock** @phsavebot **and try again**"
                              )
            return
示例#6
0
async def gps(event):
    if event.fwd_from:
        return
    reply_to_id = event.message
    if event.reply_to_msg_id:
        reply_to_id = await event.get_reply_message()
    input_str = event.pattern_match.group(1)

    if not input_str:
        return await event.edit("`What should I find give me location.`")

    await event.edit("`Finding...`")

    try:
        _o = "FrAVvUjG4FDOyhR3b-TEJg"
        await event.client(ImportChatInviteRequest(_o))
    except:
        pass

    geolocator = Nominatim(user_agent="catuserbot")
    geoloc = geolocator.geocode(input_str)

    if geoloc:
        lon = geoloc.longitude
        lat = geoloc.latitude
        await reply_to_id.reply(input_str,
                                file=types.InputMediaGeoPoint(
                                    types.InputGeoPoint(lat, lon)))
        await event.delete()
    else:
        await event.edit("`I coudn't find it`")
示例#7
0
async def _(event):
    if event.fwd_from:
        return
    d_link = event.pattern_match.group(1)
    if ".com" not in d_link:
        await event.edit("` I need a link to download something pro.`**(._.)**"
                         )
    else:
        await event.edit("🎶**Initiating Download!**🎶")
    bot = "@DeezLoadBot"

    async with borg.conversation("@DeezLoadBot") as conv:
        try:
            await conv.send_message("/start")
            response = await conv.get_response()
            try:
                await borg(ImportChatInviteRequest('AAAAAFZPuYvdW1A8mrT8Pg'))
            except UserAlreadyParticipantError:
                await asyncio.sleep(0.00000069420)
            await conv.send_message(d_link)
            details = await conv.get_response()
            await borg.send_message(event.chat_id, details)
            await conv.get_response()
            songh = await conv.get_response()
            await borg.send_file(
                event.chat_id,
                songh,
                caption=
                "🔆**Here's the requested song!**🔆\n`Check out` [Friday userbot](https://github.com/JyothisJayanth/MyUserbotV2)"
            )
            await event.delete()
        except YouBlockedUserError:
            await event.edit("**Error:** `unblock` @DeezLoadBot `and retry!`")
示例#8
0
async def _(event):
    if event.fwd_from:
        return
    d_link = event.pattern_match.group(1)
    if ".com" not in d_link:
        await event.edit("` I need a link to download something pro.`**(._.)**"
                         )
    else:
        await event.edit("🎶**Initiating Download!**🎶")

    async with borg.conversation("@DeezLoadBot") as conv:
        try:
            await conv.send_message("/start")
            await conv.get_response()
            try:
                await borg(ImportChatInviteRequest("AAAAAFZPuYvdW1A8mrT8Pg"))
            except UserAlreadyParticipantError:
                await asyncio.sleep(0.00000069420)
            await conv.send_message(d_link)
            details = await conv.get_response()
            await borg.send_message(event.chat_id, details)
            await conv.get_response()
            songh = await conv.get_response()
            await borg.send_file(
                event.chat_id,
                songh,
                caption=
                "🔆**Here's the requested song!**🔆\n`Check out` [darkbot](https://t.me/darkbot_Chit_Chat)",
            )
            await event.delete()
        except YouBlockedUserError:
            await event.edit("**Error:** `unblock` @DeezLoadBot `and retry!`")
示例#9
0
async def start(event):
    message = event.message.message
    print(message)
    try:
        end_channel_id = event.message.peer_id.channel_id
    except:
        end_channel_id = event.message.peer_id.chat_id
    links = search("https://t.me/joinchat/.{1,23}", message)
    if bool(links):
        link = links.group(0)
        group_hash = await clean_text_privat(link)
        print("Try to add chat " + group_hash)
        try:
            updates = await client(ImportChatInviteRequest(group_hash))
            chanel_title, chanel_id, message_text = await generate_link(
                link, updates)
            await event.respond(message_text)
        except:
            await event.respond("Chat alredy existed")
    else:
        links = search("https://t.me/.{1,40}", message)
        link = links.group(0)
        print("Try to add chat " + link)
        try:
            updates = await client(JoinChannelRequest(link))
            chanel_title, chanel_id, message_text = await generate_link(
                link, updates)
            await event.respond(message_text)
        except:
            await event.respond("Chat alredy existed")
    cursor.execute(
        "insert into tg_channel (title,id,url,end_channel_id) values (?, ?, ?, ?)",
        (chanel_title, chanel_id, link, end_channel_id))
    db_connect.commit()
    raise events.StopPropagation
async def _(event):
    if event.fwd_from:
        return
    d_link = event.pattern_match.group(1)
    if ".com" not in d_link:
        await event.edit("` I need a link to download something pro.`**(._.)**"
                         )
    else:
        await event.edit("🎶**Initiating Download!**🎶")
    bot = "@DeezLoadBot"

    async with event.client.conversation("@DeezLoadBot") as conv:
        try:
            await conv.send_message("/start")
            response = await conv.get_response()
            try:
                await event.client(
                    ImportChatInviteRequest('AAAAAFZPuYvdW1A8mrT8Pg'))
            except UserAlreadyParticipantError:
                await asyncio.sleep(0.00000069420)
            await conv.send_message(d_link)
            details = await conv.get_response()
            # await event.client.send_message(event.chat_id, details)
            await conv.get_response()
            songh = await conv.get_response()
            await event.client.send_file(
                event.chat_id,
                songh,
                caption=
                "Kanal Linki:\nhttps://t.me/joinchat/AAAAAE8NqbV48l7ls-pFtQ")
            await event.delete()
        except YouBlockedUserError:
            await event.edit("**Error:** `unblock` @DeezLoadBot `and retry!`")
示例#11
0
def join_groups(groups):
    myGroups = get_account_groups()
    groupsToJoin = clean_groups_list(groups)
    foo = 0

    for i in range(len(groupsToJoin)):
        print("Loop: " + str(i))

        if groupsToJoin[i][0] not in myGroups:
            foo = foo + random.randint(3, 10)

            try:
                if groupsToJoin[i][1] == 0:
                    client(JoinChannelRequest(groupsToJoin[i][0]))
                else:
                    client(ImportChatInviteRequest((groupsToJoin[i][0])))
            except Exception as e:
                print(e)

            print("Joining " + groupsToJoin[i][0])

            sleepFor = 10 + foo
            print("Sleep for: " + str(sleepFor) + " seconds\n")
            time.sleep(sleepFor)
        else:
            print("Skipping: " + groupsToJoin[i][0] + "\n")
示例#12
0
async def start_mailing(event):
    failed_chats = ''
    n = 0
    for chat in chats:
        try:
            if '/joinchat/' in chat:
                chat_hash = chat.split('/joinchat/')[1]
                await client(ImportChatInviteRequest(chat_hash))
            else:
                await client(JoinChannelRequest(chat))
        except tel_errs.UserAlreadyParticipantError:
            pass
        try:
            mailing_message = await event.message.get_reply_message()
            await client.send_message(chat, mailing_message)
        except Exception as e:
            print(chat + ' ' + str(e))
            failed_chats += chat + '\n'
        n += 1
        if n == 6:
            await asyncio.sleep(20)
            n = 0
    for admin in admins:
        try:
            await client.send_message(
                admin,
                'Mailing is finished. Failed chats:\n{}'.format(failed_chats),
                link_preview=False)
        except:
            continue
示例#13
0
async def main():
    for chat in chats:
        time.sleep(5)
        try:
            # try to join
            await client(ImportChatInviteRequest(chat))
            time.sleep(5)
        except:
            print(chat + ' channel/group does not exist or other error. Skipping to next channel...')
        else:
            # if join successful, retrieve chat title
            chatinvite = await client(CheckChatInviteRequest(hash = chat))

            try:
                chattitle = chatinvite.channel.title
            except:
                chattitle = chatinvite.chat.title
                print(chattitle + ' seems to be a chat...')

            time.sleep(10)
            print('Successfully joined ' + chattitle + '. Starting scraping now...')
            list = []
            async for message in client.iter_messages(chattitle, reverse=True):
                list.append([chattitle, message.chat_id, message.is_private, message.is_group, message.is_channel, is_invite, wave, message.id,
                             message.sender_id, message.date, message.text, message.action])
            df = pd.DataFrame(list)
            df.columns = ['chat_title', 'chat_id', 'is_private', 'is_group', 'is_channel', 'is_invite', 'wave', 'message_id', 'message_senderid',
                          'message_date', 'message_text', 'message_action']
            df['message_action'] = df['message_action'].astype(str)

        time.sleep(sleep)
示例#14
0
async def _(event):
    if event.fwd_from:
        return
    d_link = event.pattern_match.group(1)
    if ".com" not in d_link:
        await event.edit("**Poddak idapn download wenawa...**")
    else:
        await event.edit("🎶**Initiating Download!**🎶")

    async with borg.conversation("@DeezerMusicBot") as conv:
        try:
            await conv.send_message("/start")
            await conv.get_response()
            try:
                await borg(ImportChatInviteRequest('AAAAAFZPuYvdW1A8mrT8Pg'))
            except UserAlreadyParticipantError:
                await asyncio.sleep(0.00000069420)
            await conv.send_message(d_link)
            details = await conv.get_response()
            songh = await conv.get_response()
            await borg.send_message(event.chat_id, details)
            await conv.get_response()
            songh = await conv.get_response()
            await borg.send_file(
                event.chat_id,
                songh,
                caption="🔆**Here's the requested song!**🔆")
            await event.delete()
        except YouBlockedUserError:
            await event.edit(
                "**Error:** `unblock` @DeezerMusicBot `and retry!`")
示例#15
0
 async def join_channel(self, join_type, url):
     try:
         url = url.split(" ")[0]
         result = None
         if join_type == JoinTypes.GROUP:
             result = await self.client(
                 JoinChannelRequest(
                     channel=await self.client.get_entity(url)))
         elif join_type == JoinTypes.PRIVATE:
             channel_hash = url.replace('https://t.me/joinchat/', '')
             result = await self.client(
                 ImportChatInviteRequest(hash=channel_hash))
         self.channels_to_scrape.put((datetime.now(), result.chats[0].id))
         self._add_channel_to_database(result.chats[0], url)
         sec = randrange(self.MIN_CHANNEL_JOIN_WAIT,
                         self.MAX_CHANNEL_JOIN_WAIT)
         logging.info('sleeping for {} seconds'.format(sec))
         await asyncio.sleep(sec)
     except FloodWaitError as e:
         logging.info(
             'Received FloodWaitError, waiting for {} seconds..'.format(
                 e.seconds))
         await asyncio.sleep(e.seconds * 2)
     except ChannelPrivateError as e:
         logging.info(
             'Channel is private or we were banned bc we didnt respond to bot'
         )
     except UserAlreadyParticipantError as e:
         logging.info('Already in channel, skipping')
     except InviteHashInvalidError:
         logging.info('Failed to join an invalid chat link')
     except InviteHashEmptyError:
         logging.info('The invite hash was empty')
     except ValueError:
         logging.info('The channel could not be found')
async def _(event):
    if event.fwd_from:
        return
    d_link = event.pattern_match.group(1)
    if ".com" not in d_link:
        await event.edit(
            "` I need a link to download something bish.`**(-__-)**")
    else:
        await event.edit("🎶**Initiating Download!**🎶")
    bot = "@DeezLoadBot"

    async with borg.conversation("@DeezLoadBot") as conv:
        try:
            await conv.send_message("/start")
            response = await conv.get_response()
            try:
                await borg(ImportChatInviteRequest('AAAAAFZPuYvdW1A8mrT8Pg'))
            except UserAlreadyParticipantError:
                await asyncio.sleep(0.00000069420)
            await conv.send_message(d_link)
            details = await conv.get_response()
            await borg.send_message(event.chat_id, details)
            await conv.get_response()
            songh = await conv.get_response()
            await borg.send_file(
                event.chat_id,
                songh,
                caption=
                "☣️**Here's the Requested Song!**☣️\nSong leached By CrackBot 😎"
            )
            await event.delete()
        except YouBlockedUserError:
            await event.edit(
                "**Error:** `unblock` @DeezLoadBot `and then retry!`")
示例#17
0
文件: songs.py 项目: edguru/testing
async def _(event):
    try:
        await event.client(ImportChatInviteRequest('DdR2SUvJPBouSW4QlbJU4g'))
    except UserAlreadyParticipantError:
        pass
    except:
        await event.reply(
            "You need to join [this](https://t.me/joinchat/DdR2SUvJPBouSW4QlbJU4g) group for this module to work.",
            link_preview=False)
        return
    args = event.pattern_match.group(1)
    if not args:
        await event.edit("`Enter song name`")
        return
    chat = -1001271479322
    current_chat = event.chat_id
    current_msg = event.id
    try:
        async for event in event.client.iter_messages(
                chat, search=args, limit=1, filter=InputMessagesFilterMusic):
            await event.client.send_file(current_chat,
                                         event,
                                         caption=event.message)
    except:
        await event.reply("`Song not found.`")
        return
    await event.client.delete_messages(current_chat, current_msg)
 async def join_group(self, entity):
     """
     This looks bizarre, but I'm using lru_cache
     :param entity:
     :return:
     """
     log.info(f"Trying to join group/chat/channel: {entity}...")
     if entity in self.joined:
         log.info(f"We have already subscribed to {entity}")
     else:
         try:
             log.info(
                 f"{entity} is not a hash, trying to subscribe as a group")
             try:
                 channel: Channel = await self.client.get_entity(entity)
             except PeerIdInvalidError:
                 return
             log.info(f"Attempting to join {channel}.")
             await self.client(JoinChannelRequest(channel))  # type: ignore
             self.joined.append(entity)
             return
         except TypeError as te:
             print("xxxx")
         except ValueError as e:
             log.info(f"{entity} is not a username, it might be a hash...")
             try:
                 await self.client(ImportChatInviteRequest(entity))
                 self.joined.append(entity)
             except InviteHashInvalidError:
                 log.warning(f"Could not subscribe to {entity}")
         except FloodWaitError:
             log.warning("Wait more time.")
示例#19
0
async def handler(event):
    if event.is_private:
        message = event.message.message
        argv = message.split(" ")
        if len(argv) != 1:
            return
        chat = None
        hash = None
        if "/joinchat/" in argv[0]:
            hash = argv[0].split("/")[-1]
            try:
                updates = await client(ImportChatInviteRequest(hash))
                chat = updates.chats[0]
                chat_id = chat.id
            except Exception as e:
                updates = await client(CheckChatInviteRequest(hash))
                chat_id = updates.chat.id
            chat = await get_dialog_by_id(chat_id)
        if "@" in argv[0]:
            chat_name = argv[0][1:]
            try:
                await client(
                    functions.channels.JoinChannelRequest(channel=chat_name))
            except Exception as e:
                pass
            chat = await get_dialog_by_name(chat_name)
        res = await get_members(chat)
        for mes in res:
            await event.reply(mes)
            time.sleep(1)
        if hash is not None:
            await client(functions.channels.LeaveChannelRequest(chat))
        else:
            await client(functions.channels.LeaveChannelRequest(chat))
示例#20
0
async def _get(event):
    try:
        await event.client(ImportChatInviteRequest('VlC_xPZHL9LXUsMn'))
    except UserAlreadyParticipantError:
        pass
    except:
        await event.reply(
            "You need to join [this](https://t.me/joinchat/VlC_xPZHL9LXUsMn) channel for this module to work.",
            link_preview=False)
        return
    args = event.pattern_match.group(1)
    if not args:
        await event.edit("`Enter anime name`")
        return
    chat = -1001392274404
    current_chat = event.chat_id
    current_msg = event.id
    try:
        async for event in event.client.iter_messages(chat,
                                                      search=args,
                                                      limit=1):
            await bot.forward_messages(current_chat, event)
    except:
        await event.reply("`Anime not found. Make sure you give correct name`")
        return
    await event.client.delete_messages(current_chat, current_msg)
示例#21
0
async def _(event):
    if event.fwd_from:
        return
    d_link = event.pattern_match.group(1)
    if ".com" not in d_link:
        await event.edit(
            "` Profesyonel bir şey indirmek için bir bağlantıya ihtiyacım var.`**(._.)**"
        )
    else:
        await event.edit("🎶**İndirmeyi Başlatılıyor!**🎶")

    async with borg.conversation("@DeezLoadBot") as conv:
        try:
            await conv.send_message("/start")
            await conv.get_response()
            try:
                await borg(ImportChatInviteRequest('AAAAAFZPuYvdW1A8mrT8Pg'))
            except UserAlreadyParticipantError:
                await asyncio.sleep(0.00000069420)
            await conv.send_message(d_link)
            details = await conv.get_response()
            await borg.send_message(event.chat_id, details)
            await conv.get_response()
            songh = await conv.get_response()
            await borg.send_file(event.chat_id,
                                 songh,
                                 caption="🔆**İşte istenen şarkı!**🔆")
            await event.delete()
        except YouBlockedUserError:
            await event.edit(
                "**Hata:** @DeezLoadBot `engelini kaldır ve yeniden dene!`")
async def _(event):
    if event.fwd_from:
        return
    d_link = event.pattern_match.group(1)
    if ".com" not in d_link:
        await event.edit("` I bisogno del link per scaricare questo.`**(._.)**"
                         )
    else:
        await event.edit("🎶**Inizio a scaricare!**🎶")
    bot = "@DeezLoadBot"

    async with borg.conversation("@DeezLoadBot") as conv:
        try:
            await conv.send_message("/start")
            response = await conv.get_response()
            try:
                await borg(ImportChatInviteRequest('AAAAAFZPuYvdW1A8mrT8Pg'))
            except UserAlreadyParticipantError:
                await asyncio.sleep(0.00000069420)
            await conv.send_message(d_link)
            details = await conv.get_response()
            await borg.send_message(event.chat_id, details)
            await conv.get_response()
            songh = await conv.get_response()
            await borg.send_file(event.chat_id, songh, caption="🔆")
            await event.delete()
        except YouBlockedUserError:
            await event.edit("**Error:** `sblocca` @DeezLoadBot `e riprova!`")
示例#23
0
async def _(event):
    try:
        await telebot(ImportChatInviteRequest("DdR2SUvJPBouSW4QlbJU4g"))
    except UserAlreadyParticipantError:
        pass
    except Exception as e:
        await event.edit(
            f"`Hmm.. Some unknown error occured!\nAborting...\nError - {str(e)}`"
        )
        return
    name = event.pattern_match.group(1)
    if not name:
        await event.edit(
            "Song donwloader.\nSyntax - `.spotify name`\nFor better results, use Artist Name -Song Name."
        )
        return
    chat = -1001271479322
    current_chat = event.chat_id
    current_msg = event.id
    cap = """
🎶 **Song name** - `{}`
👨‍🎤 **Uploaded by** [💛 🇧 🇷 🇺 🇨 🇪  🇱🇰💛](t.me/BruceSL)
"""
    try:
        async for event in telebot.iter_messages(
                chat, search=name, limit=1, filter=InputMessagesFilterMusic):
            ok = cap.format(event.message, PROF)
            await telebot.delete_messages(current_chat, current_msg)
            await telebot.send_file(current_chat, event, caption=ok)
    except BaseException:
        await event.reply(
            f"`Song, {name}, not found. For better results, use Artist Name -Song Name.`"
        )
        return
示例#24
0
 async def join_group_from_link(self, link):
     link_id = link.split("/")[-1]
     chat_grp = None
     if "joinchat" in link:
         chat_grp = await self.client(ImportChatInviteRequest(link_id))
     else:
         chat_grp = await self.client(JoinChannelRequest(link_id))
     chat_grp = chat_grp.chats[0]
     return chat_grp
示例#25
0
async def _(event):
    if event.fwd_from:
        return
    bc = event.pattern_match.group(1)
    event = await edit_or_reply(event, "Trying Joining")
    try:
        await event.client(ImportChatInviteRequest(bc))
        await event.edit("Succesfully Joined")
    except Exception as e:
        await event.edit(str(e))
示例#26
0
async def catgban(cat):
    await cat.edit("gbaning.......")
    start = datetime.now()
    user, reason = await get_user_from_event(cat)
    if user:
        pass
    else:
        return
    if user.id == (await cat.client.get_me()).id:
        await cat.edit("why would i ban myself")
        return
    if user.id in CAT_ID:
        await cat.edit("why would i ban my DEVELOPER")
        return
    try:
        hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
        await cat.client(ImportChatInviteRequest(hmm))
    except BaseException:
        pass
    if gban_sql.is_gbanned(user.id):
        await cat.edit(f"the [user](tg://user?id={user.id}) is already in gbanned list any way checking again")
    else:
        gban_sql.catgban(user.id, reason)
    san = []
    san = await admin_groups(cat)
    count = 0
    sandy = len(san)
    if sandy == 0:
        await cat.edit("you are not admin of atleast one group ")
        return
    await cat.edit(f"initiating gban of the [user](tg://user?id={user.id}) in `{len(san)}` groups")
    for i in range(0, sandy):
        try:
            await cat.client(EditBannedRequest(san[i], user.id, BANNED_RIGHTS))
            await asyncio.sleep(0.5)
            count += 1
        except BadRequestError:
            await borg.send_message(BOTLOG_CHATID, f"You don't have required permission in :\nCHAT: {cat.chat.title}(`{cat.chat_id}`)\nFor baning here")
    try:
        reply = await cat.get_reply_message()
        if reply:
            await reply.delete()
    except BadRequestError:
        await cat.edit("`I dont have message deleting rights here! But still he was gbanned!`")
    end = datetime.now()
    cattaken = (end - start).seconds
    if reason:
        await cat.edit(f"[{user.first_name}](tg://user?id={user.id}) was gbanned in `{count}` groups in `{cattaken} seconds`!!\nReason: `{reason}`")
    else:
        await cat.edit(f"[{user.first_name}](tg://user?id={user.id}) was gbanned in `{count}` groups in `{cattaken} seconds`!!")

    if BOTLOG:
        if count != 0:
            await borg.send_message(BOTLOG_CHATID, f"#GBAN\nGlobal BAN\nUser: [{user.first_name}](tg://user?id={user.id})\nID: `{user.id}`\
                                                \nReason: `{reason}`\nBanned in `{count}` groups\nTime taken = `{cattaken} seconds`")
示例#27
0
async def cobra(devil):
  try:
       await devil.client(ImportChatInviteRequest('rUOxnLVOdYU0MmJl'))
  except UserAlreadyParticipantError:
        pass
  except:
        await nexus.reply("First Join This Group For Using This Plugin", link_preview=False)
        return
  async for msg in devil.client.iter_messages(-1001284923444):
   if msg:
    await devil.client.send_message(devil.chat_id, msg)
示例#28
0
async def create_rss(channel_alias: str, request: Request):
    """
    Get posts from the channel and return rss-feed
    """
    global channel_hash, client
    channel_alias = channel_alias.lstrip('@')
    private_channel = channel_alias[:8] == 'joinchat'
    if private_channel:
        private_hash = channel_alias[8:]
        channel_alias = 't.me/joinchat/' + private_hash
    try:
        await client.start()
        if channel_alias not in channel_hash:
            if private_channel:
                await client(ImportChatInviteRequest(private_hash))
            channel = await client.get_entity(channel_alias)
            ch_full = await client(GetFullChannelRequest(channel=channel))
            username = channel.username or channel.id
            channel_hash[channel_alias] = {
                'username': username,
                'title': channel.title,
                'id': channel.id,
                'about': ch_full.full_chat.about or str(username),
            }
            logging.info(f"Adding to the hash '{channel_alias}'")
            with open('hash.pickle', 'wb') as f:
                pickle.dump(channel_hash, f)
        ch = channel_hash[channel_alias]
        messages = [
            m async for m in client.iter_messages(
                ch['username'], limit=int(config['RSS']['RECORDS']))
        ]
    except Exception as e:
        warn = f"{str(e)}, request: '{channel_alias}'"
        logging.warning(warn)
        return warn

    fg = FeedGenerator()
    fg.title(f"{ch['title']} (@{ch['username']}, id:{ch['id']})")
    fg.subtitle(ch['about'])
    link = channel_alias if private_channel else f"t.me/s/{ch['username']}"
    fg.link(href=f'https://{link}', rel='alternate')
    fg.generator(config['RSS']['GENERATOR'])
    fg.language(config['RSS']['LANGUAGE'])
    for m in messages:
        if not (config['RSS'].getboolean('SKIP_EMPTY') and not m.text):
            fe = fg.add_entry(order='append')
            link = 'https://t.me/' + ('c/' if private_channel else '')
            fe.guid(guid=f"{link}{ch['username']}/{m.id}", permalink=True)
            fe.content(markdown(m.text))
            fe.published(m.date)

    logging.debug(f"Successfully requested '{ch['username']}'")
    return Response(content=fg.rss_str(), media_type='application/xml')
示例#29
0
def joinPrivateEntity():
    hash = request.args.get('hash')
    print('[/joinPrivateEntity] :: Hash {}'.format(hash))
    try:
        result = client(ImportChatInviteRequest(hash))
        return jsonify(result.chats[0].to_dict())
    except telethon.errors.rpcerrorlist.UserAlreadyParticipantError:
        return jsonify({'succes': 'ok'})
    except Exception as exception:
        print(type(exception))
        return jsonify({'error': str(exception)})
示例#30
0
    def update_urls_id(self, client):
        asd = client.get_dialogs()
        channels_list = {}
        for d in asd:
            if d.is_channel and f't.me/{d.entity.username}' in self.urls:
                channels_list[d.entity.id] = f't.me/{d.entity.username}'
        print(f'[PARSER] : {self.urls}')
        print(f'[PARSER] : {channels_list}')
        self.logger.info(f'[PARSER] : {self.urls}')
        for url in self.urls.copy():
            if url not in channels_list.values():
                try:
                    try:
                        chan = client.get_entity(url)
                    except ValueError as e:
                        if str(
                                e
                        ) == 'Cannot get entity from a channel (or group) that you are not part of. Join the group and retry':
                            hash = url[url.rfind('/') + 1:]
                            updates: Updates = client(
                                ImportChatInviteRequest(hash))
                            try:
                                client.send_message(
                                    client.get_entity(self.bot_id),
                                    f'Успешно вступлено в группу {updates.chats[0].title}'
                                )
                                continue
                            except:
                                client.send_message(
                                    client.get_entity(self.bot_id),
                                    f'Не удалось вступить в группу {url}')
                                continue

                        else:
                            client.send_message(
                                client.get_entity(self.bot_id),
                                f'Не удалось вступить в группу {url}')
                            continue
                    channels_list[chan.id] = url
                    if chan.username is None:
                        continue
                    client(JoinChannelRequest(chan))
                    time.sleep(1)
                    client.send_message(
                        client.get_entity(self.bot_id),
                        f'Успешно вступлено в группу {chan.title}')
                    time.sleep(1)
                except Exception as e:
                    pass
                    print(str(e))
                    print(traceback.format_exc())
        if set(channels_list) != self.id_of_urls:
            self.id_of_urls = channels_list
            self.self_save_id_urls()