{"id":35109573,"url":"https://github.com/umaarov/my-system","last_synced_at":"2026-04-22T11:36:49.950Z","repository":{"id":314809678,"uuid":"1052308631","full_name":"umaarov/my-system","owner":"umaarov","description":"An intelligent Telegram userbot, featuring a persistent memory to learn from conversations, adapt, and respond with a unique, evolving persona.","archived":false,"fork":false,"pushed_at":"2025-09-07T20:31:33.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-21T05:42:37.290Z","etag":null,"topics":["ai","ai-memory","asnycio","automation","chatbot","gemini-api","generative-ai","mysql","nlp","python","telegram-userbot","telethon"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/umaarov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-07T20:31:29.000Z","updated_at":"2025-09-08T05:00:33.000Z","dependencies_parsed_at":"2025-09-15T00:06:18.761Z","dependency_job_id":null,"html_url":"https://github.com/umaarov/my-system","commit_stats":null,"previous_names":["umaarov/my-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/umaarov/my-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umaarov%2Fmy-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umaarov%2Fmy-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umaarov%2Fmy-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umaarov%2Fmy-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umaarov","download_url":"https://codeload.github.com/umaarov/my-system/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umaarov%2Fmy-system/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32134950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T08:34:57.708Z","status":"ssl_error","status_checked_at":"2026-04-22T08:34:55.583Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-memory","asnycio","automation","chatbot","gemini-api","generative-ai","mysql","nlp","python","telegram-userbot","telethon"],"created_at":"2025-12-27T19:23:59.948Z","updated_at":"2026-04-22T11:36:49.944Z","avatar_url":"https://github.com/umaarov.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## My System\n\nAn intelligent, self-learning Telegram userbot powered by Google's Gemini AI and a persistent MySQL database for long-term memory.\n\n---\n\n### About The Project\n\nMy System is not just a standard userbot; it's a digital extension of the user. It actively listens to conversations it's part of, learns facts about the user, and understands their opinions on various topics. By leveraging a powerful AI model and a structured database, it builds a long-term memory, allowing it to reply to mentions with context, personality, and knowledge that grows over time.\n\nThe core philosophy is to create an AI assistant that is indistinguishable from a real person, with an adaptive, witty, and intelligent persona.\n\n---\n\n### Key Features\n\n* **🧠 AI with Persistent Memory**: Learns new facts and opinions from conversations and stores them in a MySQL database, ensuring knowledge is never lost.\n* **💬 Context-Aware Replies**: Responds intelligently when mentioned by using both short-term (recent chat history) and long-term (facts and opinions) memory.\n* **🎭 Adaptive Persona**: Dynamically adjusts its response tone based on the context of the query—behaving as a helpful assistant for factual questions, a witty companion for casual chats, and a sharp defender against insults.\n* **📜 Advanced Chat Summarization**: Quickly get the gist of any conversation with the powerful `.summarize` command, which can analyze recent messages, unread messages, or messages from a specific user.\n* **🔒 Secure \u0026 Private**: Operates as a user account (userbot), giving you full control over its actions and ensuring your data and conversations remain private.\n\n---\n\n### Technology Stack\n\n* **Core**: Python 3.9+\n* **Telegram API**: Telethon\n* **AI Model**: Google Gemini\n* **Database**: MySQL (via aiomysql)\n* **Configuration**: python-dotenv\n\n---\n\n### Setup and Installation\n\nFollow these steps to get your instance of My System up and running.\n\n#### **Prerequisites**\n\n* Python 3.9 or higher.\n* A running MySQL-compatible database (e.g., local MySQL, PlanetScale, Aiven).\n* Your Telegram **API_ID** and **API_HASH**. Get them from [my.telegram.org](https://my.telegram.org).\n* A **Google API Key** for Gemini. Get one from [Google AI Studio](https://aistudio.google.com/app/apikey).\n\n#### **Installation Steps**\n\n1.  **Clone the repository:**\n    ```sh\n    git clone https://github.com/umaarov/my-system.git\n    cd my-system\n    ```\n\n2.  **Install the required packages:**\n    ```sh\n    pip install -r requirements.txt\n    ```\n\n3.  **Configure your environment variables:**\n    Create a file named `.env` in the project root and populate it with your credentials. You can use the example below as a template.\n    ```env\n    # .env file\n\n    # --- Telegram Credentials ---\n    API_ID=1234567\n    API_HASH=your_api_hash_here\n\n    # --- Google Gemini AI ---\n    GOOGLE_API_KEY=your_google_api_key_here\n\n    # --- Database Connection ---\n    DB_HOST=your_database_host\n    DB_PORT=3306\n    DB_USER=your_database_username\n    DB_PASS=your_database_password\n    DB_NAME=your_database_name\n    ```\n\n4.  **Set up your user identity:**\n    Open `config.py` and change the `MY_USERNAME` and `MY_ALIASES` to match your own Telegram username and real names/nicknames. This is crucial for the bot to know when a message is about you.\n\n    ```python\n    # config.py\n    MY_USERNAME = \"your_telegram_username\"\n    MY_ALIASES = [\"your_first_name\", \"your_last_name\", \"your_nickname\"]\n    ```\n\n5.  **Initialize the database:**\n    Run the setup script once to create all the necessary tables in your database.\n    ```sh\n    python setup_database.py\n    ```\n    You should see a success message indicating the tables are ready.\n\n---\n\n### Usage\n\nTo start the userbot, simply run the main script:\n\n```sh\npython userbot.py\n```\nThe first time you run it, Telethon will ask you to log in with your phone number, password, and 2FA code in the console. After a successful login, a `userbot.session` file will be created, and subsequent runs will be automatic.\n\n#### **Commands**\n\n* **Summarize Chat**: Use the `.summarize` command in any chat.\n    * `.summarize 50`: Summarizes the last 50 messages.\n    * `.summarize @username`: Summarizes the last 50 messages from a specific user.\n    * `.summarize unread`: Summarizes all unread messages in the chat.\n\n---\n\n### Database Schema\n\nThe bot's \"memory\" is structured across four main tables:\n\n* **`entities`**: Stores unique nouns identified in conversations (e.g., people, places, topics).\n* **`facts`**: Stores specific attributes about entities, particularly the user (e.g., `(entity: dribbblxr, attribute: location, value: Uzbekistan)`).\n* **`user_opinions`**: Stores the user's sentiment (positive, negative, neutral) towards different entities.\n* **`conversation_history`**: Acts as the short-term memory, storing recent messages from chats for contextual replies.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumaarov%2Fmy-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumaarov%2Fmy-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumaarov%2Fmy-system/lists"}