File size: 2,967 Bytes
618430a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# Ultroid - UserBot
# Copyright (C) 2021-2025 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://github.com/TeamUltroid/pyUltroid/blob/main/LICENSE>.
import os
import sys
import telethonpatch
from .version import __version__
run_as_module = __package__ in sys.argv or sys.argv[0] == "-m"
class ULTConfig:
lang = "en"
thumb = "resources/extras/ultroid.jpg"
if run_as_module:
import time
from .configs import Var
from .startup import *
from .startup._database import UltroidDB
from .startup.BaseClient import UltroidClient
from .startup.connections import validate_session, vc_connection
from .startup.funcs import _version_changes, autobot, enable_inline, update_envs
from .version import ultroid_version
if not os.path.exists("./plugins"):
LOGS.error(
"'plugins' folder not found!\nMake sure that, you are on correct path."
)
exit()
start_time = time.time()
_ult_cache = {}
_ignore_eval = []
udB = UltroidDB()
update_envs()
LOGS.info(f"Connecting to {udB.name}...")
if udB.ping():
LOGS.info(f"Connected to {udB.name} Successfully!")
BOT_MODE = udB.get_key("BOTMODE")
DUAL_MODE = udB.get_key("DUAL_MODE")
USER_MODE = udB.get_key("USER_MODE")
if USER_MODE:
DUAL_MODE = False
if BOT_MODE:
if DUAL_MODE:
udB.del_key("DUAL_MODE")
DUAL_MODE = False
ultroid_bot = None
if not udB.get_key("BOT_TOKEN"):
LOGS.critical(
'"BOT_TOKEN" not Found! Please add it, in order to use "BOTMODE"'
)
sys.exit()
else:
ultroid_bot = UltroidClient(
validate_session(Var.SESSION, LOGS),
udB=udB,
app_version=ultroid_version,
device_model="Ultroid",
)
ultroid_bot.run_in_loop(autobot())
if USER_MODE:
asst = ultroid_bot
else:
asst = UltroidClient("asst", bot_token=udB.get_key("BOT_TOKEN"), udB=udB)
if BOT_MODE:
ultroid_bot = asst
if udB.get_key("OWNER_ID"):
try:
ultroid_bot.me = ultroid_bot.run_in_loop(
ultroid_bot.get_entity(udB.get_key("OWNER_ID"))
)
except Exception as er:
LOGS.exception(er)
elif not asst.me.bot_inline_placeholder and asst._bot:
ultroid_bot.run_in_loop(enable_inline(ultroid_bot, asst.me.username))
vcClient = vc_connection(udB, ultroid_bot)
_version_changes(udB)
HNDLR = udB.get_key("HNDLR") or "."
DUAL_HNDLR = udB.get_key("DUAL_HNDLR") or "/"
SUDO_HNDLR = udB.get_key("SUDO_HNDLR") or HNDLR
else:
print("pyUltroid 2022 © TeamUltroid")
from logging import getLogger
LOGS = getLogger("pyUltroid")
ultroid_bot = asst = udB = vcClient = None
|