def admin_cmd(pattern=None, allow_sudo=False, **args): if pattern is not None: args["pattern"] = re.compile(Config.COMMAND_HAND_LER + pattern) if allow_sudo: borgs = list(Config.SUDO_USERS) borgs.append(Uniborg.initiate()) args["from_users"] = borgs else: args["outgoing"] = True args["blacklist_chats"] = True args["chats"] = list(Config.UB_BLACK_LIST_CHAT) return events.NewMessage(**args)
if Config.DB_URI is None: logging.warning("No DB_URI Found!") sys.exit(1) if len(Config.SUDO_USERS) >= 0: Config.SUDO_USERS.add("me") if Config.HU_STRING_SESSION is not None: # for Running on Heroku session_name = str(Config.HU_STRING_SESSION) borg = Uniborg( StringSession(session_name), plugin_path="stdplugins/", api_config=Config, api_id=Config.APP_ID, api_hash=Config.API_HASH ) borg.run_until_disconnected() elif len(sys.argv) == 2: # for running on GNU/Linux session_name = str(sys.argv[1]) borg = Uniborg( session_name, plugin_path="Uniborg/plugins/", connection_retries=None, api_config=Config, api_id=Config.APP_ID, api_hash=Config.API_HASH )
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import logging from sys import argv from uniborg import Uniborg import config logging.basicConfig(level=logging.INFO) try: session_name = argv[1].replace(".session", "") except IndexError: session_name = "stdborg" borg = Uniborg(session_name, plugin_path="stdplugins", connection_retries=None, api_id=config.id, api_hash=config.hash) borg.run_until_disconnected()
"'SUDO_USERS' should have atleast one value" ) sys.exit(1) if Config.HU_STRING_SESSION: # for Running on Heroku session_id = str(Config.HU_STRING_SESSION) container = AlchemySessionContainer( engine=Config.DB_URI ) session = container.new_session(session_id) borg = Uniborg( session, n_plugin_path="stdplugins/", db_plugin_path="dbplugins/", api_config=Config, api_id=Config.APP_ID, api_hash=Config.API_HASH ) borg.run_until_disconnected() elif Config.TG_BOT_TOKEN_BF_HER: # user defined 'TG_BOT_TOKEN_BF_HER' # but did not define, 'HU_STRING_SESSION' logging.info( "[] did not provide / generate " "'HU_STRING_SESSION', trying to work-around" ) temp_borg = TelegramClient( "temp_bot_session", api_id=Config.APP_ID,
from pathlib import Path import sys from uniborg import Uniborg from uniborg.storage import Storage from telethon.sessions import StringSession logging.basicConfig(level=logging.INFO) # the secret configuration specific things ENV = bool(os.environ.get("ENV", False)) if ENV: from sample_config import Config else: if os.path.exists("config.py"): from config import Development as Config else: logging.warning("No config.py Found!") logging.info( "Please run the command, again, after creating config.py similar to README.md" ) sys.exit(1) session_name = str(Config.HU_STRING_SESSION) borg = Uniborg(StringSession(session_name), plugin_path="stdplugins", storage=lambda n: Storage(Path("data") / n), api_config=Config, api_id=Config.APP_ID, api_hash=Config.API_HASH) borg.run_until_disconnected()
from uniborg import Uniborg logging.basicConfig(level=logging.INFO) import os import sys if "APP_ID" not in os.environ and "API_HASH" not in os.environ: print( "Please fill in the required values from app.json " "Do not steal the values from the official application. " "Doing that WILL backfire on you. \nBot quitting.", file=sys.stderr) quit(1) if len(sys.argv) == 2: api_id = int(os.environ.get("APP_ID")) api_hash = os.environ.get("API_HASH") borg = Uniborg(str(sys.argv[1]), plugin_path="stdplugins", connection_retries=None, api_id=api_id, api_hash=api_hash) borg.run_until_disconnected() else: print( "USAGE EXAMPLE:\n" "python3 -m stdborg <SESSION_NAME>" "\n 🙄👆👆Please follow the above format to run your userbot. \nBot quitting.", file=sys.stderr)
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import logging from sys import argv from uniborg import Uniborg import config logging.basicConfig(level=logging.INFO) try: session_name = argv[1].replace(".session", "") except IndexError: session_name = "devbot" borg = Uniborg(session_name, plugin_path="botplugins_dev", admins=config.admins, connection_retries=None, api_id=config.id, api_hash=config.hash) borg.run_until_disconnected()
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import logging from uniborg import Uniborg logging.basicConfig(level=logging.INFO) borg = Uniborg("stdbot", plugin_path="botplugins", admins=[12345], connection_retries=None) borg.run_until_disconnected()
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import logging from uniborg import Uniborg logging.basicConfig(level=logging.INFO) borg = Uniborg("stdborg", plugin_path="stdplugins") borg.run()
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import logging from uniborg import Uniborg logging.basicConfig(level=logging.INFO) borg = Uniborg("stdborg", plugin_path="stdplugins", connection_retries=None) borg.run_until_disconnected()