Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
Switched to NekoZee v2

- Specially optimized for download and upload

- Handled error in fsub module if the bot is not added into the channels

Signed-off-by: Dawn India <[email protected]>
  • Loading branch information
Dawn-India committed Aug 23, 2024
1 parent 1ebed7c commit 4003c97
Show file tree
Hide file tree
Showing 38 changed files with 87 additions and 102 deletions.
6 changes: 2 additions & 4 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)
from pymongo.mongo_client import MongoClient
from pymongo.server_api import ServerApi
from pyrogram import (
from nekozee import (
Client as tgClient
)
from qbittorrentapi import Client as qbClient
Expand All @@ -58,7 +58,7 @@
getLogger("apscheduler").setLevel(ERROR)
getLogger("httpx").setLevel(ERROR)
getLogger("pymongo").setLevel(ERROR)
getLogger("pyrogram").setLevel(ERROR)
getLogger("nekozee").setLevel(ERROR)

botStartTime = time()
bot_loop = get_event_loop()
Expand Down Expand Up @@ -295,7 +295,6 @@
app_version="@Z_Mirror Session",
device_model="@Z_Mirror Bot",
system_version="@Z_Mirror Server",
max_concurrent_transmissions=10,
).start()
IS_PREMIUM_USER = user.me.is_premium # type: ignore
log_info(f"Successfully logged into @{user.me.username} DC: {user.session.dc_id}.") # type: ignore
Expand Down Expand Up @@ -1276,7 +1275,6 @@
app_version="@Z_Mirror Session",
device_model="@Z_Mirror Bot",
system_version="@Z_Mirror Server",
max_concurrent_transmissions=10,
).start()

BASE += ("oAtiUyppVYRQkuWg8DG2p")
Expand Down
4 changes: 2 additions & 2 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
create_subprocess_exec
)
from os import execl as osexecl
from pyrogram.filters import command
from pyrogram.handlers import MessageHandler
from nekozee.filters import command
from nekozee.handlers import MessageHandler
from signal import signal, SIGINT
from sys import executable
from time import time
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
move,
copy2
)
from pyrogram.enums import ChatAction
from nekozee.enums import ChatAction
from re import sub, I

