Skip to content

Commit 9dfc84b

Browse files
committed
major changes
* Switched from Pyrogram to Pyrofork * Implemented modules folder structure * Added kernelsu command * Fixed bugs * Improved functions
1 parent 5a08791 commit 9dfc84b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+924
-684
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ psycopg2-binary
1717
pybase64
1818
pydrive
1919
pylast
20-
pyrogram==2.0.106
20+
pyrofork
2121
pysmartDL
2222
python-barcode
2323
python-dotenv

sedenbot/__init__.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from importlib import import_module
1212
from logging import CRITICAL, DEBUG, INFO, basicConfig, getLogger
1313
from os import environ, listdir, path, remove
14-
from os.path import isfile
14+
from os.path import isfile, join, isdir
1515
from pathlib import PurePath
1616
from re import search as resr
1717
from sqlite3 import connect
@@ -92,6 +92,7 @@ def set_logger():
9292
'pyrogram.session.session',
9393
'pyrogram.session.auth',
9494
'asyncio',
95+
'aiosqlite',
9596
]
9697
level = CRITICAL
9798

@@ -258,18 +259,27 @@ def export_session_string(self):
258259

259260
def __get_modules():
260261
folder = 'sedenbot/modules'
261-
modules = [
262-
f[:-3]
263-
for f in listdir(folder)
264-
if isfile(f'{folder}/{f}') and f[-3:] == '.py' and f != '__init__.py'
262+
subdirectories = [
263+
sub
264+
for sub in listdir(folder)
265+
if isdir(join(folder, sub))
265266
]
267+
modules = []
268+
for subdirectory in subdirectories:
269+
subfolder_path = join(folder, subdirectory)
270+
py_files = [
271+
f[:-3]
272+
for f in listdir(subfolder_path)
273+
if isfile(join(subfolder_path, f)) and f.endswith('.py')
274+
]
275+
for module in py_files:
276+
module_name = f"{subdirectory.replace('/', '.')}.{module}"
277+
modules.append(module_name)
266278
return modules
267279

268280

269281
def __import_modules():
270282
get_modules = sorted(__get_modules())
271-
modules = ', '.join(get_modules)
272-
LOGS.info(get_translation('loadedModules', [modules]))
273283
for module in get_modules:
274284
try:
275285
import_module(f'sedenbot.modules.{module}')
@@ -278,5 +288,9 @@ def __import_modules():
278288
LOGS.warn(format_exc())
279289
LOGS.warn(get_translation('loadedModulesError', [module]))
280290

291+
imported_modules = [module.split('.')[-1] for module in get_modules if module.count('.') > 0]
292+
modules = ', '.join(imported_modules)
293+
LOGS.info(get_translation('loadedModules', [modules]))
294+
281295

282296
__import_modules()
File renamed without changes.

sedenbot/modules/env.py renamed to sedenbot/modules/admin/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
set_local_env,
2222
unset_local_env,
2323
)
24-
from sedenbot.modules.horeke import restart
24+
from sedenbot.modules.miscs.horeke import restart
2525
from sedenecem.core import edit, extract_args, get_translation, sedenify
2626

2727

File renamed without changes.

sedenbot/modules/system.py renamed to sedenbot/modules/admin/system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pyrogram.raw.functions.help import GetNearestDc
1717

