### Interactive Pre-installation Setup Source: https://context7.com/debotcommunity/debot/llms.txt Describes the interactive `preinstall` function that prompts users for Telegram API credentials on the first run and saves them encoded in the .env file. ```python from userbot.src.preinstall import preinstall # Called automatically if API_ID is not set # Displays ASCII art "SETUP" banner, then prompts: # -> [setup] - Введите API ID: # -> [setup] - Введите API HASH: # Creates .env file with encoded credentials: # API_ID= # API_HASH= # Returns tuple: (api_id, api_hash) api_id, api_hash = preinstall() ``` -------------------------------- ### Starting the Userbot with Command-Line Arguments Source: https://context7.com/debotcommunity/debot/llms.txt Demonstrates how to launch the DeBot userbot from the command line, including options for custom session names, proxy configurations (SOCKS5, HTTP), and authentication. ```bash # Basic startup with default session name "account" python3 -m userbot # Start with custom session file path python3 -m userbot -s "my_session" # Start with SOCKS5 proxy (type, ip, port, username, password) python3 -m userbot -p "socks5" "127.0.0.1" "1080" "user" "pass" # Combined: custom session with HTTP proxy python3 -m userbot -s "my_session" -p "http" "192.168.1.1" "8080" "0" "0" # Note: Use "0" for username/password if proxy has no authentication ``` -------------------------------- ### Automatic Module Discovery and Import Source: https://context7.com/debotcommunity/debot/llms.txt Explains how DeBot automatically discovers and imports all Python modules located in the userbot/modules directory when the userbot starts. ```python from userbot.modules import ALL_MODULES ``` -------------------------------- ### Displaying Available Commands with .help Source: https://context7.com/debotcommunity/debot/llms.txt Illustrates how to use the .help command in DeBot to view all registered commands, organized by category such as chat, fun, and tools. ```bash # In Telegram chat: # .help # Output shows registered commands: # ❓ ᴋ᧐ʍᴀнды: # ➖ 𝐂𝐡𝐚𝐭 # ➖ 𝐅𝐮𝐧 # ➖ 𝐓𝐨𝐨𝐥𝐬 # .about -> о юзᴇᴩбоᴛᴇ # .addmod -> добᴀʙиᴛь ʍодуᴧь (ᴩᴇᴨᴧᴀᴇʍ нᴀ ɸᴀйᴧ) # .delmod -> удᴀᴧиᴛь ʍодуᴧь ``` -------------------------------- ### Dynamic Module Loading with .addmod Command Source: https://context7.com/debotcommunity/debot/llms.txt Explains how to dynamically load a Python module into DeBot by replying to a .py file in Telegram. The module's commands are automatically discovered and registered. ```python # In Telegram chat: # 1. Send a .py module file to any chat # 2. Reply to that file with: .addmod # Example module structure (mymodule.py): from telethon import events from userbot import client info = { "category": "fun", "pattern": ".hello|.hi", "description": "Says hello|Says hi" } @client.on(events.NewMessage(outgoing=True, pattern=r"^\.hello$")) async def hello_handler(event): await event.edit("Hello, World!") @client.on(events.NewMessage(outgoing=True, pattern=r"^\.hi$")) async def hi_handler(event): await event.edit("Hi there!") ``` -------------------------------- ### Encoding and Decoding Credentials with CryptoUtils Source: https://context7.com/debotcommunity/debot/llms.txt Shows how the CryptoUtils class in DeBot uses base64 encoding and decoding for API credentials stored in the .env file, ensuring secure storage. ```python from userbot.src.encrypt import CryptoUtils # Encode credentials for storage api_id = "12345678" encoded_id = CryptoUtils.encrypt(api_id) # Result: "MTIzNDU2Nzg=" # Decode credentials on load decoded_id = CryptoUtils.decrypt(encoded_id) # Result: "12345678" # Used automatically by preinstall() to save credentials: # .env file contents: # API_ID=MTIzNDU2Nzg= # API_HASH=YWJjZGVmMTIzNDU2... ``` -------------------------------- ### Module Uninstallation with .delmod Command Source: https://context7.com/debotcommunity/debot/llms.txt Details the process of removing a DeBot module using the .delmod command, which includes deleting the module file, cleaning up event handlers, and removing it from sys.modules. ```bash # In Telegram chat, delete a module by name: # .delmod mymodule # The command will: # 1. Delete the file from userbot/modules/ # 2. Remove all registered event handlers for that module # 3. Clean up sys.modules entries # Console output: "-> [.delmod] - Модуль mymodule успешно удален" ``` -------------------------------- ### TelegramClient Extension for HTML and Session Protection Source: https://context7.com/debotcommunity/debot/llms.txt Shows how the extended TelegramClient in DeBot defaults to HTML parse mode for messages and includes protection against unauthorized session string extraction. ```python from userbot import client # The client is pre-configured and ready to use # HTML is the default parse mode for all messages # Send a message with HTML formatting await client.send_message( "me", "Bold and italic text" ) # The client includes session grab protection # Any attempt to call client.save() raises RuntimeError: # "Save string session try detected and stopped. Check external libraries." ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.