Spaces:
Sleeping
Sleeping
Upload 27 files
Browse files- src/__pycache__/config.cpython-311.pyc +0 -0
- src/config.py +3 -0
- src/plugins/__pycache__/channels.cpython-311.pyc +0 -0
- src/plugins/__pycache__/flow.cpython-311.pyc +0 -0
- src/plugins/__pycache__/general.cpython-311.pyc +0 -0
- src/plugins/channels.py +19 -1
- src/plugins/flow.py +30 -8
- src/plugins/general.py +30 -9
src/__pycache__/config.cpython-311.pyc
CHANGED
|
Binary files a/src/__pycache__/config.cpython-311.pyc and b/src/__pycache__/config.cpython-311.pyc differ
|
|
|
src/config.py
CHANGED
|
@@ -11,3 +11,6 @@ PORT = int(os.getenv("PORT", 7860))
|
|
| 11 |
|
| 12 |
# Enlace del canal destino para el flujo
|
| 13 |
TARGET_CHANNEL_LINK = os.getenv("TARGET_CHANNEL_LINK", "https://t.me/+IKNrGXMIt_MxMzg5")
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# Enlace del canal destino para el flujo
|
| 13 |
TARGET_CHANNEL_LINK = os.getenv("TARGET_CHANNEL_LINK", "https://t.me/+IKNrGXMIt_MxMzg5")
|
| 14 |
+
|
| 15 |
+
# Enlace del canal de control/escaneo (donde reenvías los mensajes a clonar)
|
| 16 |
+
TRIGGER_CHANNEL_LINK = os.getenv("TRIGGER_CHANNEL_LINK", "https://t.me/+D-vFPowf4JpjNGRh")
|
src/plugins/__pycache__/channels.cpython-311.pyc
CHANGED
|
Binary files a/src/plugins/__pycache__/channels.cpython-311.pyc and b/src/plugins/__pycache__/channels.cpython-311.pyc differ
|
|
|
src/plugins/__pycache__/flow.cpython-311.pyc
CHANGED
|
Binary files a/src/plugins/__pycache__/flow.cpython-311.pyc and b/src/plugins/__pycache__/flow.cpython-311.pyc differ
|
|
|
src/plugins/__pycache__/general.cpython-311.pyc
CHANGED
|
Binary files a/src/plugins/__pycache__/general.cpython-311.pyc and b/src/plugins/__pycache__/general.cpython-311.pyc differ
|
|
|
src/plugins/channels.py
CHANGED
|
@@ -1,13 +1,31 @@
|
|
| 1 |
from telethon import events
|
| 2 |
from telethon.tl.functions.channels import CreateChannelRequest
|
| 3 |
from telethon.tl.functions.messages import ExportChatInviteRequest
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def register_channels_handlers(client):
|
| 6 |
"""
|
| 7 |
Registra comandos relacionados a creación y gestión de canales.
|
| 8 |
"""
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
async def crear_canal_handler(event):
|
|
|
|
|
|
|
| 11 |
canal_nombre = event.pattern_match.group(1)
|
| 12 |
if not canal_nombre or not canal_nombre.strip():
|
| 13 |
await event.reply("⚠️ Debes indicar el nombre del canal.\nEjemplo: `/crear_canal Mi Canal Pelis`")
|
|
|
|
| 1 |
from telethon import events
|
| 2 |
from telethon.tl.functions.channels import CreateChannelRequest
|
| 3 |
from telethon.tl.functions.messages import ExportChatInviteRequest
|
| 4 |
+
from config import TRIGGER_CHANNEL_LINK
|
| 5 |
+
from plugins.flow import get_or_join_target_channel
|
| 6 |
|
| 7 |
def register_channels_handlers(client):
|
| 8 |
"""
|
| 9 |
Registra comandos relacionados a creación y gestión de canales.
|
| 10 |
"""
|
| 11 |
+
trigger_entity_holder = {"entity": None}
|
| 12 |
+
|
| 13 |
+
async def is_valid_chat(event):
|
| 14 |
+
try:
|
| 15 |
+
if trigger_entity_holder["entity"] is None:
|
| 16 |
+
trigger_entity_holder["entity"] = await get_or_join_target_channel(client, TRIGGER_CHANNEL_LINK)
|
| 17 |
+
|
| 18 |
+
chat = await event.get_chat()
|
| 19 |
+
if chat and trigger_entity_holder["entity"]:
|
| 20 |
+
return chat.id == trigger_entity_holder["entity"].id
|
| 21 |
+
except Exception:
|
| 22 |
+
pass
|
| 23 |
+
return False
|
| 24 |
+
|
| 25 |
+
@client.on(events.NewMessage(pattern=r"(?i)^/crear_canal(?:\s+(.+))?$"))
|
| 26 |
async def crear_canal_handler(event):
|
| 27 |
+
if not await is_valid_chat(event):
|
| 28 |
+
return
|
| 29 |
canal_nombre = event.pattern_match.group(1)
|
| 30 |
if not canal_nombre or not canal_nombre.strip():
|
| 31 |
await event.reply("⚠️ Debes indicar el nombre del canal.\nEjemplo: `/crear_canal Mi Canal Pelis`")
|
src/plugins/flow.py
CHANGED
|
@@ -16,7 +16,7 @@ from telethon.errors import (
|
|
| 16 |
UserAlreadyParticipantError,
|
| 17 |
ChatForwardsRestrictedError
|
| 18 |
)
|
| 19 |
-
from config import TARGET_CHANNEL_LINK
|
| 20 |
|
| 21 |
# Estado del modo escaneo
|
| 22 |
flow_state = {
|
|
@@ -85,16 +85,31 @@ def register_flow_handlers(client):
|
|
| 85 |
Registra los comandos /flow_on, /flow_off y la lógica inteligente de sincronización.
|
| 86 |
"""
|
| 87 |
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
async def flow_on_handler(event):
|
|
|
|
|
|
|
| 90 |
flow_state["active"] = True
|
| 91 |
msg = (
|
| 92 |
"🟢 **Modo Flujo ACTIVADO**\n"
|
| 93 |
"━━━━━━━━━━━━━━━━━━━━\n"
|
| 94 |
-
"📡 **
|
| 95 |
"🎯 **Canal Destino:** `" + TARGET_CHANNEL_LINK + "`\n\n"
|
| 96 |
-
"👉 **Instrucciones:** Reenvía
|
| 97 |
-
"•
|
| 98 |
"• Compara peso y duración para **no duplicar videos** ya enviados.\n"
|
| 99 |
"• Si se añadieron capítulos nuevos al canal original, enviará únicamente los que falten.\n"
|
| 100 |
"━━━━━━━━━━━━━━━━━━━━\n"
|
|
@@ -102,13 +117,17 @@ def register_flow_handlers(client):
|
|
| 102 |
)
|
| 103 |
await event.reply(msg)
|
| 104 |
|
| 105 |
-
@client.on(events.NewMessage(
|
| 106 |
async def flow_off_handler(event):
|
|
|
|
|
|
|
| 107 |
flow_state["active"] = False
|
| 108 |
await event.reply("🔴 **Modo Flujo DESACTIVADO**.\nEl bot ya no procesará mensajes reenviados.")
|
| 109 |
|
| 110 |
-
@client.on(events.NewMessage(
|
| 111 |
async def eliminar_notificaciones_fijados_handler(event):
|
|
|
|
|
|
|
| 112 |
"""
|
| 113 |
Escanea el canal destino y elimina todos los mensajes de servicio que genera Telegram
|
| 114 |
al fijar mensajes (ej: 'FLOW fijó una foto', 'Te uniste a este canal', etc.)
|
|
@@ -149,8 +168,11 @@ def register_flow_handlers(client):
|
|
| 149 |
except Exception as e:
|
| 150 |
await status_msg.edit(f"❌ Error al eliminar notificaciones de fijado: `{e}`")
|
| 151 |
|
| 152 |
-
@client.on(events.NewMessage(
|
| 153 |
async def process_forwarded_content(event):
|
|
|
|
|
|
|
|
|
|
| 154 |
# Ignorar comandos
|
| 155 |
if event.raw_text and event.raw_text.startswith('/'):
|
| 156 |
return
|
|
|
|
| 16 |
UserAlreadyParticipantError,
|
| 17 |
ChatForwardsRestrictedError
|
| 18 |
)
|
| 19 |
+
from config import TARGET_CHANNEL_LINK, TRIGGER_CHANNEL_LINK
|
| 20 |
|
| 21 |
# Estado del modo escaneo
|
| 22 |
flow_state = {
|
|
|
|
| 85 |
Registra los comandos /flow_on, /flow_off y la lógica inteligente de sincronización.
|
| 86 |
"""
|
| 87 |
|
| 88 |
+
trigger_entity_holder = {"entity": None}
|
| 89 |
+
|
| 90 |
+
async def is_trigger_channel(event):
|
| 91 |
+
try:
|
| 92 |
+
if trigger_entity_holder["entity"] is None:
|
| 93 |
+
trigger_entity_holder["entity"] = await get_or_join_target_channel(client, TRIGGER_CHANNEL_LINK)
|
| 94 |
+
chat = await event.get_chat()
|
| 95 |
+
if chat and trigger_entity_holder["entity"]:
|
| 96 |
+
return chat.id == trigger_entity_holder["entity"].id
|
| 97 |
+
except Exception:
|
| 98 |
+
pass
|
| 99 |
+
return False
|
| 100 |
+
|
| 101 |
+
@client.on(events.NewMessage(pattern=r"(?i)^/flow_on$"))
|
| 102 |
async def flow_on_handler(event):
|
| 103 |
+
if not await is_trigger_channel(event):
|
| 104 |
+
return
|
| 105 |
flow_state["active"] = True
|
| 106 |
msg = (
|
| 107 |
"🟢 **Modo Flujo ACTIVADO**\n"
|
| 108 |
"━━━━━━━━━━━━━━━━━━━━\n"
|
| 109 |
+
"📡 **Canal de Escaneo:** `" + TRIGGER_CHANNEL_LINK + "`\n"
|
| 110 |
"🎯 **Canal Destino:** `" + TARGET_CHANNEL_LINK + "`\n\n"
|
| 111 |
+
"👉 **Instrucciones:** Reenvía a este canal un mensaje de cualquier **canal** que quieras sincronizar.\n"
|
| 112 |
+
"• Mensajes Guardados queda totalmente libre.\n"
|
| 113 |
"• Compara peso y duración para **no duplicar videos** ya enviados.\n"
|
| 114 |
"• Si se añadieron capítulos nuevos al canal original, enviará únicamente los que falten.\n"
|
| 115 |
"━━━━━━━━━━━━━━━━━━━━\n"
|
|
|
|
| 117 |
)
|
| 118 |
await event.reply(msg)
|
| 119 |
|
| 120 |
+
@client.on(events.NewMessage(pattern=r"(?i)^/flow_off$"))
|
| 121 |
async def flow_off_handler(event):
|
| 122 |
+
if not await is_trigger_channel(event):
|
| 123 |
+
return
|
| 124 |
flow_state["active"] = False
|
| 125 |
await event.reply("🔴 **Modo Flujo DESACTIVADO**.\nEl bot ya no procesará mensajes reenviados.")
|
| 126 |
|
| 127 |
+
@client.on(events.NewMessage(pattern=r"(?i)^/(eliminar_fijados|elimianr_fijados)$"))
|
| 128 |
async def eliminar_notificaciones_fijados_handler(event):
|
| 129 |
+
if not await is_trigger_channel(event):
|
| 130 |
+
return
|
| 131 |
"""
|
| 132 |
Escanea el canal destino y elimina todos los mensajes de servicio que genera Telegram
|
| 133 |
al fijar mensajes (ej: 'FLOW fijó una foto', 'Te uniste a este canal', etc.)
|
|
|
|
| 168 |
except Exception as e:
|
| 169 |
await status_msg.edit(f"❌ Error al eliminar notificaciones de fijado: `{e}`")
|
| 170 |
|
| 171 |
+
@client.on(events.NewMessage())
|
| 172 |
async def process_forwarded_content(event):
|
| 173 |
+
# Solo procesar en el canal receptor/disparador
|
| 174 |
+
if not await is_trigger_channel(event):
|
| 175 |
+
return
|
| 176 |
# Ignorar comandos
|
| 177 |
if event.raw_text and event.raw_text.startswith('/'):
|
| 178 |
return
|
src/plugins/general.py
CHANGED
|
@@ -1,28 +1,49 @@
|
|
| 1 |
from telethon import events
|
| 2 |
-
from config import PORT
|
|
|
|
| 3 |
|
| 4 |
def register_general_handlers(client):
|
| 5 |
"""
|
| 6 |
-
Registra comandos utilitarios generales del UserBot.
|
| 7 |
"""
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
mensaje = (
|
| 11 |
"📂 **Control y Canales**\n"
|
| 12 |
"• `/crear_canal [nombre]` : Crea un canal privado y genera su enlace de invitación.\n\n"
|
| 13 |
"📂 **Flujo y Clonación**\n"
|
| 14 |
-
"• `/flow_on` : Activa el modo escaneo
|
| 15 |
"• `/flow_off` : Desactiva el modo escaneo.\n"
|
| 16 |
"• `/eliminar_fijados` : Elimina los avisos de notificación ('fijó una foto') del canal sin desfijar nada."
|
| 17 |
)
|
| 18 |
await event.reply(mensaje)
|
| 19 |
|
| 20 |
-
@client.on(events.NewMessage(
|
| 21 |
-
async def
|
|
|
|
|
|
|
| 22 |
await event.reply("🏓 **¡Pong!** El UserBot está activo y respondiendo.")
|
| 23 |
|
| 24 |
-
@client.on(events.NewMessage(
|
| 25 |
-
async def
|
|
|
|
|
|
|
| 26 |
msg = (
|
| 27 |
"🎬 **UserBot Películas ACTIVO**\n"
|
| 28 |
"━━━━━━━━━━━━━━━━━━━━\n"
|
|
|
|
| 1 |
from telethon import events
|
| 2 |
+
from config import PORT, TRIGGER_CHANNEL_LINK
|
| 3 |
+
from plugins.flow import get_or_join_target_channel
|
| 4 |
|
| 5 |
def register_general_handlers(client):
|
| 6 |
"""
|
| 7 |
+
Registra comandos utilitarios generales del UserBot en el canal de control.
|
| 8 |
"""
|
| 9 |
+
trigger_entity_holder = {"entity": None}
|
| 10 |
+
|
| 11 |
+
async def is_valid_chat(event):
|
| 12 |
+
try:
|
| 13 |
+
if trigger_entity_holder["entity"] is None:
|
| 14 |
+
trigger_entity_holder["entity"] = await get_or_join_target_channel(client, TRIGGER_CHANNEL_LINK)
|
| 15 |
+
|
| 16 |
+
chat = await event.get_chat()
|
| 17 |
+
if chat and trigger_entity_holder["entity"]:
|
| 18 |
+
return chat.id == trigger_entity_holder["entity"].id
|
| 19 |
+
except Exception:
|
| 20 |
+
pass
|
| 21 |
+
return False
|
| 22 |
+
|
| 23 |
+
@client.on(events.NewMessage(pattern=r"(?i)^/lista$"))
|
| 24 |
+
async def lista_handler(event):
|
| 25 |
+
if not await is_valid_chat(event):
|
| 26 |
+
return
|
| 27 |
mensaje = (
|
| 28 |
"📂 **Control y Canales**\n"
|
| 29 |
"• `/crear_canal [nombre]` : Crea un canal privado y genera su enlace de invitación.\n\n"
|
| 30 |
"📂 **Flujo y Clonación**\n"
|
| 31 |
+
"• `/flow_on` : Activa el modo escaneo en este canal.\n"
|
| 32 |
"• `/flow_off` : Desactiva el modo escaneo.\n"
|
| 33 |
"• `/eliminar_fijados` : Elimina los avisos de notificación ('fijó una foto') del canal sin desfijar nada."
|
| 34 |
)
|
| 35 |
await event.reply(mensaje)
|
| 36 |
|
| 37 |
+
@client.on(events.NewMessage(pattern=r"(?i)^/ping$"))
|
| 38 |
+
async def ping_handler(event):
|
| 39 |
+
if not await is_valid_chat(event):
|
| 40 |
+
return
|
| 41 |
await event.reply("🏓 **¡Pong!** El UserBot está activo y respondiendo.")
|
| 42 |
|
| 43 |
+
@client.on(events.NewMessage(pattern=r"(?i)^/alive$"))
|
| 44 |
+
async def alive_handler(event):
|
| 45 |
+
if not await is_valid_chat(event):
|
| 46 |
+
return
|
| 47 |
msg = (
|
| 48 |
"🎬 **UserBot Películas ACTIVO**\n"
|
| 49 |
"━━━━━━━━━━━━━━━━━━━━\n"
|