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