Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,37 @@
from pyromod import listen
from pyrogram import Client, idle, __version__
from pyrogram.raw.all import layer
import collections
import collections.abc
import sys
import types

import collections
import collections.abc
import sys
import types

# 1. Collections compatibility patch
collections.Iterable = collections.abc.Iterable
collections.Mapping = collections.abc.Mapping
collections.MutableMapping = collections.abc.MutableMapping
collections.Sequence = collections.abc.Sequence
collections.MutableSet = collections.abc.MutableSet # <--- Add this line!

# 2. Ravenclaw/Chronometry Patch
try:
import ravenclaw.preprocessing
except ImportError:
m = types.ModuleType("ravenclaw.preprocessing")
sys.modules["ravenclaw.preprocessing"] = m
ravenclaw.preprocessing = m

if not hasattr(ravenclaw.preprocessing, 'Polynomial'):
ravenclaw.preprocessing.Polynomial = type('Polynomial', (), {})
if not hasattr(ravenclaw.preprocessing, 'Normalizer'):
ravenclaw.preprocessing.Normalizer = type('Normalizer', (), {})

# ... existing code (imports like from pyromod import listen, etc)

logging.basicConfig(level=logging.INFO)
plugins = dict(root="plugins")
Expand All @@ -21,3 +51,4 @@ async def main():
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

6 changes: 2 additions & 4 deletions functions/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ def finished(self) -> bool:
@property
def read_line(self) -> str:
return (self._stdout_line + self._stderr_line).decode('utf-8').rstrip()
#return (self._stdout + self._stderr).decode('utf-8').strip()

@property
def get_output(self) -> str:
return (self._stdout + self._stderr).decode('utf-8').rstrip()

async def _read_stdout(self) -> None:
while True:
#line = await self._process.stdout.readline()
line = await self._process.stdout.read(n=1024)
if line:
self._stdout_line = line
Expand All @@ -38,7 +36,6 @@ async def _read_stdout(self) -> None:

async def _read_stderr(self) -> None:
while True:
#line = await self._process.stderr.readline()
line = await self._process.stderr.read(n=1024)
if line:
self._stderr_line = line
Expand All @@ -47,7 +44,7 @@ async def _read_stderr(self) -> None:
break

async def worker(self) -> None:
await asyncio.wait([self._read_stdout(), self._read_stderr()])
await asyncio.gather(self._read_stdout(), self._read_stderr())
await self._process.wait()
self._finished = True

Expand All @@ -58,3 +55,4 @@ async def execute(cls, cmd: str):
t_obj = cls(process)
asyncio.get_event_loop().create_task(t_obj.worker())
return t_obj

5 changes: 3 additions & 2 deletions plugins/commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from functions.functions import ip, get_server_speedtest, get_server_details
from config import allowed, help_text
from plugins.markups import start_and_help, refresh_space, base_markup
from pyrogram import Client, filters
from pyrogram import Client, filters, enums
from pyrogram.types import Message, ForceReply
import os

Expand All @@ -13,7 +13,7 @@ async def start(_, m: Message):

@Client.on_message(filters.command('ip') & filters.user(allowed))
async def ip_cmd(_, m: Message):
await m.reply(ip(), parse_mode='markdown')
await m.reply(ip(), parse_mode=enums.ParseMode.MARKDOWN)


@Client.on_message(filters.command('stats') & filters.user(allowed))
Expand Down Expand Up @@ -47,3 +47,4 @@ async def cd(client, m: Message):
@Client.on_message(filters.command('my_files') & filters.user(allowed))
async def my_files(_, m: Message):
await m.reply_text('what you want to show?', reply_markup=base_markup)

8 changes: 4 additions & 4 deletions plugins/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ async def exec_cmd(_: Client, msg: Message):
if not k:
k = await msg.reply(out_data)
else:
await k.edit(out_data)
await k.edit_text(out_data)
except Exception:
pass
out_data = f"`{output}{cmd.get_output}`"
out_data = f"{output}`{cmd.get_output}`"
if len(out_data) > 4096:
if k:
await k.delete()
Expand All @@ -45,6 +45,6 @@ async def exec_cmd(_: Client, msg: Message):
"terminal.txt", caption=cmd)
os.remove("terminal.txt")
return
send = k.edit if k else msg.reply
send = k.edit_text if k else msg.reply
await send(out_data)