Files
limoka/AmoreForever/amoremods/poststealer.py
2025-07-10 21:02:34 +03:00

89 lines
3.3 KiB
Python

# █ █ █ █▄▀ ▄▀█ █▀▄▀█ █▀█ █▀█ █ █
# █▀█ █ █ █ █▀█ █ ▀ █ █▄█ █▀▄ █▄█
# 🔒 Licensed under the GNU GPLv3
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# 👤 https://t.me/hikamoru
# meta developer: @hikamorumods
# meta banner: https://raw.githubusercontent.com/AmoreForever/assets/master/poststeal.jpg
from .. import loader, utils
@loader.tds
class PostStealer(loader.Module):
"Steal post from another channel to your channel"
strings = {
'name': 'PostStealler',
'enable': '<b>Steal mode enabled.</b>',
'disable': '<b>Steal mode disabled.</b>',
'channel': 'channel id where ub will steal messages',
'my_channel': 'channel id where ub will send messages'
}
strings_ru = {
'enable': '<b>StealMod включен.</b>',
'disable': '<b>StealMod отключен.</b>',
'channel': 'айди канала откуда юб будет пересылать сообщения',
'my_channel': 'айди канала куда юб будет пересылать сообщения'
}
def __init__(self):
self.config = loader.ModuleConfig(
loader.ConfigValue(
"my_channel",
None,
lambda: self.strings("my_channel"),
),
loader.ConfigValue(
"channel",
None,
lambda: self.strings("channel"),
),
)
async def client_ready(self, client, db):
self.client = client
self.db = db
@loader.command()
async def smode(self, message):
"""- off/on steal mode"""
status = self.db.get(
"steal_status",
"status",
)
if status == "":
self.db.set("steal_status", "status", True)
if status == False:
self.db.set("steal_status", "status", True)
await utils.answer(message, self.strings("enable"))
else:
self.db.set("steal_status", "status", False)
await utils.answer(message, self.strings("disable"))
async def watcher(self, message):
"""Лень писать описание"""
status = self.db.get("steal_status", "status")
if status == False:
return False
if status == True:
steal = self.config['channel']
chatid = int(message.chat_id)
text = message.text
if chatid == steal:
if message.photo:
await self._client.send_file(int(self.config['my_channel']), message.photo, caption=message.text if text else None, link_preview=False)
elif message.video:
await self._client.send_file(int(self.config['my_channel']), message.video, caption=message.text if text else None, link_preview=False)
elif message.document:
await self._client.send_file(int(self.config['my_channel']), message.document, caption=message.text if text else None, link_preview=False)
elif message.text:
await message.client.send_message(int(self.config['my_channel']), message.text)
else:
return False