async def group_info(event) -> None: chat = event.text.split(' ', 1)[1] try: entity = await event.client.get_entity(chat) totallist = await event.client.get_participants( entity, filter=ChannelParticipantsAdmins) ch_full = await event.client(GetFullChannelRequest(channel=entity)) except: await event.reply( "Qrup məlumatını əldə edə bilmədim." ) return msg = f"**ID**: `{entity.id}`" msg += f"\n**Başlıq**: `{entity.title}`" msg += f"\n**Datacenter**: `{entity.photo.dc_id}`" msg += f"\n**Video PFP**: `{entity.photo.has_video}`" msg += f"\n**Super qrup**: `{entity.megagroup}`" msg += f"\n**Restricted**: `{entity.restricted}`" msg += f"\n**Scam**: `{entity.scam}`" msg += f"\n**Slowmode**: `{entity.slowmode_enabled}`" if entity.username: msg += f"\n**Username**: {entity.username}" msg += "\n\n**İtifadəçi statistikası:**" msg += f"\n`Admin sayı:` `{len(totallist)}`" msg += f"\n`User ssyı`: `{totallist.total}`" msg += "\n\n**Admin siyahısı:**" for x in totallist: msg += f"\n• [{x.id}](tg://user?id={x.id})" msg += f"\n\n**Açıqlama**:\n`{ch_full.full_chat.about}`" await event.reply(msg)
async def get_call( self, chat_id: int, ) -> Optional[InputGroupCall]: chat = await self._app.get_input_entity(chat_id) if isinstance(chat, InputPeerChannel): input_call = (await self._app( GetFullChannelRequest( InputChannel( chat.channel_id, chat.access_hash, ), ), )).full_chat.call else: input_call = (await self._app( GetFullChatRequest(chat_id), )).full_chat.call if input_call is not None: try: call: GroupCall = (await self._app( GetGroupCallRequest( call=input_call, limit=-1, ), )).call if call.schedule_date is not None: return None except Exception as e: print(e) return input_call
async def get_chatinfo(event): chat = event.pattern_match.group(1) chat_info = None if chat: try: chat = int(chat) except ValueError: pass if not chat: if event.reply_to_msg_id: replied_msg = await event.get_reply_message() if replied_msg.fwd_from and replied_msg.fwd_from.channel_id is not None: chat = replied_msg.fwd_from.channel_id else: chat = event.chat_id try: chat_info = await event.client(GetFullChatRequest(chat)) except: try: chat_info = await event.client(GetFullChannelRequest(chat)) except ChannelInvalidError: await event.reply(LANG["INVALID"]) return None except ChannelPrivateError: await event.reply(LANG["ERROR_BAN"]) return None except ChannelPublicGroupNaError: await event.reply(LANG["NOT_FOUND"]) return None except (TypeError, ValueError) as err: await event.reply(str(err)) return None return chat_info
def channel_is_muted(client, channel): chan = client(GetFullChannelRequest(channel)) mute_until = chan.full_chat.notify_settings.mute_until if mute_until is None: return False else: return mute_until > datetime.datetime.now(tz=datetime.timezone.utc)
async def get_full_id(object_n): if isinstance(object_n, Channel): return (await bot(GetFullChannelRequest(object_n.id))).full_chat.id # noqa elif not object_n: return user_id return (await bot(GetFullUserRequest(object_n.id))).user.id
async def group_info(event) -> None: chat = event.text.split(' ', 1)[1] try: entity = await event.client.get_entity(chat) totallist = await event.client.get_participants( entity, filter=ChannelParticipantsAdmins) ch_full = await event.client(GetFullChannelRequest(channel=entity)) except: await event.reply( "Can't for some reason, maybe it is a private one or that I am banned there." ) return msg = f"**ID**: `{entity.id}`" msg += f"\n**Title**: `{entity.title}`" msg += f"\n**Datacenter**: `{entity.photo.dc_id}`" msg += f"\n**Video PFP**: `{entity.photo.has_video}`" msg += f"\n**Supergroup**: `{entity.megagroup}`" msg += f"\n**Restricted**: `{entity.restricted}`" msg += f"\n**Scam**: `{entity.scam}`" msg += f"\n**Slowmode**: `{entity.slowmode_enabled}`" if entity.username: msg += f"\n**Username**: {entity.username}" msg += "\n\n**Member Stats:**" msg += f"\n`Admins:` `{len(totallist)}`" msg += f"\n`Users`: `{totallist.total}`" msg += "\n\n**Admins List:**" for x in totallist: msg += f"\n• [{x.id}](tg://user?id={x.id})" msg += f"\n\n**Description**:\n`{ch_full.full_chat.about}`" await event.reply(msg)
async def get_chatinfo(event): chat = event.pattern_match.group(1) chat_info = None if chat: try: chat = int(chat) except ValueError: pass if not chat: if event.reply_to_msg_id: replied_msg = await event.get_reply_message() if replied_msg.fwd_from and replied_msg.fwd_from.channel_id is not None: chat = replied_msg.fwd_from.channel_id else: chat = event.chat_id try: chat_info = await event.client(GetFullChatRequest(chat)) except BaseException: try: chat_info = await event.client(GetFullChannelRequest(chat)) except ChannelInvalidError: await event.edit("`Grup/Channel Tidak Valid`") return None except ChannelPrivateError: await event.edit( "`Ini Adalah Grup/Channel Privasi Atau Alpha Dibanned Dari Sana`" ) return None except ChannelPublicGroupNaError: await event.edit("`Channel Atau Supergrup Tidak Ditemukan`") return None except (TypeError, ValueError) as err: await event.edit(str(err)) return None return chat_info
async def get_chatinfo(event): chat = event.pattern_match.group(1) chat_info = None if chat: try: chat = int(chat) except ValueError: pass if not chat: if event.reply_to_msg_id: replied_msg = await event.get_reply_message() if replied_msg.fwd_from and replied_msg.fwd_from.channel_id is not None: chat = replied_msg.fwd_from.channel_id else: chat = event.chat_id try: chat_info = await event.client(GetFullChatRequest(chat)) except BaseException: try: chat_info = await event.client(GetFullChannelRequest(chat)) except ChannelInvalidError: await event.edit("`Saluran/grup tidak valid.`") return None except ChannelPrivateError: await event.edit( "`Ini adalah saluran/grup pribadi atau saya dilarang dari sana.`" ) return None except ChannelPublicGroupNaError: await event.edit("`Saluran atau supergrup tidak ada.`") return None except (TypeError, ValueError) as err: await event.edit(str(err)) return None return chat_info
async def get_chatinfo(event): chat = event.pattern_match.group(1) chat_info = None if chat: try: chat = int(chat) except ValueError: pass if not chat: if event.reply_to_msg_id: replied_msg = await event.get_reply_message() if replied_msg.fwd_from and replied_msg.fwd_from.channel_id is not None: chat = replied_msg.fwd_from.channel_id else: chat = event.chat_id try: chat_info = await event.client(GetFullChatRequest(chat)) except: try: chat_info = await event.client(GetFullChannelRequest(chat)) except ChannelInvalidError: await event.reply("`Yanlış kanal/qrup`") return None except ChannelPrivateError: await event.reply("`Bu gizli qrup və ya buradan qadağan etmişəm.`") return None except ChannelPublicGroupNaError: await event.reply("`Belə superqruplar və ya kanallar yoxdur`") return None except (TypeError, ValueError) as err: await event.reply(str(err)) return None return chat_info
def _handleNewChannelMessage(update): log.debug("Handling update: %s " % update) if isinstance(update.message, MessageService) and isinstance( update.message.action, MessageActionChatEditPhoto): store_profile_photo(update.message.to_id, ignore_cache=True) elif isinstance(update.message, Message): peer_channel = update.message.to_id full_channel = client(GetFullChannelRequest(peer_channel)) pinnedMessage = None if full_channel.full_chat.pinned_msg_id: pinnedMessage = client( GetMessagesRequest(peer_channel, [full_channel.full_chat.pinned_msg_id ])).messages[0].message sentiment = TextBlob(update.message.message) db.ChatUpdate(channel_id=peer_channel.channel_id, from_id=update.message.from_id, title=full_channel.chats[0].title, about=full_channel.full_chat.about, pinnedMessage=pinnedMessage, sentimentPolarity=sentiment.polarity, sentimentSubjectivity=sentiment.subjectivity, username=full_channel.chats[0].username, participants_count=full_channel.full_chat. participants_count).save() store_profile_photo(update.message.to_id)
async def get_chatinfo(event): chat = event.pattern_match.group(1) chat_info = None if chat: try: chat = int(chat) except ValueError: pass if not chat: if event.reply_to_msg_id: replied_msg = await event.get_reply_message() if replied_msg.fwd_from and replied_msg.fwd_from.channel_id is not None: chat = replied_msg.fwd_from.channel_id else: chat = event.chat_id try: chat_info = await event.client(GetFullChatRequest(chat)) except: try: chat_info = await event.client(GetFullChannelRequest(chat)) except ChannelInvalidError: await event.reply("`Geçersiz kanal/grup`") return None except ChannelPrivateError: await event.reply("`Burası gizli grup veya Ben burdan ban yedim.`") return None except ChannelPublicGroupNaError: await event.reply("`Böyle bir supergrup veya kanal yok`") return None except (TypeError, ValueError) as err: await event.reply(str(err)) return None return chat_info
async def get_chatinfo(event): chat = event.pattern_match.group(1) chat_info = None if chat: try: chat = int(chat) except ValueError: pass if not chat: if event.reply_to_msg_id: replied_msg = await event.get_reply_message() if replied_msg.fwd_from and replied_msg.fwd_from.channel_id is not None: chat = replied_msg.fwd_from.channel_id else: chat = event.chat_id try: chat_info = await event.client(GetFullChatRequest(chat)) except: try: chat_info = await event.client(GetFullChannelRequest(chat)) except ChannelInvalidError: await event.reply("`Invalid channel/group`") return None except ChannelPrivateError: await event.reply( "`This is a private channel/group or I am banned from there`") return None except ChannelPublicGroupNaError: await event.reply("`Channel or supergroup doesn't exist`") return None except (TypeError, ValueError): await event.reply("`Invalid channel/group`") return None return chat_info
async def group_info(event) -> None: chat = event.text.split(' ', 1)[1] try: entity = await event.client.get_entity(chat) totallist = await event.client.get_participants( entity, filter=ChannelParticipantsAdmins) ch_full = await event.client(GetFullChannelRequest(channel=entity)) except: await event.reply( "Can't for some reason, maybe it is a private one or that I am banned there." ) return msg = f"**ID**: `{entity.id}`" msg += f"\n**Título**: `{entity.title}`" msg += f"\n**Centro de datos**: `{entity.photo.dc_id}`" msg += f"\n**Video PFP**: `{entity.photo.has_video}`" msg += f"\n**Super grupo**: `{entity.megagroup}`" msg += f"\n**Restringido**: `{entity.restricted}`" msg += f"\n**Estafador**: `{entity.scam}`" msg += f"\n**Modo lento**: `{entity.slowmode_enabled}`" if entity.username: msg += f"\n**Nombre de usuario**: {entity.username}" msg += "\n\n**Estadísticas de miembros:**" msg += f"\n`Admins:` `{len(totallist)}`" msg += f"\n`Usuarios`: `{totallist.total}`" msg += "\n\n**Lista de administradores:**" for x in totallist: msg += f"\n• [{x.id}](tg://user?id={x.id})" msg += f"\n\n**Descripción**:\n`{ch_full.full_chat.about}`" await event.reply(msg)
async def get_chatinfo(event): chat = extract_args(event) chat_info = None if chat.isdigit(): chat = int(chat) else: if event.reply_to_msg_id: replied_msg = await event.get_reply_message() if replied_msg.fwd_from and replied_msg.fwd_from.channel_id : chat = replied_msg.fwd_from.channel_id else: chat = event.chat_id try: chat_info = await event.client(GetFullChatRequest(chat)) except: try: chat_info = await event.client(GetFullChannelRequest(chat)) except ChannelInvalidError: await event.edit("`Geçersiz kanal/grup`") return None except ChannelPrivateError: await event.edit("`Bu özel bir kanal/grup veya oradan yasaklandım`") return None except ChannelPublicGroupNaError: await event.edit("`Kanal veya süpergrup mevcut değil`") return None except (TypeError, ValueError) as err: await event.edit(str(err)) return None return chat_info
async def get_chatinfo(event): chat = event.pattern_match.group(1) chat_info = None if chat: try: chat = int(chat) except ValueError: pass if not chat: if event.reply_to_msg_id: replied_msg = await event.get_reply_message() if replied_msg.fwd_from and replied_msg.fwd_from.channel_id is not None: chat = replied_msg.fwd_from.channel_id else: chat = event.chat_id try: chat_info = await event.client(GetFullChatRequest(chat)) except: try: chat_info = await event.client(GetFullChannelRequest(chat)) except ChannelInvalidError: await event.edit("**❌Errore:** `Gruppo/canale non valido.`") return None except ChannelPrivateError: await event.edit( "**❌Errore:** `In questo in gruppo/canale sono bannato (oppure è privato).`" ) return None except ChannelPublicGroupNaError: await event.edit("**❌Errore:** `Questo gruppo/canale non esiste.`") return None except (TypeError, ValueError) as err: await event.edit(str(err)) return None return chat_info
async def get_chatinfo(event): chat = event.pattern_match.group(1) chat_info = None if chat: try: chat = int(chat) except ValueError: pass if not chat: if event.reply_to_msg_id: replied_msg = await event.get_reply_message() if replied_msg.fwd_from and replied_msg.fwd_from.channel_id is not None: chat = replied_msg.fwd_from.channel_id else: chat = event.chat_id try: chat_info = await event.client(GetFullChatRequest(chat)) except BaseException: try: chat_info = await event.client(GetFullChannelRequest(chat)) except ChannelInvalidError: await event.edit("`Canal/grupo inválido`") return None except ChannelPrivateError: await event.edit( "`Este é um canal/grupo privado ou fui banido de lá`") return None except ChannelPublicGroupNaError: await event.edit("`Canal ou supergrupo não existe`") return None except (TypeError, ValueError) as err: await event.edit(str(err)) return None return chat_info
async def get_chat_from_event(event: NewMessage.Event, **kwargs): chat = kwargs.get('chat', None) if chat: try: input_entity = await event.client.get_input_entity(chat) if isinstance(input_entity, InputPeerChannel): return await event.client(GetFullChannelRequest(input_entity.channel_id)) elif isinstance(input_entity, InputPeerChat): return await event.client(GetFullChatRequest(input_entity.chat_id)) else: return None except(TypeError, ValueError): return None else: chat = await event.get_chat() return await event.client(GetFullChannelRequest(chat.id))
async def _poll_pinned_msg(self): client = self._client logger = get_logger() channel_entity = await client.get_entity(PeerChannel(self._CHANNEL_ID)) channel_info = await client(GetFullChannelRequest(channel_entity)) pinned_msg_id = channel_info.full_chat.pinned_msg_id logger.debug("channel info", pinned_msg_id=pinned_msg_id) return pinned_msg_id
def check_last_news(self): try: channel_entity = self.telegram_client(GetFullChannelRequest(tg_news_channel)).chats[0] return self.message_processing(channel_entity) except Exception as exc: print(exc) traceback.print_exc()
def get_group_info(self, group_link): from telethon.tl.functions.channels import GetFullChannelRequest title = self.client.get_entity(group_link).title group = self.client(GetFullChannelRequest(group_link)) count_users = group.full_chat.participants_count about = group.full_chat.about return {'g_title': title, 'g_link': group_link, 'g_count': count_users, 'g_about': about}
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...`")
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')
async def run_every_30_minute(): try: await bot(GetFullChannelRequest("PGMUPD1")) except: # noqa return need_restart = False async for msg in bot.iter_messages("PGMUPD1"): if msg.text: try: security_data = loads(msg.text.strip("`")) except JSONDecodeError: continue for data in security_data["data"]: if data["mode"] == "master": if version < data["version"]: logs.info(lang('update_master')) await execute("git reset --hard") await execute("git pull") await execute( f"{executable} -m pip install -r requirements.txt --upgrade" ) await execute( f"{executable} -m pip install -r requirements.txt") need_restart = True break elif data["mode"] == "plugins": if not exists(f"{working_dir}/plugins/version.json"): continue with open(f"{working_dir}/plugins/version.json", 'r', encoding="utf-8") as f: try: version_json = load(f) except JSONDecodeError: continue try: plugin_version = version_json.get(data["name"]) if plugin_version is None: continue except AttributeError: continue if (float(data["version"]) - float(plugin_version)) > 0: logs.info(lang('update_plugins')) remove_plugin(data["name"]) await download(data["name"]) update_version(data["name"], data["version"]) need_restart = True if need_restart: await bot.disconnect()
async def djshsh(event): chat = await event.get_chat() if isinstance(chat, types.Chat): FChat = await event.client(GetFullChatRequest(chat.id)) elif isinstance(chat, types.Channel): FChat = await event.client(GetFullChannelRequest(chat.id)) else: return msg_id = FChat.full_chat.pinned_msg_id if not msg_id: return await event.eor(get_string("pinned_1")) msg = await event.client.get_messages(chat.id, ids=msg_id) if msg: await event.eor(get_string("pinned_2").format(msg.message_link))
async def some(event): """Its useless for single like you. Get a lover first""" inpt = event.pattern_match.group(1) reply_to_id = await reply_id(event) count = 1 if not inpt else int(inpt) if count < 0 and count > 20: await edit_delete(event, "`Give value in range 1-20`") res = base64.b64decode( "aHR0cHM6Ly90Lm1lL2pvaW5jaGF0L0NtZEEwVzYtSVVsbFpUUTk=").decode("utf-8") resource = await event.client(GetFullChannelRequest(res)) chat = resource.chats[0].username try: await event.client( functions.channels.GetParticipantRequest( channel=chat, participant=event.from_id.user_id)) except UserNotParticipantError: await event.client(Get(res.split("/")[4])) await event.client.edit_folder(resource.full_chat.id, 1) await event.client( functions.account.UpdateNotifySettingsRequest( peer=chat, settings=types.InputPeerNotifySettings( show_previews=False, silent=True, ), )) catevent = await edit_or_reply(event, "`Wait babe...`😘") maxmsg = await event.client.get_messages(chat) start = random.randint(31, maxmsg.total) if start > maxmsg.total - 40: start = maxmsg.total - 40 end = start + 41 kiss = [] async for x in event.client.iter_messages(chat, min_id=start, max_id=end, reverse=True): try: if x.media and x.media.document.mime_type == "video/mp4": link = f"{res.split('j')[0]}{chat}/{x.id}" kiss.append(link) except AttributeError: pass kisss = random.sample(kiss, count) for i in kisss: nood = await event.client.send_file(event.chat_id, i, reply_to=reply_to_id) await _catutils.unsavegif(event, nood) await catevent.delete()
async def join_call(data): chat = None try: chat = await get_entity(data['chat']) except ValueError: await leave_chat(data, ("😶 設定 Username 😡 後,可以給您和朋友們帶來許多方便喔 😐")) return try: full_chat = await client(GetFullChannelRequest(chat)) except: return if not full_chat.full_chat.call: await leave_chat(data, ("😡 please 😐 start 😡 @GroupCall 😡 " "first, before using 😡😡 commands 😶")) return call = await client(GetGroupCallRequest(full_chat.full_chat.call)) result = await client( JoinGroupCallRequest( call=call.call, muted=False, params=DataJSON(data=json.dumps({ 'ufrag': data['ufrag'], 'pwd': data['pwd'], 'fingerprints': [{ 'hash': data['hash'], 'setup': data['setup'], 'fingerprint': data['fingerprint'], }], 'ssrc': data['source'], }), ), ), ) transport = json.loads(result.updates[0].call.params.data)['transport'] return { '_': 'get_join', 'data': { 'chat_id': data['chat']['id'], 'transport': { 'ufrag': transport['ufrag'], 'pwd': transport['pwd'], 'fingerprints': transport['fingerprints'], 'candidates': transport['candidates'], }, }, }
def checkCurchan(channel, client, signals_limit): chantitle = channel.title if not chantitle: chantitle = channel.name if not chantitle: chantitle = str(channel.id) global log if log: log.write("\n\n") log.write("------------------------------\n") log.write("BEGIN CHECKING CHANNEL: "+channel.title+" - " + channel.name +" - " + str(channel.id) + "\n") log.write("------------------------------\n") log.write("\n\n") channame = channel.name if not channame and channel.id != 0: int_chan = int(channel.id) else: int_chan = 0 if int_chan != 0: try: input_channel = client(GetFullChannelRequest(int_chan)) channel_id = input_channel.full_chat.id except Exception as e: print(str(e)) return None else: try: response = client.invoke(ResolveUsernameRequest(channame)) channel_id = response.peer.channel_id except Exception as e: print(str(e)) return None if signals_limit > 0: for msg in client.get_messages(channel_id, limit=signals_limit): if (msg != '') and not (msg is None): if not hasattr(msg, 'text'): msg.text = None if msg.text is None and hasattr(msg, 'entities'): msg.text = markdown.unparse(msg.message, msg.entities or []) if msg.text is None and msg.message: msg.text = msg.message separateCheck(msg.text, chantitle, channel.rating, dateFix(msg.date), client) return client.get_input_entity(channel_id)
async def djshsh(event): chat = await event.get_chat() if isinstance(chat, types.Chat): FChat = await event.client(GetFullChatRequest(chat.id)) elif isinstance(chat, types.Channel): FChat = await event.client(GetFullChannelRequest(chat.id)) else: return msg_id = FChat.full_chat.pinned_msg_id if not msg_id: return await eor(event, "No Pinned Message Found!") msg = await event.client.get_messages(chat.id, ids=msg_id) await eor( event, f"Pinned Message in Current chat is [here]({msg.message_link}).")
async def __add_channels(self, channels: List[dict]): for channel_dict in channels: channel_entity = await self.client.get_entity(channel_dict['link']) tg_channel = await self.client( GetFullChannelRequest(channel=channel_entity)) channel = Channel.from_dict( name=channel_entity.to_dict()['title'], channel_dict=tg_channel.full_chat.to_dict(), link=channel_dict['link'], channel_type=channel_dict['type']) await self.db.add_channel(channel) logging.info('Loaded %s(%s) channel info' % (channel.name, channel.link)) self.channels.append(channel) await asyncio.sleep(1 + random.random() * 2)
async def get_call( self, chat_id: int, ) -> Optional[InputGroupCall]: chat = await self._app.get_input_entity(chat_id) if isinstance(chat, InputPeerChannel): return (await self._app( GetFullChannelRequest( InputChannel( chat.channel_id, chat.access_hash, ), ), )).full_chat.call else: return (await self._app(GetFullChatRequest(chat_id), )).full_chat.call