SpottedMood is an asynchronous, automated data-ingestion and Natural Language Processing (NLP) Telegram Bot, designed to extract, analyze, and report sentiment and emotions, within SpottedDMI community. It provides daily analytics (Sentiment, Hate Speech, Emotion, Stereotype, Topic) to help community managers and users monitor group health and user interactions.
The entire pipeline, including the continuous asynchronous polling and the execution of NLP models, is highly optimized for constrained environments. The system currently runs seamlessly in production on a Raspberry Pi 4 (2GB RAM), demonstrating efficient memory management and preventing Out-Of-Memory exceptions during data processing.
The project is engineered following the Separation of Concerns (SoC) principle, ensuring maintainability and scalability:
- Data Ingestion (
msg_extractor.py): Dedicated exclusively to asynchronous message extraction via the Telethon library. - NLP Pipeline (
sentiment.py & topic.py): Handles the core analysis, currently utilizingpysentimientoto evaluate text independently of its source andgemini-2.5-flash-liteto get most discussed topics through the day. - Reporting System (
reporter.py): Formats the analyzed data and handles outbound communications. - Orchestration (
main.py): Acts as the central scheduler usingAPScheduler, coordinating background listening, daily analysis jobs, and user interface commands viapython-telegram-bot.
To ensure security, all sensitive credentials are managed via environment variables.
- Clone the repository.
- Install dependencies via
Pipfile. - Get
GeminiandBotFatherAPI tokens. - Create a
.envfile in the root directory with the following variables:API_ID=your_telegram_api_id API_HASH=your_telegram_api_hash TOKEN_BOT_API=your_bot_token PHONE_NUMBER=your_phone_number GEMINI_API_KEY=your_gemini_api_key
- Execute telethon_auth.py
- Execute main.py
To interact with SpottedMood, simply start a chat with the bot and use the following commands:
- /start – Introduces the bot's features and subscribes you to the daily reports (sent at 10 PM) regarding mood, emotions, and content analysis.
- /highlights – Opens an interactive menu to view the most intense messages and graphical plots, generated using
matplotlib, for specific emotions (Joy, Sadness, Anger, Fear) and general statistics. - /stop – Unsubscribes you from the daily automated reports.
- /help – Displays the available commands and admin contact information for support.
| Emotion Plot | General Statistics |
|---|---|
![]() |
![]() |
This project is licensed under the GNU General Public License v3.0 (GPLv3). See the LICENSE file for more details.

