async def kr(event): args = event.pattern_match.group(1) if args: if not await is_admin(event, event.sender_id): return await event.reply("You need to be an admin to do this!") if args == 'on' or args == 'enable': if not is_chat(event.chat_id): await event.reply( "**Enabled** anti channel pins. Automatic pins from a channel will now be replaced with the previous pin." ) return add_chat(event.chat_id) else: return await event.reply( "**Enabled** anti channel pins. Automatic pins from a channel will now be replaced with the previous pin." ) elif args == 'off' or args == 'disable': if is_chat(event.chat_id): await event.reply( "**Disabled** anti channel pins. Automatic pins from a channel will not be removed." ) return rmchat(event.chat_id) else: return await event.reply( "**Disabled** anti channel pins. Automatic pins from a channel will not be removed." ) else: if is_chat(event.chat_id): return await event.reply( f"Anti channel pins are currently **enabled** in {event.chat.title}." ) else: return await event.reply( f"Anti channel pins are currently **disabled** in {event.chat.title}." )
async def pk(event): if event.is_private: return if not is_chat(event.chat_id): return if not event.fwd_from: return from telethon import functions, types result = await tbot( functions.channels.GetFullChannelRequest(channel=event.chat.username)) s = result.chats for x in s: if not x.username == event.chat.username: id = x.id if not id == None: cid = event.fwd_from.from_id.channel_id if cid == id: await tbot.unpin_message(event.chat_id, event.message.id)