from bot import (
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from asyncio.subprocess import PIPE
from functools import partial, wraps

from pyrogram.types import BotCommand
from nekozee.types import BotCommand
from httpx import AsyncClient

from bot import (
Expand Down
12 changes: 6 additions & 6 deletions bot/helper/ext_utils/status_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,15 @@ async def get_readable_message(
and int(config_dict["AUTO_DELETE_MESSAGE_DURATION"]) > 0
):
msg += (
f"<pre>\r\n{index + start_position} "
f"{escape(f"{task.name()}")}\n</pre>"
f"<b><i>\n#Zee{index + start_position}: "
f"{escape(f"{task.name()}")}\n</i></b>"
if elapse <= config_dict["AUTO_DELETE_MESSAGE_DURATION"]
else f"\n<blockquote>{index + start_position}(Processing)</blockquote>"
else f"\n<b>#Zee{index + start_position}...(Processing)</b>"
)
else:
msg += (
f"<pre>\r\n{index + start_position} "
f"{escape(f"{task.name()}")}\n</pre>"
f"<b><i>\n#Zee{index + start_position}: "
f"{escape(f"{task.name()}")}\n</i></b>"
)
if tstatus not in [
MirrorStatus.STATUS_SEEDING,
Expand Down Expand Up @@ -318,7 +318,7 @@ async def get_readable_message(
f"\n<code>UserID :</code> ||{task.listener.userId}||"
f"\n<code>Engine :</code> {task.engine}"
)
msg += f"\n<blockquote>⚠️ {cancel_task}</blockquote>\n\n"
msg += f"\n⚠️ {cancel_task}\n\n"

if len(msg) == 0:
if status == "All":
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/ext_utils/token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from bot.helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper.message_utils import sendMessage, sendLogMessage

from pyrogram.filters import command
from pyrogram.handlers import MessageHandler
from nekozee.filters import command
from nekozee.handlers import MessageHandler


async def checking_access(user_id, button=None):
Expand Down
6 changes: 3 additions & 3 deletions bot/helper/listeners/task_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ async def onUploadComplete(
)
gmsg = f"\n<b>Hey {self.tag}!\nYour job is done.</b>"
msg = (
f"\n\n<blockquote><code>Size </code>: {get_readable_file_size(self.size)}"
f"\n\n<code>Size </code>: {get_readable_file_size(self.size)}"
f"\n<code>Past </code>: {get_readable_time(time() - self.time)}"
f"\n<code>Mode </code>: {self.mode}"
)
Expand All @@ -437,7 +437,7 @@ async def onUploadComplete(
)
msg_ = "\n\n<b><i>Link has been sent in your DM.</b></i>"
if self.isLeech:
msg += f"\n<code>Files </code>: {folders}</blockquote>\n"
msg += f"\n<code>Files </code>: {folders}\n"
if mime_type != 0:
msg += f"<code>Error </code>: {mime_type}\n"
msg_ = "\n<b><i>Files has been sent in your DM.</b></i>"
Expand Down Expand Up @@ -537,7 +537,7 @@ async def onUploadComplete(
gmsg + msg + msg_
)
else:
msg += f"\n<code>Type </code>: {mime_type}</blockquote>"
msg += f"\n<code>Type </code>: {mime_type}"
if mime_type == "Folder":
msg += f"\n<code>Files </code>: {files}"
msg += f"\n<code>Folder</code>: {folders}"
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/listeners/ytdlp_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
sendMessage
)

from pyrogram.handlers import CallbackQueryHandler
from pyrogram.filters import (
from nekozee.handlers import CallbackQueryHandler
from nekozee.filters import (
regex,
user
)
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/task_utils/download_utils/jd_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
wait_for,
)
from functools import partial
from pyrogram.filters import (
from nekozee.filters import (
regex,
user
)
from pyrogram.handlers import CallbackQueryHandler
from nekozee.handlers import CallbackQueryHandler
from time import time
from aiofiles.os import path as aiopath
from aiofiles import open as aiopen
Expand Down
12 changes: 3 additions & 9 deletions bot/helper/task_utils/download_utils/telegram_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
sleep
)
from time import time
from pyrogram.errors import (
FloodWait,
FloodPremiumWait
)
from nekozee.errors import FloodWait

from bot import (
config_dict,
Expand Down Expand Up @@ -98,11 +95,8 @@ async def _download(self, message, path):
if self._listener.isCancelled:
await self._onDownloadError("Cancelled by user!")
return

except (
FloodWait,
FloodPremiumWait
) as f:

except FloodWait as f:
LOGGER.warning(str(f))
await sleep(f.value) # type: ignore
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/task_utils/gdrive_utils/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from functools import partial
from logging import getLogger
from natsort import natsorted
from pyrogram.filters import (
from nekozee.filters import (
regex,
user
)
from pyrogram.handlers import CallbackQueryHandler
from nekozee.handlers import CallbackQueryHandler
from tenacity import RetryError
from time import time

Expand Down
4 changes: 2 additions & 2 deletions bot/helper/task_utils/rclone_utils/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from configparser import ConfigParser
from functools import partial
from json import loads
from pyrogram.filters import (
from nekozee.filters import (
regex,
user
)
from pyrogram.handlers import CallbackQueryHandler
from nekozee.handlers import CallbackQueryHandler
from time import time

from bot import LOGGER, config_dict
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/task_utils/status_utils/aria2_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(
self.queued = queued
self.start_time = 0
self.seeding = seeding
self.engine = f"Aria2 v{self._eng_ver()}"
self.engine = f"Aria2c v{self._eng_ver()}"

def _eng_ver(self):
return aria2.client.get_version()["version"]
Expand Down
14 changes: 4 additions & 10 deletions bot/helper/task_utils/telegram_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
walk,
path as ospath
)
from pyrogram.errors import (
from nekozee.errors import (
FloodWait,
FloodPremiumWait,
RPCError,
SlowmodeWait
RPCError
)
from pyrogram.types import (
from nekozee.types import (
InputMediaVideo,
InputMediaDocument,
InputMediaPhoto
Expand Down Expand Up @@ -812,11 +810,7 @@ async def _upload_file(self, cap_mono, file, o_path, force_document=False):
and await aiopath.exists(thumb)
):
await remove(thumb)
except (
FloodWait,
FloodPremiumWait,
SlowmodeWait
) as f:
except FloodWait as f:
LOGGER.warning(str(f))
await sleep(f.value * 1.3) # type: ignore
if (
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/telegram_helper/button_build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pyrogram.types import (
from nekozee.types import (
InlineKeyboardMarkup,
InlineKeyboardButton
)
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/telegram_helper/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pyrogram.filters import create
from nekozee.filters import create

from bot import user_data, OWNER_ID

Expand Down
13 changes: 6 additions & 7 deletions bot/helper/telegram_helper/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
sleep,
create_task,
)
from pyrogram.errors import (
from nekozee.errors import (
FloodWait,
FloodPremiumWait,
PeerIdInvalid,
RPCError,
UserNotParticipant,
)
from pyrogram.types import ChatPermissions
from pyrogram.enums import ChatAction
from nekozee.types import ChatPermissions
from nekozee.enums import ChatAction
from re import match as re_match
from time import time
from datetime import (
Expand Down Expand Up @@ -112,7 +111,7 @@ async def sendRss(text):
disable_web_page_preview=True,
disable_notification=True,
)
except (FloodWait, FloodPremiumWait) as f:
except FloodWait as f:
LOGGER.warning(str(f))
await sleep(f.value * 1.2) # type: ignore
return await sendRss(text)
Expand Down Expand Up @@ -517,8 +516,8 @@ async def forcesub(message, ids, button=None):
continue
try:
chat = await message._client.get_chat(channel_id)
except PeerIdInvalid as e:
LOGGER.error(f"{e.NAME}: {e.MESSAGE} for {channel_id}")
except (PeerIdInvalid, RPCError) as e:
LOGGER.error(f"{e.NAME}: {e.MESSAGE} for {channel_id}. Mostly I'm not added in the channel as admin.")
continue
try:
await chat.get_member(message.from_user.id)
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/anonymous.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pyrogram.filters import regex
from pyrogram.handlers import CallbackQueryHandler
from nekozee.filters import regex
from nekozee.handlers import CallbackQueryHandler

from bot import (
bot,
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/authorize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pyrogram.filters import command
from pyrogram.handlers import MessageHandler
from nekozee.filters import command
from nekozee.handlers import MessageHandler

from bot import (
user_data,
Expand Down
6 changes: 3 additions & 3 deletions bot/modules/bot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
getcwd
)

from pyrogram import filters
from pyrogram.handlers import (
from nekozee import filters
from nekozee.handlers import (
MessageHandler,
CallbackQueryHandler
)
from pyrogram.errors import (
from nekozee.errors import (
ListenerTimeout,
ListenerStopped
)
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/cancel_task.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from asyncio import sleep
from re import search as re_search
from pyrogram.filters import (
from nekozee.filters import (
command,
regex
)
from pyrogram.handlers import (
from nekozee.handlers import (
MessageHandler,
CallbackQueryHandler
)
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/clone.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from asyncio import gather
from json import loads
from pyrogram.filters import command
from pyrogram.handlers import MessageHandler
from nekozee.filters import command
from nekozee.handlers import MessageHandler
from secrets import token_urlsafe

from bot import (
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
getcwd,
chdir
)
from pyrogram.filters import command
from pyrogram.handlers import MessageHandler
from nekozee.filters import command
from nekozee.handlers import MessageHandler
from textwrap import indent
from traceback import format_exc

Expand Down
4 changes: 2 additions & 2 deletions bot/modules/file_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
remove,
path as aiopath
)
from pyrogram.filters import (
from nekozee.filters import (
command,
regex
)
from pyrogram.handlers import (
from nekozee.handlers import (
MessageHandler,
CallbackQueryHandler
)
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/force_start.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pyrogram.filters import command
from pyrogram.handlers import MessageHandler
from nekozee.filters import command
from nekozee.handlers import MessageHandler

from bot import (
task_dict,
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/gd_count.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pyrogram.filters import command
from pyrogram.handlers import MessageHandler
from nekozee.filters import command
from nekozee.handlers import MessageHandler

from bot import bot
from bot.helper.ext_utils.bot_utils import sync_to_async
Expand Down
Loading

0 comments on commit 4003c97

Please sign in to comment.