weebzone commited on
Commit Β·
6f85dc9
1
Parent(s): bedc5b1
junk
Browse files- Backend/__main__.py +4 -5
- Backend/config.py +0 -1
- Backend/pyrofork/bot.py +2 -2
- Backend/pyrofork/clients.py +1 -1
- Backend/pyrofork/plugins/channels.py +2 -14
- Backend/pyrofork/plugins/fix_metadata.py +1 -1
- Backend/pyrofork/plugins/reciever.py +4 -9
- Backend/pyrofork/plugins/scanner.py +5 -8
- Backend/pyrofork/plugins/start.py +0 -4
- Backend/pyrofork/plugins/utilities.py +0 -2
Backend/__main__.py
CHANGED
|
@@ -6,13 +6,16 @@ from pyrogram import idle
|
|
| 6 |
from Backend import __version__, db
|
| 7 |
from Backend.helper.pinger import ping
|
| 8 |
from Backend.logger import LOGGER
|
|
|
|
| 9 |
from Backend.fastapi import server
|
| 10 |
from Backend.helper.pyro import restart_notification, setup_bot_commands
|
| 11 |
from Backend.pyrofork.bot import Helper, StreamBot
|
| 12 |
from Backend.pyrofork.clients import initialize_clients
|
|
|
|
|
|
|
| 13 |
from Backend.helper.link_checker import DeadLinkChecker
|
| 14 |
from Backend.fastapi.main import app
|
| 15 |
-
|
| 16 |
|
| 17 |
loop = get_event_loop()
|
| 18 |
|
|
@@ -49,14 +52,10 @@ async def start_services():
|
|
| 49 |
loop.create_task(server.serve())
|
| 50 |
loop.create_task(ping())
|
| 51 |
|
| 52 |
-
# Start the background Dead Link Checker
|
| 53 |
link_checker_task = DeadLinkChecker(db, app, check_interval_hours=24)
|
| 54 |
loop.create_task(link_checker_task.start())
|
| 55 |
|
| 56 |
-
# Start Subscription Background Task
|
| 57 |
-
from Backend.config import Telegram
|
| 58 |
if Telegram.SUBSCRIPTION:
|
| 59 |
-
from Backend.helper.subscription_checker import subscription_checker_loop
|
| 60 |
loop.create_task(subscription_checker_loop(StreamBot))
|
| 61 |
LOGGER.info("Subscription Checker Task Started.")
|
| 62 |
|
|
|
|
| 6 |
from Backend import __version__, db
|
| 7 |
from Backend.helper.pinger import ping
|
| 8 |
from Backend.logger import LOGGER
|
| 9 |
+
from Backend.config import Telegram
|
| 10 |
from Backend.fastapi import server
|
| 11 |
from Backend.helper.pyro import restart_notification, setup_bot_commands
|
| 12 |
from Backend.pyrofork.bot import Helper, StreamBot
|
| 13 |
from Backend.pyrofork.clients import initialize_clients
|
| 14 |
+
from Backend.pyrofork.plugins.channels import _load_channels_from_db
|
| 15 |
+
from Backend.helper.subscription_checker import subscription_checker_loop
|
| 16 |
from Backend.helper.link_checker import DeadLinkChecker
|
| 17 |
from Backend.fastapi.main import app
|
| 18 |
+
|
| 19 |
|
| 20 |
loop = get_event_loop()
|
| 21 |
|
|
|
|
| 52 |
loop.create_task(server.serve())
|
| 53 |
loop.create_task(ping())
|
| 54 |
|
|
|
|
| 55 |
link_checker_task = DeadLinkChecker(db, app, check_interval_hours=24)
|
| 56 |
loop.create_task(link_checker_task.start())
|
| 57 |
|
|
|
|
|
|
|
| 58 |
if Telegram.SUBSCRIPTION:
|
|
|
|
| 59 |
loop.create_task(subscription_checker_loop(StreamBot))
|
| 60 |
LOGGER.info("Subscription Checker Task Started.")
|
| 61 |
|
Backend/config.py
CHANGED
|
@@ -27,7 +27,6 @@ class Telegram:
|
|
| 27 |
|
| 28 |
REPLACE_MODE = getenv("REPLACE_MODE", "true").lower() == "true"
|
| 29 |
HIDE_CATALOG = getenv("HIDE_CATALOG", "false").lower() == "true"
|
| 30 |
-
# SKIP_MULTIPART = getenv("SKIP_MULTIPART", "true").lower() == "true"
|
| 31 |
|
| 32 |
ADMIN_USERNAME = getenv("ADMIN_USERNAME", "fyvio")
|
| 33 |
ADMIN_PASSWORD = getenv("ADMIN_PASSWORD", "fyvio")
|
|
|
|
| 27 |
|
| 28 |
REPLACE_MODE = getenv("REPLACE_MODE", "true").lower() == "true"
|
| 29 |
HIDE_CATALOG = getenv("HIDE_CATALOG", "false").lower() == "true"
|
|
|
|
| 30 |
|
| 31 |
ADMIN_USERNAME = getenv("ADMIN_USERNAME", "fyvio")
|
| 32 |
ADMIN_PASSWORD = getenv("ADMIN_PASSWORD", "fyvio")
|
Backend/pyrofork/bot.py
CHANGED
|
@@ -25,5 +25,5 @@ Helper = Client(
|
|
| 25 |
multi_clients = {}
|
| 26 |
work_loads = {}
|
| 27 |
client_dc_map = {}
|
| 28 |
-
client_failures = {}
|
| 29 |
-
client_avg_mbps = {}
|
|
|
|
| 25 |
multi_clients = {}
|
| 26 |
work_loads = {}
|
| 27 |
client_dc_map = {}
|
| 28 |
+
client_failures = {}
|
| 29 |
+
client_avg_mbps = {}
|
Backend/pyrofork/clients.py
CHANGED
|
@@ -71,4 +71,4 @@ async def initialize_clients():
|
|
| 71 |
LOGGER.info(f"Multi-Client Mode Enabled with {len(multi_clients)} clients")
|
| 72 |
LOGGER.info(f"DC Distribution: {client_dc_map}")
|
| 73 |
else:
|
| 74 |
-
LOGGER.info("No additional clients were initialized, using default client")
|
|
|
|
| 71 |
LOGGER.info(f"Multi-Client Mode Enabled with {len(multi_clients)} clients")
|
| 72 |
LOGGER.info(f"DC Distribution: {client_dc_map}")
|
| 73 |
else:
|
| 74 |
+
LOGGER.info("No additional clients were initialized, using default client")
|
Backend/pyrofork/plugins/channels.py
CHANGED
|
@@ -8,16 +8,15 @@ Commands (owner-only, private chat):
|
|
| 8 |
|
| 9 |
Changes take effect immediately (no restart needed) and are persisted to MongoDB.
|
| 10 |
|
| 11 |
-
Drop this file into Backend/pyrofork/plugins/channels.py
|
| 12 |
"""
|
| 13 |
|
| 14 |
from pyrogram import filters, Client, enums
|
| 15 |
from pyrogram.types import Message
|
| 16 |
from pyrogram.errors import ChannelPrivate, ChatAdminRequired, PeerIdInvalid
|
| 17 |
|
|
|
|
| 18 |
from Backend.helper.custom_filter import CustomFilters
|
| 19 |
from Backend.logger import LOGGER
|
| 20 |
-
from Backend import db
|
| 21 |
from Backend.config import Telegram
|
| 22 |
|
| 23 |
|
|
@@ -27,7 +26,6 @@ CHANNEL_DOC_ID = "auth_channels"
|
|
| 27 |
|
| 28 |
|
| 29 |
async def _load_channels_from_db():
|
| 30 |
-
"""Load persisted channels from tracking DB and merge with env var channels."""
|
| 31 |
try:
|
| 32 |
doc = await db.dbs["tracking"]["config"].find_one({"_id": CHANNEL_DOC_ID})
|
| 33 |
if doc and "channels" in doc:
|
|
@@ -44,7 +42,6 @@ async def _load_channels_from_db():
|
|
| 44 |
|
| 45 |
|
| 46 |
async def _save_channels_to_db():
|
| 47 |
-
"""Persist the current AUTH_CHANNEL list to tracking DB."""
|
| 48 |
try:
|
| 49 |
await db.dbs["tracking"]["config"].update_one(
|
| 50 |
{"_id": CHANNEL_DOC_ID},
|
|
@@ -59,7 +56,6 @@ async def _save_channels_to_db():
|
|
| 59 |
|
| 60 |
@Client.on_message(filters.command('channels') & filters.private & CustomFilters.owner, group=10)
|
| 61 |
async def list_channels(client: Client, message: Message):
|
| 62 |
-
"""List all active AUTH_CHANNELs with their names."""
|
| 63 |
if not Telegram.AUTH_CHANNEL:
|
| 64 |
await message.reply_text(
|
| 65 |
"π No AUTH_CHANNELs configured.\n\n"
|
|
@@ -71,7 +67,7 @@ async def list_channels(client: Client, message: Message):
|
|
| 71 |
|
| 72 |
lines = []
|
| 73 |
for i, ch_id in enumerate(Telegram.AUTH_CHANNEL, 1):
|
| 74 |
-
name = ch_id
|
| 75 |
try:
|
| 76 |
chat = await client.get_chat(int(ch_id))
|
| 77 |
name = getattr(chat, "title", ch_id)
|
|
@@ -90,7 +86,6 @@ async def list_channels(client: Client, message: Message):
|
|
| 90 |
|
| 91 |
@Client.on_message(filters.command('addchannel') & filters.private & CustomFilters.owner, group=10)
|
| 92 |
async def add_channel(client: Client, message: Message):
|
| 93 |
-
"""Add a channel to AUTH_CHANNELs. Bot must be admin in the channel."""
|
| 94 |
args = message.text.split(maxsplit=1)
|
| 95 |
if len(args) < 2:
|
| 96 |
await message.reply_text(
|
|
@@ -105,7 +100,6 @@ async def add_channel(client: Client, message: Message):
|
|
| 105 |
|
| 106 |
ch_id = args[1].strip()
|
| 107 |
|
| 108 |
-
# Validate it's a number
|
| 109 |
try:
|
| 110 |
int(ch_id)
|
| 111 |
except ValueError:
|
|
@@ -117,7 +111,6 @@ async def add_channel(client: Client, message: Message):
|
|
| 117 |
)
|
| 118 |
return
|
| 119 |
|
| 120 |
-
# Check if already added
|
| 121 |
if ch_id in Telegram.AUTH_CHANNEL:
|
| 122 |
await message.reply_text(
|
| 123 |
f"βΉοΈ Channel <code>{ch_id}</code> is already in AUTH_CHANNELs.",
|
|
@@ -126,7 +119,6 @@ async def add_channel(client: Client, message: Message):
|
|
| 126 |
)
|
| 127 |
return
|
| 128 |
|
| 129 |
-
# Validate bot has access
|
| 130 |
status_msg = await message.reply_text(
|
| 131 |
"π Validating channel accessβ¦",
|
| 132 |
quote=True,
|
|
@@ -157,7 +149,6 @@ async def add_channel(client: Client, message: Message):
|
|
| 157 |
)
|
| 158 |
return
|
| 159 |
|
| 160 |
-
# Add to runtime list and persist
|
| 161 |
Telegram.AUTH_CHANNEL.append(ch_id)
|
| 162 |
await _save_channels_to_db()
|
| 163 |
|
|
@@ -175,10 +166,8 @@ async def add_channel(client: Client, message: Message):
|
|
| 175 |
|
| 176 |
@Client.on_message(filters.command('removechannel') & filters.private & CustomFilters.owner, group=10)
|
| 177 |
async def remove_channel(client: Client, message: Message):
|
| 178 |
-
"""Remove a channel from AUTH_CHANNELs."""
|
| 179 |
args = message.text.split(maxsplit=1)
|
| 180 |
if len(args) < 2:
|
| 181 |
-
# Show current channels for easy selection
|
| 182 |
if Telegram.AUTH_CHANNEL:
|
| 183 |
lines = []
|
| 184 |
for ch_id in Telegram.AUTH_CHANNEL:
|
|
@@ -212,7 +201,6 @@ async def remove_channel(client: Client, message: Message):
|
|
| 212 |
)
|
| 213 |
return
|
| 214 |
|
| 215 |
-
# Get channel name before removing
|
| 216 |
ch_name = ch_id
|
| 217 |
try:
|
| 218 |
chat = await client.get_chat(int(ch_id))
|
|
|
|
| 8 |
|
| 9 |
Changes take effect immediately (no restart needed) and are persisted to MongoDB.
|
| 10 |
|
|
|
|
| 11 |
"""
|
| 12 |
|
| 13 |
from pyrogram import filters, Client, enums
|
| 14 |
from pyrogram.types import Message
|
| 15 |
from pyrogram.errors import ChannelPrivate, ChatAdminRequired, PeerIdInvalid
|
| 16 |
|
| 17 |
+
from Backend import db
|
| 18 |
from Backend.helper.custom_filter import CustomFilters
|
| 19 |
from Backend.logger import LOGGER
|
|
|
|
| 20 |
from Backend.config import Telegram
|
| 21 |
|
| 22 |
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
async def _load_channels_from_db():
|
|
|
|
| 29 |
try:
|
| 30 |
doc = await db.dbs["tracking"]["config"].find_one({"_id": CHANNEL_DOC_ID})
|
| 31 |
if doc and "channels" in doc:
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
async def _save_channels_to_db():
|
|
|
|
| 45 |
try:
|
| 46 |
await db.dbs["tracking"]["config"].update_one(
|
| 47 |
{"_id": CHANNEL_DOC_ID},
|
|
|
|
| 56 |
|
| 57 |
@Client.on_message(filters.command('channels') & filters.private & CustomFilters.owner, group=10)
|
| 58 |
async def list_channels(client: Client, message: Message):
|
|
|
|
| 59 |
if not Telegram.AUTH_CHANNEL:
|
| 60 |
await message.reply_text(
|
| 61 |
"π No AUTH_CHANNELs configured.\n\n"
|
|
|
|
| 67 |
|
| 68 |
lines = []
|
| 69 |
for i, ch_id in enumerate(Telegram.AUTH_CHANNEL, 1):
|
| 70 |
+
name = ch_id
|
| 71 |
try:
|
| 72 |
chat = await client.get_chat(int(ch_id))
|
| 73 |
name = getattr(chat, "title", ch_id)
|
|
|
|
| 86 |
|
| 87 |
@Client.on_message(filters.command('addchannel') & filters.private & CustomFilters.owner, group=10)
|
| 88 |
async def add_channel(client: Client, message: Message):
|
|
|
|
| 89 |
args = message.text.split(maxsplit=1)
|
| 90 |
if len(args) < 2:
|
| 91 |
await message.reply_text(
|
|
|
|
| 100 |
|
| 101 |
ch_id = args[1].strip()
|
| 102 |
|
|
|
|
| 103 |
try:
|
| 104 |
int(ch_id)
|
| 105 |
except ValueError:
|
|
|
|
| 111 |
)
|
| 112 |
return
|
| 113 |
|
|
|
|
| 114 |
if ch_id in Telegram.AUTH_CHANNEL:
|
| 115 |
await message.reply_text(
|
| 116 |
f"βΉοΈ Channel <code>{ch_id}</code> is already in AUTH_CHANNELs.",
|
|
|
|
| 119 |
)
|
| 120 |
return
|
| 121 |
|
|
|
|
| 122 |
status_msg = await message.reply_text(
|
| 123 |
"π Validating channel accessβ¦",
|
| 124 |
quote=True,
|
|
|
|
| 149 |
)
|
| 150 |
return
|
| 151 |
|
|
|
|
| 152 |
Telegram.AUTH_CHANNEL.append(ch_id)
|
| 153 |
await _save_channels_to_db()
|
| 154 |
|
|
|
|
| 166 |
|
| 167 |
@Client.on_message(filters.command('removechannel') & filters.private & CustomFilters.owner, group=10)
|
| 168 |
async def remove_channel(client: Client, message: Message):
|
|
|
|
| 169 |
args = message.text.split(maxsplit=1)
|
| 170 |
if len(args) < 2:
|
|
|
|
| 171 |
if Telegram.AUTH_CHANNEL:
|
| 172 |
lines = []
|
| 173 |
for ch_id in Telegram.AUTH_CHANNEL:
|
|
|
|
| 201 |
)
|
| 202 |
return
|
| 203 |
|
|
|
|
| 204 |
ch_name = ch_id
|
| 205 |
try:
|
| 206 |
chat = await client.get_chat(int(ch_id))
|
Backend/pyrofork/plugins/fix_metadata.py
CHANGED
|
@@ -43,7 +43,7 @@ async def cancel_fix(_, query):
|
|
| 43 |
# -------------------------------
|
| 44 |
# MAIN COMMAND (REWRITTEN - Balanced)
|
| 45 |
# -------------------------------
|
| 46 |
-
# @Client.on_message(filters.command("fixmetadata") & filters.private & CustomFilters.owner, group=10)
|
| 47 |
async def fix_metadata_handler(_, message):
|
| 48 |
global CANCEL_REQUESTED
|
| 49 |
CANCEL_REQUESTED = False
|
|
|
|
| 43 |
# -------------------------------
|
| 44 |
# MAIN COMMAND (REWRITTEN - Balanced)
|
| 45 |
# -------------------------------
|
| 46 |
+
# @Client.on_message(filters.command("fixmetadata") & filters.private & CustomFilters.owner, group=10) # Inactive Now
|
| 47 |
async def fix_metadata_handler(_, message):
|
| 48 |
global CANCEL_REQUESTED
|
| 49 |
CANCEL_REQUESTED = False
|
Backend/pyrofork/plugins/reciever.py
CHANGED
|
@@ -10,6 +10,9 @@ from pyrogram import filters, Client
|
|
| 10 |
from pyrogram.types import Message
|
| 11 |
from pyrogram.errors import FloodWait
|
| 12 |
from pyrogram.enums.parse_mode import ParseMode
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
file_queue = Queue()
|
|
@@ -84,20 +87,15 @@ async def file_edited_handler(client: Client, message: Message):
|
|
| 84 |
size = get_readable_file_size(file.file_size)
|
| 85 |
channel = str(message.chat.id).replace("-100", "")
|
| 86 |
|
| 87 |
-
from Backend.helper.metadata import extract_default_id
|
| 88 |
override_id = extract_default_id(message.caption) if message.caption else None
|
| 89 |
|
| 90 |
-
# Only proceed if we found a valid manual overide ID in the caption update
|
| 91 |
if override_id:
|
| 92 |
LOGGER.info(f"Detected override ID '{override_id}' in edited message {msg_id}")
|
| 93 |
|
| 94 |
-
from Backend.helper.encrypt import encode_string
|
| 95 |
stream_id_hash = await encode_string({"chat_id": int(channel), "msg_id": msg_id})
|
| 96 |
|
| 97 |
-
# Wipe the old streaming quality reference from the old associated media
|
| 98 |
await db.delete_media_by_stream_id(stream_id_hash)
|
| 99 |
|
| 100 |
-
# Reprocess metadata completely
|
| 101 |
metadata_info = await metadata(clean_filename(title), int(channel), msg_id, override_id=override_id)
|
| 102 |
if metadata_info is None:
|
| 103 |
LOGGER.warning(f"Metadata failed for edited file: {title} (ID: {msg_id})")
|
|
@@ -107,18 +105,15 @@ async def file_edited_handler(client: Client, message: Message):
|
|
| 107 |
if not title.endswith(('.mkv', '.mp4')):
|
| 108 |
title += '.mkv'
|
| 109 |
|
| 110 |
-
# Add the new quality to the correct DB movie/show
|
| 111 |
await file_queue.put((metadata_info, int(channel), msg_id, size, title))
|
| 112 |
else:
|
| 113 |
-
pass
|
| 114 |
except Exception as e:
|
| 115 |
LOGGER.error(f"Error handling edited generic file {message.id}: {e}")
|
| 116 |
|
| 117 |
@Client.on_deleted_messages(filters.channel)
|
| 118 |
async def file_deleted_handler(client: Client, messages: list[Message]):
|
| 119 |
-
# pyrogram provides a list of deleted messages.
|
| 120 |
try:
|
| 121 |
-
from Backend.helper.encrypt import encode_string
|
| 122 |
|
| 123 |
for message in messages:
|
| 124 |
if message.chat and str(message.chat.id) in Telegram.AUTH_CHANNEL:
|
|
|
|
| 10 |
from pyrogram.types import Message
|
| 11 |
from pyrogram.errors import FloodWait
|
| 12 |
from pyrogram.enums.parse_mode import ParseMode
|
| 13 |
+
from Backend.helper.encrypt import encode_string
|
| 14 |
+
from Backend.helper.encrypt import encode_string
|
| 15 |
+
from Backend.helper.metadata import extract_default_id
|
| 16 |
|
| 17 |
|
| 18 |
file_queue = Queue()
|
|
|
|
| 87 |
size = get_readable_file_size(file.file_size)
|
| 88 |
channel = str(message.chat.id).replace("-100", "")
|
| 89 |
|
|
|
|
| 90 |
override_id = extract_default_id(message.caption) if message.caption else None
|
| 91 |
|
|
|
|
| 92 |
if override_id:
|
| 93 |
LOGGER.info(f"Detected override ID '{override_id}' in edited message {msg_id}")
|
| 94 |
|
|
|
|
| 95 |
stream_id_hash = await encode_string({"chat_id": int(channel), "msg_id": msg_id})
|
| 96 |
|
|
|
|
| 97 |
await db.delete_media_by_stream_id(stream_id_hash)
|
| 98 |
|
|
|
|
| 99 |
metadata_info = await metadata(clean_filename(title), int(channel), msg_id, override_id=override_id)
|
| 100 |
if metadata_info is None:
|
| 101 |
LOGGER.warning(f"Metadata failed for edited file: {title} (ID: {msg_id})")
|
|
|
|
| 105 |
if not title.endswith(('.mkv', '.mp4')):
|
| 106 |
title += '.mkv'
|
| 107 |
|
|
|
|
| 108 |
await file_queue.put((metadata_info, int(channel), msg_id, size, title))
|
| 109 |
else:
|
| 110 |
+
pass
|
| 111 |
except Exception as e:
|
| 112 |
LOGGER.error(f"Error handling edited generic file {message.id}: {e}")
|
| 113 |
|
| 114 |
@Client.on_deleted_messages(filters.channel)
|
| 115 |
async def file_deleted_handler(client: Client, messages: list[Message]):
|
|
|
|
| 116 |
try:
|
|
|
|
| 117 |
|
| 118 |
for message in messages:
|
| 119 |
if message.chat and str(message.chat.id) in Telegram.AUTH_CHANNEL:
|
Backend/pyrofork/plugins/scanner.py
CHANGED
|
@@ -7,8 +7,6 @@ Commands (owner-only, private chat):
|
|
| 7 |
/rescan β Wipe DB entries for AUTH_CHANNELs, then full re-index
|
| 8 |
/scanstatus β Show progress of any running scan
|
| 9 |
/cancelscan β Abort a running scan gracefully
|
| 10 |
-
|
| 11 |
-
Drop this file into Backend/pyrofork/plugins/scanner.py
|
| 12 |
"""
|
| 13 |
|
| 14 |
import asyncio
|
|
@@ -56,9 +54,8 @@ class _ScanState:
|
|
| 56 |
|
| 57 |
scan_state = _ScanState()
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
RATE_LIMIT_DELAY = 0.3 # seconds between get_messages calls
|
| 62 |
|
| 63 |
|
| 64 |
# ββ Helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -104,7 +101,7 @@ async def _update_progress(force: bool = False):
|
|
| 104 |
except FloodWait as e:
|
| 105 |
await asyncio.sleep(e.value)
|
| 106 |
except Exception:
|
| 107 |
-
pass
|
| 108 |
|
| 109 |
|
| 110 |
async def _scan_channel(client: Client, chat_id: int):
|
|
@@ -134,8 +131,8 @@ async def _scan_channel(client: Client, chat_id: int):
|
|
| 134 |
LOGGER.info(f"[Scanner] Starting scan of {s.channel_name} ({chat_id})")
|
| 135 |
|
| 136 |
BATCH_SIZE = 200
|
| 137 |
-
MAX_EMPTY_BATCHES = 5
|
| 138 |
-
MAX_ID_CAP = 500_000
|
| 139 |
empty_streak = 0
|
| 140 |
current = 1
|
| 141 |
|
|
|
|
| 7 |
/rescan β Wipe DB entries for AUTH_CHANNELs, then full re-index
|
| 8 |
/scanstatus β Show progress of any running scan
|
| 9 |
/cancelscan β Abort a running scan gracefully
|
|
|
|
|
|
|
| 10 |
"""
|
| 11 |
|
| 12 |
import asyncio
|
|
|
|
| 54 |
|
| 55 |
scan_state = _ScanState()
|
| 56 |
|
| 57 |
+
PROGRESS_EVERY = 15
|
| 58 |
+
RATE_LIMIT_DELAY = 0.3
|
|
|
|
| 59 |
|
| 60 |
|
| 61 |
# ββ Helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 101 |
except FloodWait as e:
|
| 102 |
await asyncio.sleep(e.value)
|
| 103 |
except Exception:
|
| 104 |
+
pass
|
| 105 |
|
| 106 |
|
| 107 |
async def _scan_channel(client: Client, chat_id: int):
|
|
|
|
| 131 |
LOGGER.info(f"[Scanner] Starting scan of {s.channel_name} ({chat_id})")
|
| 132 |
|
| 133 |
BATCH_SIZE = 200
|
| 134 |
+
MAX_EMPTY_BATCHES = 5
|
| 135 |
+
MAX_ID_CAP = 500_000
|
| 136 |
empty_streak = 0
|
| 137 |
current = 1
|
| 138 |
|
Backend/pyrofork/plugins/start.py
CHANGED
|
@@ -11,13 +11,9 @@ print("DEBUG: start.py PLUGIN LOADED SUCCESSFULLY!")
|
|
| 11 |
async def send_start_message(client: Client, message: Message):
|
| 12 |
try:
|
| 13 |
user_id = (message.from_user.id if message.from_user else None) or (message.sender_chat.id if message.sender_chat else None) or message.chat.id
|
| 14 |
-
print(f"DEBUG: Received /start command from {user_id}")
|
| 15 |
-
# await message.reply_text("DEBUG: Bot received the start command.")
|
| 16 |
-
|
| 17 |
base_url = Telegram.BASE_URL
|
| 18 |
addon_url = f"{base_url}/stremio/manifest.json"
|
| 19 |
|
| 20 |
-
# If subscriptions are NOT enabled
|
| 21 |
if not Telegram.SUBSCRIPTION:
|
| 22 |
# Generate or fetch API token for free user
|
| 23 |
user_name = (message.from_user.first_name or message.from_user.username or f"User {user_id}") if message.from_user else f"Chat {user_id}"
|
|
|
|
| 11 |
async def send_start_message(client: Client, message: Message):
|
| 12 |
try:
|
| 13 |
user_id = (message.from_user.id if message.from_user else None) or (message.sender_chat.id if message.sender_chat else None) or message.chat.id
|
|
|
|
|
|
|
|
|
|
| 14 |
base_url = Telegram.BASE_URL
|
| 15 |
addon_url = f"{base_url}/stremio/manifest.json"
|
| 16 |
|
|
|
|
| 17 |
if not Telegram.SUBSCRIPTION:
|
| 18 |
# Generate or fetch API token for free user
|
| 19 |
user_name = (message.from_user.first_name or message.from_user.username or f"User {user_id}") if message.from_user else f"Chat {user_id}"
|
Backend/pyrofork/plugins/utilities.py
CHANGED
|
@@ -8,8 +8,6 @@ Commands (owner-only, private chat):
|
|
| 8 |
/dbcheck purge β Find and delete orphaned entries
|
| 9 |
/exportchannels β Export AUTH_CHANNEL list as JSON
|
| 10 |
/importchannels <json> β Import channels from JSON
|
| 11 |
-
|
| 12 |
-
Drop this file into Backend/pyrofork/plugins/utilities.py
|
| 13 |
"""
|
| 14 |
|
| 15 |
import asyncio
|
|
|
|
| 8 |
/dbcheck purge β Find and delete orphaned entries
|
| 9 |
/exportchannels β Export AUTH_CHANNEL list as JSON
|
| 10 |
/importchannels <json> β Import channels from JSON
|
|
|
|
|
|
|
| 11 |
"""
|
| 12 |
|
| 13 |
import asyncio
|