1818
from sedenbot import ALIVE_MSG, BOT_VERSION, CHANNEL, HELP
19-
from sedenbot.modules.ecem import ecem
19+
from sedenbot.modules.admin.ecem import ecem
2020
from sedenecem.core import (
2121
edit,
2222
extract_args,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

sedenbot/modules/chat.py renamed to sedenbot/modules/chat/chat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def keep_read(message):
8181
@sedenify(pattern='^.call')
8282
def call_notes(message):
8383
try:
84-
from sedenbot.modules.notes import get_note
85-
from sedenbot.modules.snips import get_snip
84+
from sedenbot.modules.deneme.notes import get_note
85+
from sedenbot.modules.var.snips import get_snip
8686
except BaseException:
8787
edit(message, f'`{get_translation("nonSqlMode")}`')
8888
return
File renamed without changes.

sedenbot/modules/globals.py renamed to sedenbot/modules/chat/globals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pyrogram import enums
1313
from pyrogram.types import ChatPermissions
1414
from sedenbot import BRAIN, HELP, LOGS
15-
from sedenbot.modules.ban import get_reason
15+
from sedenbot.modules.chat.ban import get_reason
1616
from sedenecem.core import (
1717
edit,
1818
extract_args_split,
File renamed without changes.
File renamed without changes.

sedenbot/modules/pmpermit.py renamed to sedenbot/modules/chat/pmpermit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pyrogram.raw.functions.messages import ReportSpam
1212
from pyrogram.raw.types import InputPeerUser
1313
from sedenbot import HELP, LOGS, PM_AUTO_BAN, PM_MSG_COUNT, PM_UNAPPROVED, TEMP_SETTINGS
14-
from sedenbot.modules.chat import is_muted
14+
from sedenbot.modules.chat.chat import is_muted
1515
from sedenecem.core import edit, get_translation, reply, sedenify, send_log
1616
from sqlalchemy.exc import IntegrityError
1717

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

sedenbot/modules/fun/carbon_text.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Copyright (C) 2020-2024 TeamDerUntergang <https://github.com/TeamDerUntergang>
2+
#
3+
# This file is part of TeamDerUntergang project,
4+
# and licensed under GNU Affero General Public License v3.
5+
# See the GNU Affero General Public License for more details.
6+
#
7+
# All rights reserved. See COPYING, AUTHORS.
8+
#
9+
10+
from os import path, remove
11+
from time import sleep
12+
from urllib.parse import quote_plus
13+
14+
from gtts import gTTS
15+
from selenium.webdriver.common.by import By
16+
17+
from sedenbot import HELP, SEDEN_LANG
18+
from sedenecem.core import (
19+
edit,
20+
extract_args,
21+
extract_args_split,
22+
get_translation,
23+
get_webdriver,
24+
reply_doc,
25+
reply_voice,
26+
sedenify,
27+
send_log,
28+
)
29+
30+
CARBONLANG = 'auto'
31+
TTS_LANG = SEDEN_LANG
32+
TRT_LANG = SEDEN_LANG
33+
34+
35+
@sedenify(pattern='^.crblang')
36+
def carbonlang(message):
37+
global CARBONLANG
38+
CARBONLANG = extract_args(message)
39+
edit(message, get_translation('carbonLang', ['**', CARBONLANG]))
40+
41+
42+
@sedenify(pattern='^.carbon')
43+
def carbon(message):
44+
match = extract_args(message)
45+
if len(match) < 1:
46+
edit(message, f'`{get_translation("wrongCommand")}`')
47+
return
48+
edit(message, f'`{get_translation("processing")}`')
49+
reply = message.reply_to_message
50+
pcode = message.text
51+
if pcode[8:]:
52+
pcode = str(pcode[8:])
53+
elif reply:
54+
pcode = str(reply.message)
55+
code = quote_plus(pcode)
56+
global CARBONLANG
57+
CARBON = f'https://carbon.now.sh/?l={CARBONLANG}&code={code}'
58+
edit(message, f'`{get_translation("processing")}\n%25`')
59+
if path.isfile('./carbon.png'):
60+
remove('./carbon.png')
61+
driver = get_webdriver()
62+
driver.get(CARBON)
63+
edit(message, f'`{get_translation("processing")}\n%50`')
64+
driver.command_executor._commands['send_command'] = (
65+
'POST',
66+
'/session/$sessionId/chromium/send_command',
67+
)
68+
driver.find_element(By.XPATH, "//button[contains(text(),'Export')]").click()
69+
edit(message, f'`{get_translation("processing")}\n%75`')
70+
while not path.isfile('./carbon.png'):
71+
sleep(0.5)
72+
edit(message, f'`{get_translation("processing")}\n%100`')
73+
file = './carbon.png'
74+
edit(message, f'`{get_translation("carbonUpload")}`')
75+
reply_doc(
76+
reply if reply else message,
77+
file,
78+
caption=get_translation('carbonResult'),
79+
delete_after_send=True,
80+
)
81+
message.delete()
82+
driver.quit()
83+
84+
85+
@sedenify(pattern='^.tts')
86+
def text_to_speech(message):
87+
reply = message.reply_to_message
88+
args = extract_args(message)
89+
if args:
90+
pass
91+
elif reply:
92+
if not reply.text:
93+
return edit(message, f'`{get_translation("ttsUsage")}`')
94+
args = reply.text
95+
else:
96+
edit(message, f'`{get_translation("ttsUsage")}`')
97+
return
98+
99+
try:
100+
gTTS(args, lang=TTS_LANG)
101+
except AssertionError:
102+
edit(message, f'`{get_translation("ttsBlank")}`')
103+
return
104+
except ValueError:
105+
edit(message, f'`{get_translation("ttsNoSupport")}`')
106+
return
107+
except RuntimeError:
108+
edit(message, f'`{get_translation("ttsError")}`')
109+
return
110+
tts = gTTS(args, lang=TTS_LANG)
111+
tts.save('h.mp3')
112+
with open('h.mp3', 'rb') as audio:
113+
linelist = list(audio)
114+
linecount = len(linelist)
115+
if linecount == 1:
116+
tts = gTTS(args, lang=TTS_LANG)
117+
tts.save('h.mp3')
118+
with open('h.mp3', 'r'):
119+
reply_voice(reply if reply else message, 'h.mp3', delete_file=True)
120+
121+
message.delete()
122+
send_log(get_translation('ttsLog'))
123+
124+
HELP.update({'carbon': get_translation('carbonInfo')})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)