From 462096008bd516479ef745b840c7befdc1bb0881 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, 5 Feb 2022 14:47:21 +0530 Subject: [PATCH 01/19] Update config.py --- config.py | 56 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/config.py b/config.py index 401224da..2a9a10ed 100644 --- a/config.py +++ b/config.py @@ -1,11 +1,12 @@ import os +import pkg_resources -#todo +# todo if os.uname()[1] == "localhost": - response = os.system("pip3 install -r requirements.txt") + response = os.system("pip3 install -r requirements.txt --no-cache-dir") if response == 0: print("Successfully Installed all requirements") else: @@ -14,16 +15,17 @@ -# if you deploy this bot by localhost method, then replace all the necessary part of variables given below after '=' sign with your desired values. +# if you deployed this userbot using localhost method, then replace all the necessary parts of the variables given below after '=' sign with the required values. # for example edit like 'API_ID = 1234567' instead of 'API_ID = os.getenv("API_ID")' -# Note: don't touch anything else given below except the values you wanna change otherwise you'll face errors. +# Warning: don't touch anything else given below except the values you wanna change otherwise you'll get errors. #------------------------------------------------------------------------------------------------------------- class Config(object): + """ configuration class """ # api id of your telegram account (required) - API_ID = os.getenv("API_ID") + API_ID = int(os.getenv("API_ID")) # api hash of your telegram account (required) API_HASH = os.getenv("API_HASH") - # Create a session from session.py (required) + # create a session using command [ python3 session.py ] or use repl.it (required) SESSION = os.getenv("SESSION") # ------------------ # temporary download location (required) @@ -31,49 +33,49 @@ class Config(object): # official repo for updates UPSTREAM_REPO = os.getenv("UPSTREAM_REPO", "https://github.com/beastzx18/Tron.git") # ------------------ - # heroku api key (required if hosted on heroku) + # heroku api key (required -> if hosted on heroku) HEROKU_API_KEY = os.getenv("HEROKU_API_KEY") - # heroku app name (required if hosted on heroku) + # heroku app name (required -> if hosted on heroku) HEROKU_APP_NAME = os.getenv("HEROKU_APP_NAME") # database url (required) DB_URI = os.getenv("DATABASE_URL") # ------------------ - # these users can use your bot / userbot - SUDO_USERS = os.getenv("SUDO_USERS") + # these users can use your userbot + SUDO_USERS = [int(x) for x in os.getenv("SUDO_USERS").split()] # splits on spaces # a group to store logs, etc (required) - LOG_CHAT = os.getenv("LOG_CHAT") - # command handler, if you give ! (exclamation) then you can do like this !ping => pong ! + LOG_CHAT = int(os.getenv("LOG_CHAT")) + # command handler, if you give (exclamation symbol = !) then you can do like this command: !ping => result: pong ! PREFIX = os.getenv("PREFIX", ".") - # for more info visit docs.pyrogram.org, workers section (required) - WORKERS = os.getenv("WORKERS", 8) - # exclude official plugins from installing - NO_LOAD = os.getenv("NO_LOAD") + # for more info visit docs.pyrogram.org, workers section + WORKERS = int(os.getenv("WORKERS", 8)) + # exclude official plugins from installing, give a space between plugin names + NO_LOAD = [int(x) for x in os.getenv("NO_LOAD").split()] # splits on spaces # default reason for afk plugin AFK_TEXT = os.getenv("AFK_TEXT", "I am busy Now !") # ------------------ # add True to enable (default: False) PMPERMIT = os.getenv("PMPERMIT", False) - # pmpermit pic - PMPERMIT_PIC = os.getenv("PMPERMIT_PIC", False) + # pmpermit pic (optional) + PMPERMIT_PIC = os.getenv("PMPERMIT_PIC") # custom pmpermit security text (optional) PMPERMIT_TEXT = os.getenv("PMPERMIT_TEXT", "Hey ! This is [Tron Userbot](https://t.me/tronuserbot) Security System.\n**You will be blocked if you spammed my owner's pm**\nCurrently My Owner is busy! So Wait Until He Arrives. šŸ‘šŸ»\nAnd Better Not To Spam His here!") - # pmpermit warn limit - PM_LIMIT = os.getenv("PM_LIMIT", 4) - # this is used in time plugin + # pmpermit warn limit (optional) + PM_LIMIT = int(os.getenv("PM_LIMIT", 4)) + # this is used to get your accurate time TIME_ZONE = os.getenv("TIME_ZONE", "Asia/Kolkata") # ------------------- # your custom name (default: telegram name) USER_NAME = os.getenv("USER_NAME") - # your custom bio (default: None) + # your custom bio (default: telegram bio) USER_BIO = os.getenv("USER_BIO") - # used for alive plugin (default: official tronuserbot logo image) + # used for alive plugin (default: tronuserbot logo image) USER_PIC = os.getenv("USER_PIC", "https://telegra.ph/file/1073e200f9d8e70b91f0d.jpg") # add your telegram id if bot fails to get your id - USER_ID = os.getenv("USER_ID") + USER_ID = int(os.getenv("USER_ID")) # add your username if bot fails to get your username USER_USERNAME = os.getenv("USER_USERNAME") # -------------------- - # this bio will be shown in /help menu (default: official bio from bot) + # this bio will be shown in '/help' menu (default: official bio from bot) BOT_BIO = os.getenv("BOT_BIO") # your assistants custom name (default: NORA) BOT_NAME = os.getenv("BOT_NAME", "NORA") @@ -82,8 +84,8 @@ class Config(object): # provide this if bot fails to get username of bot (optional) BOT_USERNAME = os.getenv("BOT_USERNAME") # telegram id of bot if failed to get automatically (optional) - BOT_ID = os.getenv("BOT_ID") - # without this the bot will not work (required) + BOT_ID = int(os.getenv("BOT_ID")) + # access token of your bot, without this the bot will not work (required) TOKEN = os.getenv("TOKEN") # --------------------- # thumbnail used while uploading plugins, etc. (optional) From 99c56b02304c7ef839085aea28bda0dfc830d936 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, 5 Feb 2022 14:48:21 +0530 Subject: [PATCH 02/19] Delete white.jpg --- material/images/white.jpg | Bin 1759 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 material/images/white.jpg diff --git a/material/images/white.jpg b/material/images/white.jpg deleted file mode 100644 index a13ee4994084b556416a8a9e90f7dbdd57f57311..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1759 zcmeHFO=}cE5UrjOUBttV#Iw>z*~8B4YIJfC30Y7G2znD~Iy1ey&CYf&-96@G33$?z zBDs6?KX_BYqd&lpi~fh4av7^Pn>B+0ksM7y_f)-k^{TqNsxQ^g;N#ks>;tT?!*u{? zzy-1b0eVeb8w4Q4FCqJWJM`fI{dmS{;6L+1!a2{u^@?1cb1)*wjI)IJ4ld|)y34n_ z%iT^pz7e-$cpx)-*EmSpNu0KCrb&D)Nz%@(wA;a|ufs+5yS?Y$Cl*CM?==?Hyy%J9 zQ`&ce$uS?`o?Dtee$t{wjO7-~x#P!Up`6)f6D^gaDb0qwD1;gaOIy_H(qw`;KA0=a zftliTcR|3IIm5FNO+BiO97u&?r5Y){sZhyj#|xGlzR8>%3!1iT7|)#43X33I@NHo% zE3L?9@rEhwP#gm$L+!L>JkRHhLvfKyrwv<3`A(eH#Zl&zW=2nFnjkJMvrc9sVQAXt zg%vI8(?!m#RCwZoTX)1@mOsUYohgx(Y2~<7w)bf5VNGBc;Qa5g310qvY=So@k4o^? zKkC1XO7#Pp_j~txem-#sajU+=Dn_R>FLF8s%&tB_)PMuB9})^dM8b$vpWw=@Re#Qf tT|{`PiM`j&qyAWR^Jw%Z`VB6H1gnG*+=2Jc>N#i8*$w Date: Sat, 5 Feb 2022 14:48:40 +0530 Subject: [PATCH 03/19] Delete sample.jpg --- material/images/sample.jpg | Bin 1015 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 material/images/sample.jpg diff --git a/material/images/sample.jpg b/material/images/sample.jpg deleted file mode 100644 index 535bb2a020f78bcbe697d6c39646c69244662666..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1015 zcmbtT&x_MQ6n>M47V*%^dUlzk^pK>jtMMSRY(Zf`(3{9Gn@roG=}eiKy1SMIPkK^h z?;iahys6;PKfoUs{Y&DT*o_S?i0p%z%=_|v-+Mz|$}i>5;N#AL90Ba^!ZiSB!3A;) z0z9>G?GbaK{~jBRbPj-`rYw!eu7llw`VQH6Iy)c9k?BmG8u9U7RSFG&6cm(*$v8nRPOo3PaNoFRbWNFBdtp zQsIpYZrurkS^fkYc4mRBOe@Ewvcrcv4;ltX0O$XVP4M#HV-vhNeN=+C{-gfSsFXjT zeQ$Vo=;sp$6}R#`Y-4t|@Fr(-Ky~>6IxYNnl8{gcIwb6n@)KOCTJ`s=<08TvZS1`n g9`)C1hDSSpqu=0CNU%!Sf!px@SyNMISIe)z09x?I`v3p{ From 954934674025c789fa52070bd525df7b157e37c1 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, 5 Feb 2022 14:56:15 +0530 Subject: [PATCH 04/19] Update session.py --- session.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/session.py b/session.py index b468d068..1754be94 100644 --- a/session.py +++ b/session.py @@ -26,9 +26,8 @@ API_ID = input("\nEnter your API_ID: ") - -while not API_ID.isdigit() and (len(API_ID) < 7 or len(API_ID) > 7): - print("\n\nPlease enter a digit.\n\n") +while not (API_ID.isdigit() and len(API_ID) == 7): + print("\n\nPlease enter a 7 digit API_ID.\n\n") API_ID = input("Enter your API_ID (1234567): ") @@ -39,7 +38,7 @@ # create a new pyrogram session -with Client(":memory:", api_id=int(API_ID), api_hash=API_HASH, hide_password=True) as app: +with Client(":memory:", api_id=int(API_ID), api_hash=API_HASH) as app: app.send_message("me", f"This Is Your Tron Userbot • [ `SESSION` ]\n\n```{app.export_session_string()}```\n\nāš ļøā€¢ Don't share this with anyone !!\n\nCreate Again • [ Press Here](https://replit.com/@beastzx18/Tron-Userbot-Session)", disable_web_page_preview=True,) - print("Your String Session Is Successfully Saved In Telegram Saved Messages !! Don't Share It With Anyone!! Anyone having your session can use your telegram account !") + print("Your String Session Is Successfully Saved In Telegram Saved (Cloud) Messages !! Don't Share It With Anyone!! Anyone having your session can use (hack) your telegram account !") From 18f2b2afa832670710372231625b73f23f532f86 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, 5 Feb 2022 21:46:54 +0530 Subject: [PATCH 05/19] Update config.py --- config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index 2a9a10ed..7a0afed0 100644 --- a/config.py +++ b/config.py @@ -41,7 +41,7 @@ class Config(object): DB_URI = os.getenv("DATABASE_URL") # ------------------ # these users can use your userbot - SUDO_USERS = [int(x) for x in os.getenv("SUDO_USERS").split()] # splits on spaces + SUDO_USERS = [int(x) for x in os.getenv("SUDO_USERS", "").split() if ] # splits on spaces # a group to store logs, etc (required) LOG_CHAT = int(os.getenv("LOG_CHAT")) # command handler, if you give (exclamation symbol = !) then you can do like this command: !ping => result: pong ! @@ -49,7 +49,7 @@ class Config(object): # for more info visit docs.pyrogram.org, workers section WORKERS = int(os.getenv("WORKERS", 8)) # exclude official plugins from installing, give a space between plugin names - NO_LOAD = [int(x) for x in os.getenv("NO_LOAD").split()] # splits on spaces + NO_LOAD = [int(x) for x in os.getenv("NO_LOAD", "").split()] # splits on spaces # default reason for afk plugin AFK_TEXT = os.getenv("AFK_TEXT", "I am busy Now !") # ------------------ From 4110faeed7ca0ff6f202634f91d69494ec6ef51f 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, 5 Feb 2022 21:51:45 +0530 Subject: [PATCH 06/19] Update config.py --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index 7a0afed0..72a00510 100644 --- a/config.py +++ b/config.py @@ -41,7 +41,7 @@ class Config(object): DB_URI = os.getenv("DATABASE_URL") # ------------------ # these users can use your userbot - SUDO_USERS = [int(x) for x in os.getenv("SUDO_USERS", "").split() if ] # splits on spaces + SUDO_USERS = [int(x) for x in os.getenv("SUDO_USERS", "").split()] # splits on spaces # a group to store logs, etc (required) LOG_CHAT = int(os.getenv("LOG_CHAT")) # command handler, if you give (exclamation symbol = !) then you can do like this command: !ping => result: pong ! From ab60377944eb0eb31282dc63e5e84e396f43d128 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, 5 Feb 2022 21:58:28 +0530 Subject: [PATCH 07/19] Update config.py --- config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index 72a00510..e321d012 100644 --- a/config.py +++ b/config.py @@ -71,7 +71,7 @@ class Config(object): # used for alive plugin (default: tronuserbot logo image) USER_PIC = os.getenv("USER_PIC", "https://telegra.ph/file/1073e200f9d8e70b91f0d.jpg") # add your telegram id if bot fails to get your id - USER_ID = int(os.getenv("USER_ID")) + USER_ID = os.getenv("USER_ID") # add your username if bot fails to get your username USER_USERNAME = os.getenv("USER_USERNAME") # -------------------- @@ -84,7 +84,7 @@ class Config(object): # provide this if bot fails to get username of bot (optional) BOT_USERNAME = os.getenv("BOT_USERNAME") # telegram id of bot if failed to get automatically (optional) - BOT_ID = int(os.getenv("BOT_ID")) + BOT_ID = os.getenv("BOT_ID") # access token of your bot, without this the bot will not work (required) TOKEN = os.getenv("TOKEN") # --------------------- From 82e5e2ad73cd203e06e8f94ea44e8581f7d457aa 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, 5 Feb 2022 22:27:59 +0530 Subject: [PATCH 08/19] Create others.py --- tronx/helpers/others.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tronx/helpers/others.py diff --git a/tronx/helpers/others.py b/tronx/helpers/others.py new file mode 100644 index 00000000..2ac2ebe9 --- /dev/null +++ b/tronx/helpers/others.py @@ -0,0 +1,12 @@ +class Others(object): + def NoLoad(self): + noloadvar = self.getdv("NO_LOAD") + data_list = [int(x) for x in noloadvar.split()] if self.is_int((x for x in noloadvar.split())) else False + return data_list or self.NO_LOAD or [] + + + def SudoUsers(self): + sudovar = self.getdv("SUDO_USERS") + data_list = [int(x) for x in sudovar.split()] if self.is_int((x for x in sudovar.split())) else False + return data_list or self.SUDO_USERS or [] + From caa855275b283ff7a803c0d574acaa8701b38d19 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, 5 Feb 2022 22:28:43 +0530 Subject: [PATCH 09/19] Update __init__.py --- tronx/helpers/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tronx/helpers/__init__.py b/tronx/helpers/__init__.py index b8d9bee7..e06d4ff0 100644 --- a/tronx/helpers/__init__.py +++ b/tronx/helpers/__init__.py @@ -5,6 +5,7 @@ from .utilities import Utilities from .bot import Bot from .user import User +from .others import Others from .filters import * @@ -16,6 +17,7 @@ class Helpers( Strings, Utilities, Bot, - User + User, + Others ): pass From 3a2c9336a52129964cf890bed20a416bfe75748e 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, 5 Feb 2022 22:38:46 +0530 Subject: [PATCH 10/19] Update others.py --- tronx/helpers/others.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tronx/helpers/others.py b/tronx/helpers/others.py index 2ac2ebe9..12585f2e 100644 --- a/tronx/helpers/others.py +++ b/tronx/helpers/others.py @@ -1,12 +1,12 @@ class Others(object): def NoLoad(self): noloadvar = self.getdv("NO_LOAD") - data_list = [int(x) for x in noloadvar.split()] if self.is_int((x for x in noloadvar.split())) else False + data_list = [int(x) for x in noloadvar.split()] if noloadvar else False return data_list or self.NO_LOAD or [] def SudoUsers(self): sudovar = self.getdv("SUDO_USERS") - data_list = [int(x) for x in sudovar.split()] if self.is_int((x for x in sudovar.split())) else False + data_list = [int(x) for x in sudovar.split()] if sudovar else False return data_list or self.SUDO_USERS or [] From 5ea13b3e3650a92115f0c75d14ee7ed3bd1e9bdf 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, 5 Feb 2022 22:44:51 +0530 Subject: [PATCH 11/19] Update __main__.py --- tronx/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tronx/__main__.py b/tronx/__main__.py index 0e9cf334..f97ea292 100644 --- a/tronx/__main__.py +++ b/tronx/__main__.py @@ -41,10 +41,10 @@ async def start_bot(): """ __main__ startup """ print("___________________________________. Welcome to Tron corporation .___________________________________\n\n\n") print("PLUGINS: Installing . . .\n\n") - _plugs = app.import_module("tronx/plugins/") + _plugs = app.import_module("tronx/plugins/", exclude=app.NoLoad()) print(f"\n\n{_plugs} plugins Loaded\n\n") print("MODULES: Installing . . .\n\n") - _mods = app.import_module("tronx/modules/") + _mods = app.import_module("tronx/modules/", exclude=app.NoLoad())) print(f"\n\n{_mods} modules Loaded") await start_assistant() await start_userbot() From ba0acf599ef64d2d2be6e0fa79dfaabcbfd33579 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, 5 Feb 2022 22:47:28 +0530 Subject: [PATCH 12/19] Update __main__.py --- tronx/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tronx/__main__.py b/tronx/__main__.py index f97ea292..5214056b 100644 --- a/tronx/__main__.py +++ b/tronx/__main__.py @@ -44,7 +44,7 @@ async def start_bot(): _plugs = app.import_module("tronx/plugins/", exclude=app.NoLoad()) print(f"\n\n{_plugs} plugins Loaded\n\n") print("MODULES: Installing . . .\n\n") - _mods = app.import_module("tronx/modules/", exclude=app.NoLoad())) + _mods = app.import_module("tronx/modules/", exclude=app.NoLoad()) print(f"\n\n{_mods} modules Loaded") await start_assistant() await start_userbot() From eaaab1434c857d40603114962e8509d61c295c71 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, 5 Feb 2022 22:52:37 +0530 Subject: [PATCH 13/19] Update others.py --- tronx/helpers/others.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tronx/helpers/others.py b/tronx/helpers/others.py index 12585f2e..d42f660e 100644 --- a/tronx/helpers/others.py +++ b/tronx/helpers/others.py @@ -1,7 +1,7 @@ class Others(object): def NoLoad(self): noloadvar = self.getdv("NO_LOAD") - data_list = [int(x) for x in noloadvar.split()] if noloadvar else False + data_list = noloadvar.split() if noloadvar else False return data_list or self.NO_LOAD or [] From 06cb9efc7358f11dc1719ee2ef02d42d2edb7bcd 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, 5 Feb 2022 23:29:03 +0530 Subject: [PATCH 14/19] Update filters.py trying to add sudo functionality --- tronx/helpers/filters.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/tronx/helpers/filters.py b/tronx/helpers/filters.py index fd125a51..981b016b 100644 --- a/tronx/helpers/filters.py +++ b/tronx/helpers/filters.py @@ -28,29 +28,32 @@ def regex( pattern: Union[str, Pattern], flags: int = 0, - only_me: bool = True, + allow_sudo: bool = True, allow_forward: bool = False, allow_channel: bool = False, allow_edit: bool = True ): - async def func(flt, _, update: Update): - if only_me: - if not (update.from_user - and update.from_user.is_self - ): + async def func(flt, client: Client, update: Update): + + # works for you & sudo | only for you + if allow_sudo: + if not (update.from_user.is_self or update.from_user.id in client.SudoUsers()): + return False + elif not allow_sudo: + if not update.from_user.is_self: return False - if allow_forward is False: - if update.forward_date: + if not allow_forward: + if update.forward_date: return False - if allow_channel is False: - if update.chat.type == "channel": + if not allow_channel: + if update.chat.type == "channel": return False - if allow_edit is False: - if update.edit_date: + if not allow_edit: + if update.edit_date: return False if isinstance(update, Message): @@ -88,7 +91,7 @@ def gen( commands: Union[str, List[str]], prefixes: Union[str, List[str]] = myprefix(), case_sensitive: bool = True, - only_me: bool = True, + allow_sudo: bool = True, allow_forward: bool = False, allow_channel: bool = False, allow_edit: bool = True, @@ -110,9 +113,12 @@ async def func(flt, client: Client, message: Message): if not text: return False - # works only for you - if only_me: - if message.from_user and not message.from_user.is_self: + # works for you & sudo | only for you + if allow_sudo: + if not (message.from_user.is_self or message.from_user.id in client.SudoUsers()): + return False + elif not allow_sudo: + if not message.from_user.is_self: return False if allow_forward is False: From d8d7256589b1535fb956570d62288e14f95cac8f 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, 5 Feb 2022 23:38:25 +0530 Subject: [PATCH 15/19] Update filters.py --- tronx/helpers/filters.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tronx/helpers/filters.py b/tronx/helpers/filters.py index 981b016b..67003408 100644 --- a/tronx/helpers/filters.py +++ b/tronx/helpers/filters.py @@ -38,10 +38,10 @@ async def func(flt, client: Client, update: Update): # works for you & sudo | only for you if allow_sudo: - if not (update.from_user.is_self or update.from_user.id in client.SudoUsers()): + if update.from_user and not (update.from_user.is_self or update.from_user.id in client.SudoUsers()): return False elif not allow_sudo: - if not update.from_user.is_self: + if update.from_user and not update.from_user.is_self: return False if not allow_forward: @@ -115,10 +115,10 @@ async def func(flt, client: Client, message: Message): # works for you & sudo | only for you if allow_sudo: - if not (message.from_user.is_self or message.from_user.id in client.SudoUsers()): + if message.from_user and not (message.from_user.is_self or message.from_user.id in client.SudoUsers()): return False elif not allow_sudo: - if not message.from_user.is_self: + if message.from_user and not message.from_user.is_self: return False if allow_forward is False: From dbebc5f7856145822e4ed134deae53d7c556629d 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, 5 Feb 2022 23:50:11 +0530 Subject: [PATCH 16/19] Update functions.py --- tronx/helpers/functions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tronx/helpers/functions.py b/tronx/helpers/functions.py index 6964f3f3..61d9b4d7 100644 --- a/tronx/helpers/functions.py +++ b/tronx/helpers/functions.py @@ -50,7 +50,8 @@ async def edit_text(self, m: Message, text, disable_web_page_preview=False, pars parse_mode=parse_mode, disable_web_page_preview=disable_web_page_preview, ) - except MessageIdInvalid: + except (MessageIdInvalid or MessageAuthorRequired): + await m.delete() await self.send_message( m.chat.id, text, From f4a8778a3989442419ed56d65b84208db4f2ca66 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 00:06:51 +0530 Subject: [PATCH 17/19] Update functions.py --- tronx/helpers/functions.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tronx/helpers/functions.py b/tronx/helpers/functions.py index 61d9b4d7..5631f43b 100644 --- a/tronx/helpers/functions.py +++ b/tronx/helpers/functions.py @@ -45,19 +45,21 @@ 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""" try: - await m.edit( - text, - parse_mode=parse_mode, - disable_web_page_preview=disable_web_page_preview, - ) - except (MessageIdInvalid or MessageAuthorRequired): - await m.delete() - await self.send_message( - m.chat.id, - text, - disable_web_page_preview=disable_web_page_preview, - parse_mode=parse_mode - ) + if m.from_user and m.from_user.is_self: + 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.chat.id, + text, + disable_web_page_preview=disable_web_page_preview, + parse_mode=parse_mode + ) + except Exception as e: + self.log.info(e) async def error(self, m: Message, e, edit_error=False): From d1ad7aca791de74b0bece8f7f0ea6152d293f8a8 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 00:30:03 +0530 Subject: [PATCH 18/19] Update dv.py --- tronx/modules/dv.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tronx/modules/dv.py b/tronx/modules/dv.py index 42270608..ff7f964a 100644 --- a/tronx/modules/dv.py +++ b/tronx/modules/dv.py @@ -27,7 +27,7 @@ -@app.on_message(gen("setdv")) +@app.on_message(gen("setdv", allow_sudo=False)) async def set_dv_var(_, m: Message): if app.long(m) == 2: await app.send_edit(m, "Please give me key with a value . . . ", mono=True, delme=2) @@ -49,7 +49,7 @@ async def set_dv_var(_, m: Message): -@app.on_message(gen("deldv")) +@app.on_message(gen("deldv", allow_sudo=False)) async def del_dv_var(_, m: Message): if app.long(m) == 1: await app.send_edit(m, "Give me some key to delete that a var from database . . . ", mono=True, delme=2) @@ -66,7 +66,7 @@ async def del_dv_var(_, m: Message): -@app.on_message(gen("getdv")) +@app.on_message(gen("getdv", allow_sudo=False)) async def get_dv_var(_, m: Message): if app.long(m) == 1: await app.send_edit(m, "Give me some key to get value that a var from database . . . ", mono=True, delme=2) @@ -86,7 +86,7 @@ async def get_dv_var(_, m: Message): -@app.on_message(gen("pm")) +@app.on_message(gen("pm", allow_sudo=False)) async def get_database_var(_, m: Message): arg = m.command if app.long(m) < 2: @@ -114,7 +114,7 @@ async def get_database_var(_, m: Message): -@app.on_message(gen("alldv")) +@app.on_message(gen("alldv", allow_sudo=False)) async def get_all_dv(_, m: Message): if bool(app.getalldv()) is True: await app.send_edit(m, "Getting all database vars . . .", mono=True) From bf3ec5a44c658b491dbc92e833ea041611e600ae 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 00:41:29 +0530 Subject: [PATCH 19/19] Update decorators.py --- tronx/helpers/decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tronx/helpers/decorators.py b/tronx/helpers/decorators.py index a91972cc..5abe724b 100644 --- a/tronx/helpers/decorators.py +++ b/tronx/helpers/decorators.py @@ -8,7 +8,7 @@ class Decorators(object): def alert_user(self, func): async def wrapper(_, cb: CallbackQuery): - if cb.from_user and not cb.from_user.id == self.id: + if cb.from_user and not (cb.from_user.id == self.id or cb.from_user.id in self.SudoUsers()): await cb.answer( f"Sorry, but you can't use this userbot ! make your own userbot at @tronuserbot", show_alert=True