Skip to content
Merged

Beta #84

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
52 changes: 27 additions & 25 deletions config.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -14,66 +15,67 @@



# 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)
TEMP_DICT = os.getenv("TEMP_DICT", os.path.abspath(".") + "/downloads/")
# 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")
# 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")
Expand All @@ -83,7 +85,7 @@ class Config(object):
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)
# access token of your bot, without this the bot will not work (required)
TOKEN = os.getenv("TOKEN")
# ---------------------
# thumbnail used while uploading plugins, etc. (optional)
Expand Down
Binary file removed material/images/sample.jpg
Binary file not shown.
Binary file removed material/images/white.jpg
Binary file not shown.
9 changes: 4 additions & 5 deletions session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): ")


Expand All @@ -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 !")

4 changes: 2 additions & 2 deletions tronx/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion tronx/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .utilities import Utilities
from .bot import Bot
from .user import User
from .others import Others
from .filters import *


Expand All @@ -16,6 +17,7 @@ class Helpers(
Strings,
Utilities,
Bot,
User
User,
Others
):
pass
2 changes: 1 addition & 1 deletion tronx/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 21 additions & 15 deletions tronx/helpers/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 update.from_user and 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):
Expand Down Expand Up @@ -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,
Expand All @@ -110,8 +113,11 @@ async def func(flt, client: Client, message: Message):
if not text:
return False

# works only for you
if only_me:
# works for you & sudo | only for you
if allow_sudo:
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 message.from_user and not message.from_user.is_self:
return False

Expand Down
27 changes: 15 additions & 12 deletions tronx/helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +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:
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):
Expand Down
12 changes: 12 additions & 0 deletions tronx/helpers/others.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Others(object):
def NoLoad(self):
noloadvar = self.getdv("NO_LOAD")
data_list = 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 sudovar else False
return data_list or self.SUDO_USERS or []

10 changes: 5 additions & 5 deletions tronx/modules/dv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down