π€ Intelligent bot for analyzing negative posts in Telegram channels
Telegram News Analyzer is a powerful tool for monitoring and analyzing sentiment in Telegram channels. The bot uses modern machine learning technologies to detect negative posts based on the analysis of user comments.
- π Sentiment analysis β automatic detection of negative posts using AI
- π Multi-channel monitoring β simultaneous analysis of multiple channels
- π Flexible time ranges β analysis for today, yesterday, last week, last month, or a custom period
- π― Configurable thresholds β ability to adjust the sensitivity of the analysis
- Python 3.8+ β main programming language
- Telethon β interaction with the Telegram API
- Transformers β machine learning models for sentiment analysis
- PyTorch β deep learning framework
- spaCy & NLTK β natural language processing
- pandas & scikit-learn β data analysis
- python-telegram-bot β Telegram bot framework
git clone https://github.com/your-username/Telegram-news-analyzer.git
cd Telegram-news-analyzerpython -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windowspip install -r requirements.txtCopy the env_template file to .env and fill in the required parameters:
cp env_template .envEdit the .env file:
# Telegram API Configuration
TELEGRAM_API_ID=your_api_id_here
TELEGRAM_API_HASH=your_api_hash_here
TELEGRAM_PHONE=+1234567890
# Telegram Bot Token
BOT_TOKEN=your_bot_token_here
# Channels to analyze
CHANNELS_LIST=@yourchannel,@anotherchannel,@thirdchannel
# Analysis settings
NEGATIVE_COMMENT_THRESHOLD=0.3
OUTPUT_DIR=output
MAX_MESSAGES=200- Go to my.telegram.org
- Log in to your account
- Create a new application
- Copy the
API IDandAPI Hash
- Find @BotFather in Telegram
- Send the
/newbotcommand - Follow the instructions to create a bot
- Copy the generated token
python main.py/startβ start and main menu/helpβ usage help/analyzeβ start post analysis
- π Analyze β select a period and start analysis
- π Select channels β configure the list of channels to monitor
- βΉοΈ Help β detailed information about the features
- π Today β analyze posts for the current day
- π Yesterday β analyze posts for the previous day
- π Last 7 days β weekly analysis
- π Last 30 days β monthly analysis
- π§ Custom period β arbitrary time range
- Interactive web page with detailed statistics
- Data visualizations and charts
- Convenient navigation through results
- Structured data for further processing
- Complete information about posts and comments
- Metrics and statistics
- 0.3 (30%) β moderate sensitivity
- 0.5 (50%) β high sensitivity
- 0.2 (20%) β very high sensitivity
- Recommended: 100β500 messages
- For large channels: 1000+ messages
Telegram-news-analyzer/
βββ main.py # Entry point
βββ telegram_bot.py # Telegram bot logic
βββ telegram_client.py # Client for working with Telegram API
βββ sentiment_analyzer.py # Sentiment analysis
βββ report_generator.py # Report generation
βββ config.py # Configuration
βββ logging_config.py # Logging configuration
βββ requirements.txt # Dependencies
βββ env_template # Configuration template
βββ output/ # Reports folder
Edit the CHANNELS_LIST variable in the .env file:
CHANNELS_LIST=@channel1,@channel2,@channel3You can change the machine learning model in sentiment_analyzer.py:
model_name = "cardiffnlp/twitter-xlm-roberta-base-sentiment"Edit report_generator.py to change the format and style of the reports.
-
Telegram authorization error
- Check that
API_IDandAPI_HASHare correct - Make sure the phone number is in international format
- Check that
-
The bot does not respond
- Check that
BOT_TOKENis correct - Make sure the bot is running and not blocked
- Check that
-
Sentiment analysis errors
- Check your internet connection
- Make sure all dependencies are installed
Logs are saved to logs/news_analyzer.log for debugging.
We welcome contributions to the project! Please:
- Fork the repository
- Create a branch for your feature
- Make your changes
- Open a Pull Request
If you have any questions or issues:
- Open an Issue
Created with β€οΈ for analyzing Telegram content