from telethon.types import Message
from telethon.tl.functions.channels import JoinChannelRequest, LeaveChannelRequest
from .. import loader, utils
"""
███ ███ ██ ██ ██████ ██ ██ ██ ██████ ███████ ███████
████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ████ ██ ██ ██ ██████ ██ ██ ██ ██ ██ ███████ █████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██████ ██ ██ ██████ ███████ ██████ ███████ ███████
TempJoinChannel
"""
# 🔒 Licensed under the GNU AGPLv3
# meta banner: https://raw.githubusercontent.com/MuRuLOSE/HikkaModulesRepo/main/assets/modbanners/tempjoinchannel.png
# meta desc: Enter the channels temporarily!
# meta developer: @BruhHikkaModules
@loader.tds
class TempJoinChannel(loader.Module):
"""Enter the channels temporarily!"""
strings = {
"name": "TempJoinChannel",
"added": "✔️ Channels added",
"leaved": "🚪 All the channels have disappeared..."
}
strings_ru = {
"_cls_doc": "Входи в каналы временно!",
"added": "✔️ Каналы добавлены",
"leaved": "🚪 Все каналы исчезли..."
}
async def client_ready(self, client, db):
self.db = db
def __init__(self):
self._lock = False # if cleaning channels, cmd locking
self._channels = self.pointer("channels", [])
@loader.command(
ru_doc="Добавь каналы, напишите в аргументы слово inline если нужны каналы оттуда. Либо перечислите любые признаки канала (айди, ссылки, юзернеймы). Inline dont work"
)
async def addchannels(self, message: Message):
""" - Add channels, put the word inline in the arguments if you need channels from there. Or list any channel attributes (ids, links, usernames). (Inline dont work)"""
args = utils.get_args_raw(message)
if "inline" in args:
pass
else:
channels = args.split()
for channel in channels:
if channel not in self._channels:
self._channels.extend(str(channel))
await self.client(JoinChannelRequest(channel))
else:
pass
await utils.answer(message, self.srtings["added"])
@loader.command(
ru_doc="Покинуть все каналы которые были добавлены"
)
async def leavechannels(self, message: Message):
""" - Leave all channels that have been added"""
for channel in self._channels:
self._channels.remove(str(channel))
await self.client(LeaveChannelRequest(channel))
await utils.answer(message, self.strings["leaved"])