Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerpq authored Oct 30, 2023
1 parent d62e9d0 commit 3f72c96
Show file tree
Hide file tree
Showing 17 changed files with 1,990 additions and 0 deletions.
7 changes: 7 additions & 0 deletions repthon/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .decorators import check_owner

CMD_INFO = {}
PLG_INFO = {}
GRP_INFO = {}
BOT_INFO = []
LOADED_CMDS = {}
352 changes: 352 additions & 0 deletions repthon/core/client.py

Large diffs are not rendered by default.

94 changes: 94 additions & 0 deletions repthon/core/cmdinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
from typing import Dict, List, Union

from ..helpers.utils.extdl import install_pip

try:
from urlextract import URLExtract
except ModuleNotFoundError:
install_pip("urlextract")
from urlextract import URLExtract

from ..Config import Config

extractor = URLExtract()


def get_data(about, ktype):
data = about[ktype]
urls = extractor.find_urls(data)
if len(urls) > 0:
return data
return data.capitalize()


def _format_about(
about: Union[str, Dict[str, Union[str, List[str], Dict[str, str]]]]
) -> str: # sourcery no-metrics
if not isinstance(about, dict):
return about
tmp_chelp = ""
if "header" in about and isinstance(about["header"], str):
tmp_chelp += f"__{about['header'].title()}__"
del about["header"]
if "description" in about and isinstance(about["description"], str):
tmp_chelp += (
"\n\n✘ **Description :**\n" f"__{get_data(about , 'description')}__"
)
del about["description"]
if "flags" in about:
tmp_chelp += "\n\n✘ **Available Flags :**"
if isinstance(about["flags"], dict):
for f_n, f_d in about["flags"].items():
tmp_chelp += f"\n ▫ `{f_n}` : __{f_d.lower()}__"
else:
tmp_chelp += f"\n {about['flags']}"
del about["flags"]
if "options" in about:
tmp_chelp += "\n\n✘ **Available Options :**"
if isinstance(about["options"], dict):
for o_n, o_d in about["options"].items():
tmp_chelp += f"\n ▫ `{o_n}` : __{o_d.lower()}__"
else:
tmp_chelp += f"\n __{about['options']}__"
del about["options"]
if "types" in about:
tmp_chelp += "\n\n✘ **Supported Types :**"
if isinstance(about["types"], list):
for _opt in about["types"]:
tmp_chelp += f"\n `{_opt}` ,"
else:
tmp_chelp += f"\n __{about['types']}__"
del about["types"]
if "usage" in about:
tmp_chelp += "\n\n✘ **Usage :**"
if isinstance(about["usage"], list):
for ex_ in about["usage"]:
tmp_chelp += f"\n `{ex_}`"
else:
tmp_chelp += f"\n `{about['usage']}`"
del about["usage"]
if "examples" in about:
tmp_chelp += "\n\n✘ **Examples :**"
if isinstance(about["examples"], list):
for ex_ in about["examples"]:
tmp_chelp += f"\n `{ex_}`"
else:
tmp_chelp += f"\n `{about['examples']}`"
del about["examples"]
if "others" in about:
tmp_chelp += f"\n\n✘ **Others :**\n__{get_data(about , 'others')}__"
del about["others"]
if about:
for t_n, t_d in about.items():
tmp_chelp += f"\n\n✘ **{t_n.title()} :**\n"
if isinstance(t_d, dict):
for o_n, o_d in t_d.items():
tmp_chelp += f" ▫ `{o_n}` : __{get_data(t_d , o_n)}__\n"
elif isinstance(t_d, list):
for _opt in t_d:
tmp_chelp += f" `{_opt}` ,"
tmp_chelp += "\n"
else:
tmp_chelp += f"__{get_data(about ,t_n)}__"
tmp_chelp += "\n"
return tmp_chelp.replace("{tr}", Config.COMMAND_HAND_LER)
36 changes: 36 additions & 0 deletions repthon/core/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from ..sql_helper.global_collectionjson import get_collection
from ..sql_helper.global_list import get_collection_list


def _sudousers_list():
try:
sudousers = get_collection("sudousers_list").json
except AttributeError:
sudousers = {}
ulist = sudousers.keys()
return [int(chat) for chat in ulist]


def _users_list():
try:
sudousers = get_collection("sudousers_list").json
except AttributeError:
sudousers = {}
ulist = sudousers.keys()
ulist = [int(chat) for chat in ulist]
ulist.append("me")
return list(ulist)


def blacklist_chats_list():
try:
blacklistchats = get_collection("blacklist_chats_list").json
except AttributeError:
blacklistchats = {}
blacklist = blacklistchats.keys()
return [int(chat) for chat in blacklist]


def sudo_enabled_cmds():
listcmds = get_collection_list("sudo_enabled_cmds")
return list(listcmds)
32 changes: 32 additions & 0 deletions repthon/core/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import asyncio

from telethon.errors import FloodWaitError, MessageNotModifiedError
from telethon.events import CallbackQuery

from ..Config import Config
from ..sql_helper.globals import gvarstatus


def check_owner(func):
async def wrapper(c_q: CallbackQuery):
if c_q.query.user_id and (
c_q.query.user_id == Config.OWNER_ID
or c_q.query.user_id in Config.SUDO_USERS
):
try:
await func(c_q)
except FloodWaitError as e:
await asyncio.sleep(e.seconds + 5)
except MessageNotModifiedError:
pass
else:
HELP_TEXT = (
gvarstatus("HELP_TEXT")
or "- عـذراً .. هـذه اللوحـه خاصـه بـ مـالك البـوت\n\n- قم بتنصيب بوت خاص بك من القناة @Repthon"
)
await c_q.answer(
HELP_TEXT,
alert=True,
)

return wrapper
Loading

0 comments on commit 3f72c96

Please sign in to comment.