From cc5d3ae5489241cd2ee82adafbdd8f3aa975add7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Sun, 6 Feb 2022 10:16:29 +0530 Subject: [PATCH 01/22] Update utils.py --- tronx/plugins/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tronx/plugins/utils.py b/tronx/plugins/utils.py index b56d4bec..b1ba7024 100644 --- a/tronx/plugins/utils.py +++ b/tronx/plugins/utils.py @@ -1,31 +1,31 @@ +from tronx import app + from pyrogram import filters from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton -from tronx import app - @app.bot.on_message(filters.command("id")) -async def id_of_user(_, m): +async def chat_user_id(_, m): reply = m.reply_to_message if not reply: await app.bot.send_message( m.chat.id, - f"**YOUR ID:** `{m.from_user.id}`\n**CHAT ID:** `{m.chat.id}`" + f"**{m.from_user.first_name}:** `{m.from_user.id}`\n**{m.chat.title}:** `{m.chat.id}`" ) elif reply: await app.bot.send_message( m.chat.id, - f"**REPLIED USER ID:** `{m.from_user.id}`\n**CHAT ID:** `{m.chat.id}`\n**REPLIED ID:** `{reply.from_user.id}`" + f"**{m.from_user.first_name}:** `{m.from_user.id}`\n**{m.chat.title}:** `{m.chat.id}`\n**{reply.from_user.first_name}:** `{reply.from_user.id}`" ) @app.bot.on_message(filters.command("quote")) -async def get_anime_quotes(_, m): +async def bot_anime_quotes(_, m): await app.bot.send_message( m.chat.id, app.quote(), From 75296131bcd7c4dd197e930adf0535ecaf4ab16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Sun, 6 Feb 2022 10:25:49 +0530 Subject: [PATCH 02/22] Update inlinequery.py --- tronx/plugins/inlinequery.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tronx/plugins/inlinequery.py b/tronx/plugins/inlinequery.py index 6558b8c4..0ba0606a 100644 --- a/tronx/plugins/inlinequery.py +++ b/tronx/plugins/inlinequery.py @@ -36,10 +36,10 @@ def inline_result(_, inline_query): inline_query.answer( results=[ InlineQueryResultPhoto( - photo_url=app.PMPERMIT_PIC, + photo_url=app.PmpermitPic(), title="Tron security system", description="This is tron security system, it helps you to stop spammers from spamming in your dm.", - caption=app.PMPERMIT_TEXT, + caption=app.PmpermitText(), parse_mode="combined", reply_markup=InlineKeyboardMarkup([approve]) ) From 0f4d6f871eb488198158669270f2b345c6eda425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Sun, 6 Feb 2022 10:28:40 +0530 Subject: [PATCH 03/22] Update others.py --- tronx/helpers/others.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tronx/helpers/others.py b/tronx/helpers/others.py index d42f660e..64409eb5 100644 --- a/tronx/helpers/others.py +++ b/tronx/helpers/others.py @@ -10,3 +10,11 @@ def SudoUsers(self): data_list = [int(x) for x in sudovar.split()] if sudovar else False return data_list or self.SUDO_USERS or [] + + def PmpermitPic(self): + return self.getdv("PMPERMIT_PIC") or self.PMPERMIT_PIC or None + + + def PmpermitText(self): + return self.getdv("PMPERMIT_TEXT") or self.PMPERMIT_TEXT or None + From 5f53c117e888dbd007d8827020c786ab0ad78bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Sun, 6 Feb 2022 10:55:14 +0530 Subject: [PATCH 04/22] Update functions.py --- tronx/helpers/functions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tronx/helpers/functions.py b/tronx/helpers/functions.py index 5631f43b..bd467340 100644 --- a/tronx/helpers/functions.py +++ b/tronx/helpers/functions.py @@ -188,6 +188,7 @@ async def private(self, m : Message): mono=True, delme=True ) + return def long(self, m: Message): From 7e9cfa8fcf4aba97e9dd89d1a9529a9635606aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Sun, 6 Feb 2022 10:57:13 +0530 Subject: [PATCH 05/22] Update functions.py --- tronx/helpers/functions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tronx/helpers/functions.py b/tronx/helpers/functions.py index bd467340..d3370505 100644 --- a/tronx/helpers/functions.py +++ b/tronx/helpers/functions.py @@ -426,3 +426,4 @@ def import_module(self, path, exclude=[], display_module=True): def db_status(self): """database is available or not""" "Available" if self.DB_URI else "Unavailable" + From c249f3f249878358709dad2829efbd9d1ec271dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Sun, 6 Feb 2022 11:20:45 +0530 Subject: [PATCH 06/22] Update functions.py --- tronx/helpers/functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tronx/helpers/functions.py b/tronx/helpers/functions.py index d3370505..67465b9d 100644 --- a/tronx/helpers/functions.py +++ b/tronx/helpers/functions.py @@ -188,7 +188,7 @@ async def private(self, m : Message): mono=True, delme=True ) - return + return def long(self, m: Message): From ebdd52d49d037bf22ff1ee67b2894b8845fffd63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:27:07 +0530 Subject: [PATCH 07/22] Update dev.py improving eval command by adding restrictions on executing commands which expose api keys or sessions in group ( this will help the ub owner who don't know the use of this command and use this command in public because of some users who tell them to do it, this will help them to protect their sensitive data) --- tronx/modules/dev.py | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/tronx/modules/dev.py b/tronx/modules/dev.py index 1fd99bfd..4be7d266 100644 --- a/tronx/modules/dev.py +++ b/tronx/modules/dev.py @@ -30,17 +30,40 @@ -# shortcuts -p = print -c = Config - @app.on_message(gen(["eval", "e"], allow_channel=True)) -async def evaluate(_, m): - global reply +async def evaluate(client, m: Message): + """ This function is made to execute python codes """ + + global reply, chat_id, chat_type + + access_list = ("SESSION", "API_ID", "API_HASH", "session_name", "api_id", "api_hash") + sensitive = [ f"app.{x}" for x in dir(self) if x in access_list] + [ f"self.{y}" for y in dir(self) if y in access_list] + [f"Config.{z}" for z in dir(self) if z in access_list] + warning = "Sorry but by evaluating this code your sensitive data will be exposed in this chat, aborting command !" reply = m.reply_to_message + chat_type = m.chat.type + chat_id = m.chat.id + text_list = m.command + p = print + bot = app.bot + + if chat_type in ("supergroup", "group") and chat_id != app.LOG_CHAT: + for x in text_list: + if x in sensitive: + return await send_edit(m, warning_message, mono=True, delme=4) + + elif chat_type == "private" and chat_id != app.id: + for y in text_list: + if y in sensitive: + return await send_edit(m, warning_message, mono=True, delme=4) + + elif chat_type == "bot" and chat_id != app.bot.id:: + for z in text_list: + if z in sensitive: + return await send_edit(m, warning_message, mono=True, delme=4) + try: cmd = m.text.split(" ", maxsplit=1)[1] except IndexError: @@ -48,9 +71,7 @@ async def evaluate(_, m): await app.send_edit(m, "Running . . .", mono=True) - reply_to_id = m.message_id - if reply: - reply_to_id = reply.message_id + reply_to_id = reply.message_id if reply else m.message_id old_stderr = sys.stderr old_stdout = sys.stdout From 51ddafe6353651e20682e02fb364a78583e97030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:30:28 +0530 Subject: [PATCH 08/22] Update dev.py --- tronx/modules/dev.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tronx/modules/dev.py b/tronx/modules/dev.py index 4be7d266..8394e3bf 100644 --- a/tronx/modules/dev.py +++ b/tronx/modules/dev.py @@ -59,13 +59,13 @@ async def evaluate(client, m: Message): if y in sensitive: return await send_edit(m, warning_message, mono=True, delme=4) - elif chat_type == "bot" and chat_id != app.bot.id:: + elif chat_type == "bot" and chat_id != app.bot.id: for z in text_list: if z in sensitive: return await send_edit(m, warning_message, mono=True, delme=4) try: - cmd = m.text.split(" ", maxsplit=1)[1] + cmd = m.text.split(None, 1)[1] except IndexError: return await app.send_edit(m, "Give me some code to execute . . .", mono=True, delme=3) From 354450f4b2bc35a4de3b66eb0210fb5998d1386b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:33:43 +0530 Subject: [PATCH 09/22] Update dev.py --- tronx/modules/dev.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tronx/modules/dev.py b/tronx/modules/dev.py index 8394e3bf..766cd0b7 100644 --- a/tronx/modules/dev.py +++ b/tronx/modules/dev.py @@ -9,9 +9,8 @@ from pyrogram import filters from pyrogram.types import Message -from tronx import * - -from tronx.helpers import * +from tronx import app +from tronx.helpers import gen, regex @@ -40,7 +39,7 @@ async def evaluate(client, m: Message): global reply, chat_id, chat_type access_list = ("SESSION", "API_ID", "API_HASH", "session_name", "api_id", "api_hash") - sensitive = [ f"app.{x}" for x in dir(self) if x in access_list] + [ f"self.{y}" for y in dir(self) if y in access_list] + [f"Config.{z}" for z in dir(self) if z in access_list] + sensitive = [ f"app.{x}" for x in dir(app) if x in access_list] + [ f"self.{y}" for y in dir(app) if y in access_list] + [f"Config.{z}" for z in dir(app) if z in access_list] warning = "Sorry but by evaluating this code your sensitive data will be exposed in this chat, aborting command !" reply = m.reply_to_message chat_type = m.chat.type From 578e706fd2100c47ac8f45fee8e1c515e92f9536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:36:13 +0530 Subject: [PATCH 10/22] Update dev.py --- tronx/modules/dev.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tronx/modules/dev.py b/tronx/modules/dev.py index 766cd0b7..68a3efbd 100644 --- a/tronx/modules/dev.py +++ b/tronx/modules/dev.py @@ -51,17 +51,17 @@ async def evaluate(client, m: Message): if chat_type in ("supergroup", "group") and chat_id != app.LOG_CHAT: for x in text_list: if x in sensitive: - return await send_edit(m, warning_message, mono=True, delme=4) + return await app.send_edit(m, warning_message, mono=True, delme=4) elif chat_type == "private" and chat_id != app.id: for y in text_list: if y in sensitive: - return await send_edit(m, warning_message, mono=True, delme=4) + return await app.send_edit(m, warning_message, mono=True, delme=4) elif chat_type == "bot" and chat_id != app.bot.id: for z in text_list: if z in sensitive: - return await send_edit(m, warning_message, mono=True, delme=4) + return await app.send_edit(m, warning_message, mono=True, delme=4) try: cmd = m.text.split(None, 1)[1] From 89b40678422cc5a84f7c881badff2042ba1c8b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:40:38 +0530 Subject: [PATCH 11/22] Update dev.py --- tronx/modules/dev.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tronx/modules/dev.py b/tronx/modules/dev.py index 68a3efbd..863974ea 100644 --- a/tronx/modules/dev.py +++ b/tronx/modules/dev.py @@ -36,11 +36,11 @@ async def evaluate(client, m: Message): """ This function is made to execute python codes """ - global reply, chat_id, chat_type + global reply, chat_id, chat_type, p, bot access_list = ("SESSION", "API_ID", "API_HASH", "session_name", "api_id", "api_hash") sensitive = [ f"app.{x}" for x in dir(app) if x in access_list] + [ f"self.{y}" for y in dir(app) if y in access_list] + [f"Config.{z}" for z in dir(app) if z in access_list] - warning = "Sorry but by evaluating this code your sensitive data will be exposed in this chat, aborting command !" + warning_message = "Sorry but by evaluating this code your sensitive data will be exposed in this chat, aborting command !" reply = m.reply_to_message chat_type = m.chat.type chat_id = m.chat.id From 63ad413d001330124c50f70b8e95340750967b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:50:38 +0530 Subject: [PATCH 12/22] Update dev.py --- tronx/modules/dev.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tronx/modules/dev.py b/tronx/modules/dev.py index 863974ea..b90b1048 100644 --- a/tronx/modules/dev.py +++ b/tronx/modules/dev.py @@ -44,23 +44,23 @@ async def evaluate(client, m: Message): reply = m.reply_to_message chat_type = m.chat.type chat_id = m.chat.id - text_list = m.command + text = m.text p = print bot = app.bot if chat_type in ("supergroup", "group") and chat_id != app.LOG_CHAT: - for x in text_list: - if x in sensitive: + for x in sensitive: + if x in text: return await app.send_edit(m, warning_message, mono=True, delme=4) elif chat_type == "private" and chat_id != app.id: - for y in text_list: - if y in sensitive: + for y in sensitive: + if y in text: return await app.send_edit(m, warning_message, mono=True, delme=4) elif chat_type == "bot" and chat_id != app.bot.id: - for z in text_list: - if z in sensitive: + for z in sensitive: + if z in text: return await app.send_edit(m, warning_message, mono=True, delme=4) try: From c490147bc47956e3e80b8e65e9415aa6745d271c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Mon, 7 Feb 2022 20:09:23 +0530 Subject: [PATCH 13/22] Update dev.py improvement --- tronx/modules/dev.py | 63 ++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 46 deletions(-) diff --git a/tronx/modules/dev.py b/tronx/modules/dev.py index b90b1048..14629b59 100644 --- a/tronx/modules/dev.py +++ b/tronx/modules/dev.py @@ -10,7 +10,7 @@ from pyrogram.types import Message from tronx import app -from tronx.helpers import gen, regex +from tronx.helpers import gen @@ -29,6 +29,8 @@ +bot = app.bot +p = print @@ -36,6 +38,9 @@ async def evaluate(client, m: Message): """ This function is made to execute python codes """ + if app.textlen(m) > 4096: + return await send_edit(m, "Your message is too long ! only 4096 characters are allowed", mono=True, delme=4) + global reply, chat_id, chat_type, p, bot access_list = ("SESSION", "API_ID", "API_HASH", "session_name", "api_id", "api_hash") @@ -45,8 +50,6 @@ async def evaluate(client, m: Message): chat_type = m.chat.type chat_id = m.chat.id text = m.text - p = print - bot = app.bot if chat_type in ("supergroup", "group") and chat_id != app.LOG_CHAT: for x in sensitive: @@ -66,12 +69,10 @@ async def evaluate(client, m: Message): try: cmd = m.text.split(None, 1)[1] except IndexError: - return await app.send_edit(m, "Give me some code to execute . . .", mono=True, delme=3) + return await app.send_edit(m, "Give me some text (code) to execute . . .", mono=True, delme=3) await app.send_edit(m, "Running . . .", mono=True) - reply_to_id = reply.message_id if reply else m.message_id - old_stderr = sys.stderr old_stdout = sys.stdout redirected_output = sys.stdout = StringIO() @@ -82,34 +83,16 @@ async def evaluate(client, m: Message): await app.aexec(m, cmd) except Exception: exc = traceback.format_exc() + stdout = redirected_output.getvalue() stderr = redirected_error.getvalue() sys.stdout = old_stdout sys.stderr = old_stderr - evaluation = "" - - if exc: - evaluation = exc - elif stderr: - evaluation = stderr - elif stdout: - evaluation = stdout - else: - evaluation = f"Success" - + evaluation = exc or stderr or stdout or "Success" final_output = f"**• COMMAND:**\n\n`{cmd}`\n\n**• OUTPUT:**\n\n`{evaluation.strip()}`" + if len(final_output) > 4096: - filename = "eval_output.txt" - with open(filename, "w+", encoding="utf8") as out_file: - out_file.write(str(final_output)) - await m.reply_document( - document=filename, - caption=f"`{cmd}`", - disable_notification=True, - reply_to_message_id=reply_to_id, - ) - if os.path.exists(f"./{filename}"): - os.remove(filename) + await app.create_file(m, "eval_output.txt", str(final_output)) await m.delete() else: await app.send_edit(m, final_output) @@ -118,10 +101,13 @@ async def evaluate(client, m: Message): @app.on_message(gen("term", allow_channel=True)) -async def terminal(_, m): +async def terminal(_, m: Message): if app.long(m) == 1: return await app.send_edit(m, "Use: `.term pip3 install colorama`", delme=5) + elif app.textlen(m) > 4096: + return await send_edit(m, "Your message is too long ! only 4096 characters are allowed", mono=True, delme=4) + await app.send_edit(m, "Running . . .", mono=True) args = m.text.split(None, 1) teks = args[1] @@ -135,13 +121,7 @@ async def terminal(_, m): shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) except Exception as e: - print(e) - await app.send_edit(m, - """ - **Error:** - ```{}``` - """.format(e) - ) + await app.error(m, e) output += "**{}**\n".format(code) output += process.stdout.read()[:-1].decode("utf-8") output += "\n" @@ -165,16 +145,7 @@ async def terminal(_, m): output = None if output: if len(output) > 4096: - with open("term_output.txt", "w+") as file: - file.write(output) - await app.send_document( - m.chat.id, - "output.txt", - reply_to_message_id=m.message_id, - caption="`Output file`", - ) - if os.path.exists("./output.txt"): - os.remove("output.txt") + await app.create_file(m, "term_output.txt", output) else: await app.send_edit(m, f"**OUTPUT:**\n\n```{output}```") else: From 13108edda68cc9515421197908f19c69359ee91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Tue, 8 Feb 2022 12:53:44 +0530 Subject: [PATCH 14/22] Update functions.py --- tronx/helpers/functions.py | 45 ++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/tronx/helpers/functions.py b/tronx/helpers/functions.py index 67465b9d..8db0818f 100644 --- a/tronx/helpers/functions.py +++ b/tronx/helpers/functions.py @@ -63,32 +63,43 @@ async def edit_text(self, m: Message, text, disable_web_page_preview=False, pars async def error(self, m: Message, e, edit_error=False): - """Error tracing""" + """ + params: + 1. message (update) :: incoming updates + 2. error :: occured error + 3. edit_error: bool, default=False :: edits | sends error message + + usage: + use this function at the end of try/except block + + ex: (async) + try: + statements . . . + except Exception as e: + await app.error(m, e, edit_error=True) + """ + teks = f"**Traceback Report:**\n\n" - teks += f"**Date:** {self.showdate()}\nTime: {self.showtime()}\n\n" - teks += f"This can be a error in tronuserbot, if you want you can forward this to @tronuserbot.\n\n" - teks += f"**Command:** {m.text}\n\n" - teks += f"**Error:**\n\n" - teks += f"**SHORT:** \n\n{e}\n\n" - teks += f"**FULL:** \n\n{traceback.format_exc()}" + teks += f"**Date:** `{self.showdate()}`\n**Time:** `{self.showtime()}`\n\n" + teks += f"`This can be a error in tronuserbot, if you want you can forward this to @tronuserbot_support.`\n\n" + teks += f"**Command:** `{m.text}`\n\n" + teks += "`-`" * 30 + "\n\n" + teks += f"**SHORT:** \n\n`{e}`\n\n" + teks += f"**FULL:** \n\n`{traceback.format_exc()}`" try: if edit_error: if hasattr(e, "MESSAGE"): - await self.send_edit(m, (e.MESSAGE.replace("(", "")).replace(")", "")) + await self.send_edit(m, f"[ **{e.CODE}** ] : `{e.MESSAGE}`") else: await self.send_edit(m, e.args) - except Exception as err: - print(err) - try: - await self.send_message( - self.LOG_CHAT, - teks - ) + await self.send_message(self.LOG_CHAT, teks) + except PeerIdInvalid: - print(teks) - self.log.error("Please check your logs online.") + self.log.error(teks) + except Exception as err: + self.log.error(err) async def sleep(self, m: Message, sec, delme=False): From 28416c7599b817966a9dda1c50b7e244e7707b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Tue, 8 Feb 2022 16:12:10 +0530 Subject: [PATCH 15/22] Update functions.py --- tronx/helpers/functions.py | 410 +++++++++++++++++++++++++++++++++---- 1 file changed, 372 insertions(+), 38 deletions(-) diff --git a/tronx/helpers/functions.py b/tronx/helpers/functions.py index 8db0818f..071b7d97 100644 --- a/tronx/helpers/functions.py +++ b/tronx/helpers/functions.py @@ -18,7 +18,18 @@ class Functions(object): async def aexec(self, m, code): - """execute python codes""" + """ + params: + 1. message (update) :: incoming update + 2. code: str :: your written python code + + use: + use this function to execute python codes + + ex: (async) + await app.aexec(message, "print('Hello, World !')") + """ + exec( f"async def __aexec(self, m): " + "".join(f"\n {l}" for l in code.split("\n")) @@ -27,7 +38,17 @@ async def aexec(self, m, code): def showdate(self): - """your location's date""" + """ + params: + None + + use: + use this function to get realtime date of your location + + ex: (async) + await app.showdate() + """ + today = pytz.timezone(self.TIME_ZONE) get_date = datetime.datetime.now(today) mydate = get_date.strftime("%d %b %Y") @@ -35,7 +56,17 @@ def showdate(self): def showtime(self): - """your location's time""" + """ + params: + None + + use: + use this function to get time of your location + + ex: (async) + await app.showtime() + """ + today = pytz.timezone(self.TIME_ZONE) get_time = datetime.datetime.now(today) mytime = get_time.strftime("%r") @@ -43,7 +74,19 @@ def showtime(self): async def edit_text(self, m: Message, text, disable_web_page_preview=False, parse_mode="combined"): - """this is a alias function for send_edit function""" + """ + params: + 1. message :: incoming update + 2. text: str :: text to be edited to + 3. disable_web_page_preview: bool, default=False :: shows web page preview if True, Not if it is False + + use: + use this function to edit message, this is also a alias for send_edit function + + ex: (async) + await app.edit_text(m, "This is a text", disable_web_page_preview=True) + """ + try: if m.from_user and m.from_user.is_self: await m.edit( @@ -74,9 +117,9 @@ async def error(self, m: Message, e, edit_error=False): ex: (async) try: - statements . . . + await app.send_message(message.chat.id, "This is a test") except Exception as e: - await app.error(m, e, edit_error=True) + await app.error(message, error, edit_error=True) """ teks = f"**Traceback Report:**\n\n" @@ -103,14 +146,39 @@ async def error(self, m: Message, e, edit_error=False): async def sleep(self, m: Message, sec, delme=False): - """delete a message after some time""" + """ + params: + 1. message (update) :: incoming update + 2. sec :: time to sleep in seconds + 3. delme, default=False :: delete the message if it is True + + use: + this function deletes the message after sleeping for a given time, + this function blocks the code + + ex: (async) + await app.sleep(message, 10, delme=True) + """ + await asyncio.sleep(sec) if delme and m.from_user.is_self: await m.delete() async def delete(self, m: Message, sec: int = 0): - """delete a message after some time using sleep func without blocking the code""" + """ + params: + 1. message (update) :: incoming update + 2. sec: int, default=0 :: time to sleep in seconds + + use: + this function deletes a message after given time period + this function works without blocking the entire execution + + ex: (async) + await app.delete(message, 10) + """ + if sec <= 600: # 10 min asyncio.create_task(self.sleep(m, sec=sec, delme=True)) else: @@ -118,7 +186,17 @@ async def delete(self, m: Message, sec: int = 0): async def data(self, plug): - """create help information page for each module""" + """ + params: + 1. plug: str :: module name whose information is updated in app.CMD_HELP dict + + use: + use this function to get information about a module + + ex: (async) + await app.data("admin") + """ + try: plugin_data = [] plugin_data.clear() @@ -132,7 +210,7 @@ async def data(self, plug): ) return plugin_data except Exception as e: - self.log.info(e) + self.log.error(e) return None @@ -149,7 +227,29 @@ async def send_edit( strike=False, underline=False, ): - """This function edits or exceptionally sends the message""" + """ + params: + 1. message (update) :: incoming update + 2. text: str :: text to be edited or sent instead of editing + 3. disable_web_page_preview: bool, default=False :: web page preview will be shown if True + 4. delme: int, default=0 :: sleeps for given time and then deletes the message + 5. mono: bool, default=False :: all text format will become mono + 6. bold: bool, default=False :: all text format will become bold + 7. italic: bool, default=False :: all text format will become italic + 8. underline: bool, defau=False :: all text format will become underlined + + use: + use this function to get realtime date of your location + + ex: (async) + await app.send_edit( + message, + "This text is sent or edited", + disable_web_page_preview=True, + delme=5, + mono=True + ) + """ formats = [mono, bold, italic, strike, underline] @@ -191,7 +291,17 @@ async def send_edit( async def private(self, m : Message): - """stop user from using in private""" + """ + params: + 1. message (update) :: incoming update + + use: + use this to tell that they can't use some commands in private + + ex: (async) + await app.private(message) + """ + if m.chat.type == "private": await self.send_edit( m, @@ -203,18 +313,54 @@ async def private(self, m : Message): def long(self, m: Message): - """to check args, same as len(message.text.split())""" + """ + params: + 1. message (update) :: incoming update + + use: + this function returns the length of a list containing message splited on spaces + + ex: + if app.long(message) == 1: + print("more arguments needed") + return + """ + text = len(m.command) - return text if bool(text) else none + return text if bool(text) else None def textlen(self, m: Message): - """to check length of characters inside a message""" + """ + params: + 1. message (update) :: incoming update + + use: + this function returns length of characters in message.text + + ex: + if app.textlen(message) > 4096: + print("Text too long") + """ + return len([x for x in m.text or m.caption]) async def create_file(self, m: Message, filename, text): - """create a file with any type of extension""" + """ + params: + 1. message (update) :: incoming update + 2. filename: str :: give a filename with some extension or without extension + 3. text: str :: contents which is going to be written in the file + + use: + use this function to create files with any type of extension (.txt, .py, .java, .html, etc), + this function also sends the created file. + + ex: (async) + await app.create_file(message, "sample.txt", "This file was created with app.create_file() method") + """ + try: name = filename content = text @@ -234,12 +380,34 @@ async def create_file(self, m: Message, filename, text): def rem_dual(self, one, two): - """remove multiples of same element from a list""" + """ + params: + 1. one: list :: list from that you want to remove duplicates + 2. two: list :: list that contains removable elements + + use: + use this function to remove duplicates from lists + + ex: + await app.rem_dual([1, 1, 1, 2, 3], [1]) + """ + return list(set(one) - set(two)) async def kick_user(self, chat_id, user_id): - """kick user from chat""" + """ + params: + 1. chat_id: int :: chat id of the chat where this method is used + 2. user_id: int :: user id of the user you want to kick from chat + + use: + use this function to kick a member from your chat + + ex: (async) + await app.kick_user(chat_id, user_id) + """ + try: await self.kick_chat_member(chat_id, user_id) except Exception as e: @@ -247,32 +415,94 @@ async def kick_user(self, chat_id, user_id): def is_str(self, element): - """true if string else False""" + """ + params: + 1. element: [str, bool, int, float] :: anytype of data + + use: + use this function to check if the element is string or not + + ex: + await app.is_str(data) + """ + return isinstance(element, str) def is_bool(self, element): - """true if boolean else False""" + """ + params: + 1. element: [str, bool, int, float] :: anytype of data + + use: + use this function to check if the element is boolean or not + + ex: + await app.is_bool(data) + """ + return isinstance(element, bool) def is_float(self, element): - """true if float else False""" + """ + params: + 1. element: [str, bool, int, float] :: anytype of data + + use: + use this function to check if the element is float or not + + ex: + await app.is_float(data) + """ + return isinstance(element, float) def is_int(self, element): - """true if int else False""" + """ + params: + 1. element: [str, bool, int, float] :: anytype of data + + use: + use this function to check if the element is integer or not + + ex: + await app.is_int(data) + """ + return isinstance(element, int) - async def get_last_msg(self, m: Message, user_id: int, reverse=False): - """get the first or last message of user/chat""" + async def get_last_msg(self, m: Message, chat_id: int, reverse=False): + """ + params: + 1. message (update) :: incoming update + 2. chat_id: int :: chat id of group or user + 3. reverse: bool, default=False :: if reverse is True you'll get the oldest message in chat + + use: + use this function to get last message of the chat or user + + ex: (async) + await app.get_last_msg(message, chat_id, reverse=True) + """ + return await self.get_history(user_id, limit=1, reverse=reverse) async def toggle_inline(self, m: Message): - """turn on | off inline mode of your bot""" + """ + params: + 1. message (update) :: incoming update + + use: + use this function to turn on | off inline mode of your bot + + ex: (async) + await app.toggle_inline() + """ + try: botname = "BotFather" await self.send_edit(m, "Processing command . . .", mono=True) @@ -327,7 +557,17 @@ async def toggle_inline(self, m: Message): def quote(self): - """anime quotes for weebs""" + """ + params: + None + + use: + use this function to anime quotes + + ex: + await app.quote() + """ + results = requests.get("https://animechan.vercel.app/api/random").json() msg = f"❝ {results.get('quote')} ❞" msg += f" [ {results.get('anime')} ]\n\n" @@ -336,14 +576,34 @@ def quote(self): def ialive_pic(self): - """inline alive pic url""" + """ + params: + None + + use: + use this function to get inline alive pic url + + ex: + await app.ialive_pic() + """ + pic_url = self.getdv("USER_PIC") data = pic_url if pic_url else self.UserPic() return data if data else None def get_file_id(self, message): - """get file id of supported telegram media""" + """ + params: + 1. message (update) :: incoming update + + use: + use this function to get file_id of any media in telegram + + ex: + await app.get_file_id(message) + """ + media = ["photo", "video", "audio", "document", "sticker", "animation"] for x in media: @@ -356,13 +616,34 @@ def get_file_id(self, message): return [messsge.text, None, "text"] - def clear(): - """ clear terminal prompt """ + def clear_screen(self): + """ + params: + None + + use: + use this function to clear terminal screen + + ex: + await app.clear_screen() + """ + subprocess.call("clear" if os.name == "posix" else "cls") - async def add_users(self, user_id: Union[int, List[int]], chat_id: str): - """ add users in groups / channels """ + async def add_users(self, user_id: Union[int, List[int]], chat_id): + """ + params: + 1. user_id: int :: list of telegram id of user + 2. chat_id :: chat id of a group or channel + + use: + use this function to add users in a group / channel + + ex: (async) + await app.add_users(user_id, chat_id) + """ + try: done = await self.add_chat_members(chat_id, user_id) return True if done else False @@ -370,8 +651,19 @@ async def add_users(self, user_id: Union[int, List[int]], chat_id: str): print(e) - async def user_exists(self, user_id: int, chat_id: str): - """check whether a user exists in a group or not""" + async def user_exists(self, user_id: int, chat_id): + """ + params: + 1. user_id: int :: id of a telegram user + 2. chat :: id of telegram chat + + use: + use this function to check whether a user exists in a group or not + + ex: (async) + await app.user_exists(user_id, chat_id) + """ + async for x in self.iter_chat_members(chat_id): if x.user.id == user_id: return True @@ -379,7 +671,17 @@ async def user_exists(self, user_id: int, chat_id: str): async def check_bot_in_log_chat(self): - """check pesence of bot (assistant) in log chat""" + """ + params: + None + + use: + use this function to add your bot if he is not in the log chat + + ex: (async) + await app.check_bot_in_log_chat() + """ + try: if bot: self.log.info("Checking presence of bot in log chat . . .\n") @@ -399,12 +701,34 @@ async def check_bot_in_log_chat(self): def uptime(self): - """ bot active time """ + """ + params: + None + + use: + use this function to get ubot uptime + + ex: + await app.uptime() + """ + return self.GetReadableTime(time.time() - self.StartTime) def import_module(self, path, exclude=[], display_module=True): - """include/exclude modules installation""" + """ + params: + 1. path :: path of module directory + 2. exclude: list, default=[] :: exclude specific module installation + 3. display_module: bool, drfau=True :: whether to print module name after installation or not + + use: + use this function to install python modules + + ex: + await app.import_module("./tronx/modules/", exclude=["admin"]) + """ + bin = [] bin.clear() @@ -435,6 +759,16 @@ def import_module(self, path, exclude=[], display_module=True): def db_status(self): - """database is available or not""" + """ + params: + None + + use: + use this function to check if database is available or not + + ex: + await app.db_status() + """ + "Available" if self.DB_URI else "Unavailable" From 1ee561ec36b93c10b031edb97924e4891ef4650b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Thu, 10 Feb 2022 23:19:04 +0530 Subject: [PATCH 16/22] Update ping.py --- tronx/modules/ping.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tronx/modules/ping.py b/tronx/modules/ping.py index efd04e5e..cc6bbcd3 100644 --- a/tronx/modules/ping.py +++ b/tronx/modules/ping.py @@ -57,7 +57,7 @@ async def pingme(_, m: Message): if app.long(m) == 1: start = datetime.now() - await app.send_edit(m, ". . .", mono=True) + m = await app.send_edit(m, ". . .", mono=True) end = datetime.now() m_s = (end - start).microseconds / 1000 await app.send_edit( @@ -93,7 +93,7 @@ async def pingme(_, m: Message): # function to create lots of pings async def infinite(m: Message): start = datetime.now() - mid = await app.send_edit(m, random.choice(data)) + m = await app.send_edit(m, random.choice(data)) end = datetime.now() ms = (end - start).microseconds / 1000 msg = f"Pöng !\n{ms} ms\n⧑ {app.UserMention()}\n\n" From 1db0e2471c3275de2ff96b57ca5391a9b617a7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Thu, 10 Feb 2022 23:26:47 +0530 Subject: [PATCH 17/22] Update ping.py --- tronx/modules/ping.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tronx/modules/ping.py b/tronx/modules/ping.py index cc6bbcd3..90f4159f 100644 --- a/tronx/modules/ping.py +++ b/tronx/modules/ping.py @@ -78,7 +78,7 @@ async def pingme(_, m: Message): try: num = int(count) + 1 for x in range(1, num): - await infinite(m) + m = await infinite(m) await app.send_edit(m, ". . .", mono=True) time.sleep(0.50) await app.send_edit(m, "".join(pings)) @@ -98,5 +98,6 @@ async def infinite(m: Message): ms = (end - start).microseconds / 1000 msg = f"Pöng !\n{ms} ms\n⧑ {app.UserMention()}\n\n" pings.append(msg) + return m From 4fe6e61976e88efcc91183873ac573e0ce734919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Thu, 10 Feb 2022 23:30:31 +0530 Subject: [PATCH 18/22] Update functions.py --- tronx/helpers/functions.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tronx/helpers/functions.py b/tronx/helpers/functions.py index 071b7d97..7a1ae088 100644 --- a/tronx/helpers/functions.py +++ b/tronx/helpers/functions.py @@ -89,13 +89,13 @@ async def edit_text(self, m: Message, text, disable_web_page_preview=False, pars try: if m.from_user and m.from_user.is_self: - await m.edit( + m = await m.edit( text, parse_mode=parse_mode, disable_web_page_preview=disable_web_page_preview, ) elif m.from_user and not m.from_user.is_self: # for sudo users - await self.send_message( + m = await self.send_message( m.chat.id, text, disable_web_page_preview=disable_web_page_preview, @@ -103,6 +103,7 @@ async def edit_text(self, m: Message, text, disable_web_page_preview=False, pars ) except Exception as e: self.log.info(e) + return m async def error(self, m: Message, e, edit_error=False): @@ -265,7 +266,7 @@ async def send_edit( for x in formats: if x: - await self.edit_text( + m = await self.edit_text( m, format_dict[x], disable_web_page_preview=disable_web_page_preview, @@ -275,7 +276,7 @@ async def send_edit( break if not edited: - await self.edit_text( + m = await self.edit_text( m, text, disable_web_page_preview=disable_web_page_preview, @@ -288,6 +289,7 @@ async def send_edit( except Exception as e: await self.error(m, e) + return m async def private(self, m : Message): From 2bc41defebf058b2bb252c8bd08c61055afa2236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Thu, 10 Feb 2022 23:47:11 +0530 Subject: [PATCH 19/22] Update carbon.py --- tronx/modules/carbon.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tronx/modules/carbon.py b/tronx/modules/carbon.py index 60eec945..89dfba8d 100644 --- a/tronx/modules/carbon.py +++ b/tronx/modules/carbon.py @@ -61,20 +61,19 @@ async def carb_api(_, m: Message): if app.long(m) < 2: return await app.send_edit(m, f"Usage:\n\n`{app.PREFIX}carbon [colour] [text]`\n`{app.PREFIX}carbon [text]`\n\n**Note:** Default colour is aqua", delme=2) - elif app.long(m) <= 4096: + elif app.textlen(m) <= 4096: try: - await app.send_edit(m, "creating carbon . . .", mono=True) + m = await app.send_edit(m, "creating carbon . . .", mono=True) if cmd[1] in colour_code: text = m.text.split(None, 2)[2] colour = cmd[1] - await create_carbon(m, text=text, colour=colour) else: text = m.text.split(None, 1)[1] colour= "aqua" - await create_carbon(m, text=text, colour=colour) + await create_carbon(m, text=text, colour=colour) except Exception as e: await app.error(m, e) - elif app.long(m) > 4096: + elif app.textlen(m) > 4096: await app.send_edit(m, "The text is too long !", delme=2) From 528e642d5a2fdb9bc5986d3a63c8bc9989f01edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Thu, 10 Feb 2022 23:58:10 +0530 Subject: [PATCH 20/22] Update alive.py --- tronx/modules/alive.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tronx/modules/alive.py b/tronx/modules/alive.py index bd73eb88..3666953e 100644 --- a/tronx/modules/alive.py +++ b/tronx/modules/alive.py @@ -27,7 +27,7 @@ @app.on_message(gen("alive")) async def simple_alive(_, m: Message): try: - await app.send_edit(m, ". . .", mono=True) + m = await app.send_edit(m, ". . .", mono=True) alive_msg = f"\n" if app.UserBio(): @@ -56,8 +56,8 @@ async def simple_alive(_, m: Message): parse_mode="markdown" ) elif not pic: - await app.send_message( - m.chat.id, + await app.send_edit( + m, alive_msg, disable_web_page_preview=True, parse_mode="markdown", @@ -70,7 +70,7 @@ async def simple_alive(_, m: Message): @app.on_message(gen("ialive")) async def inline_alive(_, m: Message): - await app.send_edit(m, ". . .", mono=True) + m = await app.send_edit(m, ". . .", mono=True) try: result = await app.get_inline_bot_results(app.bot.username, "#i2l8v3") except BotInlineDisabled: @@ -96,7 +96,7 @@ async def inline_alive(_, m: Message): @app.on_message(gen(["qt"])) async def inline_quote(_, m: Message): try: - await app.send_edit(m,". . .", mono=True) + m = await app.send_edit(m,". . .", mono=True) try: result = await app.get_inline_bot_results(app.bot.username, "#q7o5e") except BotInlineDisabled: From ff8015f9d2482211fceeb13e045c24a7c1e162b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Fri, 11 Feb 2022 23:58:25 +0530 Subject: [PATCH 21/22] Update zombies.py --- tronx/modules/zombies.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tronx/modules/zombies.py b/tronx/modules/zombies.py index b3a019cc..d33aafa4 100644 --- a/tronx/modules/zombies.py +++ b/tronx/modules/zombies.py @@ -35,7 +35,7 @@ async def remove_deleted(_, m: Message): count = 0 if app.long(m) != 2: - await app.send_edit(m, "Checking deleted accounts . . .", mono=True) + m = await app.send_edit(m, "Checking deleted accounts . . .", mono=True) async for x in app.iter_chat_members(chat_id=m.chat.id): if x.user.is_deleted: @@ -47,7 +47,7 @@ async def remove_deleted(_, m: Message): await app.send_edit(m, "No deleted accounts found.\nGroup is clean as Hell ! 😃", delme=3, mono=True) elif app.long(m) == 2 and m.command[1] == "clean": - await app.send_edit(m, "Cleaning deleted accounts . . .", mono=True) + m = await app.send_edit(m, "Cleaning deleted accounts . . .", mono=True) async for x in app.iter_chat_members(chat_id=m.chat.id): if x.user.is_deleted: From 29dd54e2935b3838b32a53b26c840b5dd900962d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BF=87=E2=80=A2=E1=BA=9E=E1=97=B4=E1=97=A9S=D4=B5?= =?UTF-8?q?=E2=80=A2=E0=BF=87?= <80647839+beastzx18@users.noreply.github.com> Date: Sat, 12 Feb 2022 00:12:45 +0530 Subject: [PATCH 22/22] Update functions.py --- tronx/helpers/functions.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tronx/helpers/functions.py b/tronx/helpers/functions.py index 7a1ae088..173befa4 100644 --- a/tronx/helpers/functions.py +++ b/tronx/helpers/functions.py @@ -73,7 +73,14 @@ def showtime(self): return mytime - async def edit_text(self, m: Message, text, disable_web_page_preview=False, parse_mode="combined"): + async def edit_text( + self, + m: Message, + text, + disable_web_page_preview=False, + parse_mode="combined", + reply_markup=None + ): """ params: 1. message :: incoming update @@ -93,13 +100,15 @@ async def edit_text(self, m: Message, text, disable_web_page_preview=False, pars text, parse_mode=parse_mode, disable_web_page_preview=disable_web_page_preview, + reply_markup=reply_markup ) elif m.from_user and not m.from_user.is_self: # for sudo users m = await self.send_message( m.chat.id, text, disable_web_page_preview=disable_web_page_preview, - parse_mode=parse_mode + parse_mode=parse_mode, + reply_markup=reply_markup ) except Exception as e: self.log.info(e)