async def remove_ch(event): if event.fwd_from: return chat_id = event.pattern_match.group(1) if chat_id == "all": await edit_or_reply(event, "Removing...") channels = get_all_channels() for channel in channels: rm_channel(channel.chat_id) await event.edit("Database cleared.") return if in_channels(chat_id): rm_channel(chat_id) await event.edit("Removed from database") await asyncio.sleep(3) await event.delete() elif in_channels(event.chat_id): rm_channel(event.chat_id) await event.edit("Removed from database") await asyncio.sleep(3) await event.delete() elif not in_channels(event.chat_id): await event.edit("Channel is already removed from database. ") await asyncio.sleep(3) await event.delete()
async def add_ch(event): if event.fwd_from: return if event.reply_to_msg_id: await edit_or_reply(event, "Adding...") previous_message = await event.get_reply_message() raw_text = previous_message.text lines = raw_text.split("\n") length = len(lines) for line_number in range(1, length - 2): channel_id = lines[line_number][4:-1] if not in_channels(channel_id): add_channel(channel_id) await event.edit("Channels added!") await asyncio.sleep(3) await event.delete() return chat_id = event.chat_id try: if int(chat_id) == logs_id: return except: pass if not in_channels(chat_id): add_channel(chat_id) await event.edit("`Added Successfuly To List`") await asyncio.sleep(3) await event.delete() elif in_channels(chat_id): await event.edit("`Channel is already is database!`") await asyncio.sleep(3) await event.delete()