help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
news-summary-bot
RSK World
news-summary-bot
News Summary Bot - Python + Flask + OpenAI + NewsAPI + AI Summarization + Real-time News + News Aggregation
news-summary-bot
  • __pycache__
  • static
  • templates
  • .env459 B
  • .gitignore761 B
  • GITHUB_RELEASE_SUMMARY.md3.7 KB
  • INSTALLATION.md2.7 KB
  • PROJECT_SUMMARY.md9.5 KB
  • README.md11.4 KB
  • RELEASE_NOTES_v1.0.0.md6.7 KB
  • admin.py7.6 KB
  • analytics.py11 KB
  • app.py14.1 KB
  • auth.py15 KB
  • cache.py11.1 KB
  • export.py14.2 KB
  • news_bot.py4.7 KB
  • requirements.txt286 B
  • search.py16.8 KB
  • security.py14.4 KB
LICENSEnews_bot.pyCHANGELOG.mdRELEASE_NOTES_v1.0.0.mdGITHUB_RELEASE_SUMMARY.md
news_bot.py
Raw Download
Find: Go to:
"""
News Bot Logic - Fetching and Summarizing News Articles
Developer: Molla Samser
Design & Testing: Rima Khatun
Company: RSK World
Year: 2026
Website: https://rskworld.in
"""

import os
import requests
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()

class NewsBot:
    def __init__(self):
        self.news_api_key = os.getenv("NEWS_API_KEY")
        self.openai_api_key = os.getenv("OPENAI_API_KEY")
        self.client = OpenAI(api_key=self.openai_api_key) if self.openai_api_key else None

    def fetch_news(self, category="general", query=None):
        """Fetches news from NewsAPI."""
        if not self.news_api_key:
            return {"error": "News API Key not configured. Please add it to your .env file."}
        
        url = "https://newsapi.org/v2/top-headlines"
        params = {
            "apiKey": self.news_api_key,
            "country": "us",
            "category": category,
            "pageSize": 10
        }
        if query:
            url = "https://newsapi.org/v2/everything"
            params = {"apiKey": self.news_api_key, "q": query, "pageSize": 10}

        try:
            response = requests.get(url, params=params)
            response.raise_for_status()
            return response.json()
        except Exception as e:
            return {"error": str(e)}

    def summarize_article(self, content, language="English"):
        """Summarizes an article using OpenAI API with language support."""
        if not self.client:
            return "OpenAI API Key not configured. Cannot generate summary."

        try:
            prompt = f"Summarize the following news article briefly and concisely in {language}. Provide only the summary."
            response = self.client.chat.completions.create(
                model="gpt-3.5-turbo",
                messages=[
                    {"role": "system", "content": "You are a helpful news assistant."},
                    {"role": "user", "content": f"{prompt}\n\nArticle: {content}"}
                ],
                max_tokens=250
            )
            return response.choices[0].message.content.strip()
        except Exception as e:
            return f"Error during summarization: {str(e)}"

    def analyze_sentiment(self, content):
        """Analyzes the sentiment of an article snippet."""
        if not self.client:
            # Fallback simple logic if no OpenAI client
            content_lower = content.lower()
            positive_words = ['great', 'good', 'success', 'breakthrough', 'positive', 'win', 'improve']
            negative_words = ['fail', 'crisis', 'bad', 'death', 'crash', 'negative', 'loss', 'decline']
            
            p_count = sum(1 for w in positive_words if w in content_lower)
            n_count = sum(1 for w in negative_words if w in content_lower)
            
            if p_count > n_count: return "Positive"
            if n_count > p_count: return "Negative"
            return "Neutral"

        try:
            response = self.client.chat.completions.create(
                model="gpt-3.5-turbo",
                messages=[
                    {"role": "system", "content": "Analyze the sentiment of the following news headline/snippet. Respond with exactly one word: Positive, Negative, or Neutral."},
                    {"role": "user", "content": content}
                ],
                max_tokens=10
            )
            sentiment = response.choices[0].message.content.strip().replace('.', '')
            return sentiment if sentiment in ["Positive", "Negative", "Neutral"] else "Neutral"
        except:
            return "Neutral"

    def analyze_reliability(self, content):
        """Analyzes the reliability and objectivity of a news snippet."""
        if not self.client:
            return 75  # Default dummy score

        try:
            response = self.client.chat.completions.create(
                model="gpt-3.5-turbo",
                messages=[
                    {"role": "system", "content": "Analyze the reliability and objectivity of the following news headline/snippet. Respond with exactly one number between 0 and 100, where 100 is highly reliable and objective."},
                    {"role": "user", "content": content}
                ],
                max_tokens=5
            )
            score_str = response.choices[0].message.content.strip()
            # Extract number
            import re
            match = re.search(r'\d+', score_str)
            return int(match.group()) if match else 75
        except:
            return 75

# Developer Details in comment
# Created by Molla Samser (RSK World)
# 2026
119 lines•4.7 KB
python
RELEASE_NOTES_v1.0.0.md
Raw Download

RELEASE_NOTES_v1.0.0.md

# News Summary Bot v1.0.0 - Initial Release

## 🎉 First Official Release

We're excited to announce the first official release of the News Summary Bot - a comprehensive AI-powered news aggregation and summarization platform.

**Release Date:** January 2026
**Developer:** Molla Samser
**Design & Testing:** Rima Khatun
**Company:** RSK World
**Website:** https://rskworld.in

---

## ✨ Key Features

### Core Functionality
- ✅ **Real-time News Fetching** - Fetches top headlines from multiple sources using NewsAPI
- ✅ **AI Article Summarization** - Generates high-quality summaries using OpenAI GPT-3.5 Turbo
- ✅ **Multi-language Support** - Summarize news in English, Hindi, Spanish, French, German
- ✅ **Voice Search** - Search news using voice commands (Web Speech API)
- ✅ **Category Filtering** - Browse news in Business, Tech, Health, Science, Sports, etc.
- ✅ **Sentiment Analysis** - Analyze the sentiment of news articles with advanced NLP
- ✅ **Reliability Scoring** - Check the reliability and objectivity of news sources
- ✅ **Mobile Responsive** - Modern glassmorphism design that works on all devices

### Advanced Features
- ✅ **User Authentication System** - Complete user registration, login, and session management
- ✅ **Personalization** - User preferences, reading history, and personalized recommendations
- ✅ **Advanced Search** - Full-text search with filters, sorting, and suggestions
- ✅ **Caching System** - Intelligent caching for improved performance and reduced API costs
- ✅ **Analytics Dashboard** - Comprehensive admin panel with real-time analytics
- ✅ **Data Export** - Export data in JSON, CSV, XML formats with backup capabilities
- ✅ **Rate Limiting** - Advanced API rate limiting and security features
- ✅ **Admin Panel** - Complete admin interface for monitoring and management
- ✅ **Bookmarks/Favorites** - Save and manage favorite articles
- ✅ **PDF Export** - Export summaries as PDF documents

### Security Features
- ✅ **Input Validation** - Comprehensive input sanitization and validation
- ✅ **Rate Limiting** - Configurable rate limiting with exponential backoff
- ✅ **CSRF Protection** - Cross-site request forgery protection
- ✅ **Security Headers** - Complete security header implementation
- ✅ **API Key Authentication** - Secure API key validation
- ✅ **Session Management** - Secure session handling with expiration

---

## 📦 What's Included

### Backend Components
- `app.py` - Main Flask application (335+ lines)
- `news_bot.py` - Core news fetching and processing
- `analytics.py` - Advanced analytics and NLP processing (374 lines)
- `cache.py` - Intelligent caching system (374 lines)
- `auth.py` - User authentication and preferences (513 lines)
- `search.py` - Advanced search functionality (570 lines)
- `export.py` - Data export and reporting (484 lines)
- `security.py` - Security and rate limiting (487 lines)
- `admin.py` - Admin panel routes (262 lines)

### Frontend Components
- Modern glassmorphism UI design
- Responsive templates for all pages
- Interactive JavaScript with voice search
- Chart.js integration for analytics
- jsPDF integration for PDF export

### Documentation
- Comprehensive README.md
- Detailed INSTALLATION.md
- Complete PROJECT_SUMMARY.md
- Code comments and documentation

---

## 🚀 Getting Started

### Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- Valid API keys (NewsAPI and OpenAI)

### Quick Start
```bash
# Clone the repository
git clone https://github.com/rskworld/news-summary-bot.git
cd news-summary-bot

# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Mac/Linux

# Install dependencies
pip install -r requirements.txt

# Configure environment variables
# Create .env file with your API keys

# Run the application
python app.py
```

### Access Points
- **Main Page:** http://localhost:5000
- **Demo Interface:** http://localhost:5000/demo
- **Admin Panel:** http://localhost:5000/admin

---

## 📊 Project Statistics

- **Total Files:** 26
- **Python Modules:** 8
- **HTML Templates:** 10
- **Lines of Code:** ~7,630+
- **Features Implemented:** 25+

---

## 🛠 Technologies Used

### Backend
- Python Flask
- OpenAI API (GPT-3.5 Turbo)
- NewsAPI.org
- SQLite (with full-text search)
- Custom caching system

### Frontend
- HTML5, CSS3, JavaScript
- Glassmorphism design
- Chart.js for analytics
- Font Awesome 6.0
- jsPDF for document export

---

## 🔒 Security

This release includes comprehensive security features:
- Secure password hashing with salt
- Session management with expiration
- CSRF token protection
- API key validation
- Rate limiting with exponential backoff
- Input validation and sanitization
- Security headers implementation

---

## 📤 Data Export

Supported export formats:
- **JSON** - Complete data structure
- **CSV** - Tabular data for spreadsheets
- **XML** - Structured data format
- **ZIP** - Multiple formats in one package

Export types:
- User data export (GDPR compliant)
- Analytics data export
- News articles export
- Full system backup

---

## 🐛 Known Issues

None at this time. This is a stable release.

---

## 📝 Changelog

### v1.0.0 (January 2026)
- Initial release
- All core features implemented
- Complete documentation
- Security features implemented
- Admin panel functional
- Export functionality working
- Voice search integrated
- PDF export working
- Bookmarks system implemented

---

## 🤝 Contributing

Contributions are welcome! Please ensure all code follows the project standards and includes proper documentation.

---

## 📄 License

© 2026 RSK World. All rights reserved.

---

## 📞 Support & Contact

For technical support and inquiries:
- **Email:** info@rskworld.com, support@rskworld.in
- **Phone:** +91 93305 39277
- **Website:** https://rskworld.in
- **Address:** Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147

---

## 🙏 Acknowledgments

This project is part of the RSK World AI Chatbots collection. Visit https://rskworld.in for more projects and resources.

### Technologies Used
- [OpenAI](https://openai.com/) - AI-powered summarization
- [NewsAPI](https://newsapi.org/) - Real-time news data
- [Flask](https://flask.palletsprojects.com/) - Web framework
- [Chart.js](https://www.chartjs.org/) - Data visualization
- [Font Awesome](https://fontawesome.com/) - Icon library

---

**Thank you for using News Summary Bot!**

Developed by Molla Samser | Design & Testing by Rima Khatun
RSK World | https://rskworld.in
GITHUB_RELEASE_SUMMARY.md
Raw Download

GITHUB_RELEASE_SUMMARY.md

# GitHub Release Summary

## ✅ Successfully Pushed to GitHub

**Repository:** https://github.com/rskworld/news-summary-bot.git
**Branch:** main
**Tag:** v1.0.0
**Status:** ✅ Complete

---

## 📦 What Was Pushed

### Files Committed (26 files, 7,630+ lines)
- ✅ All Python modules (8 files)
- ✅ All HTML templates (10 files)
- ✅ CSS and JavaScript files
- ✅ Documentation files (README, INSTALLATION, PROJECT_SUMMARY)
- ✅ Configuration files (.gitignore, requirements.txt)
- ✅ Release notes

### Repository Structure
```
news-summary-bot/
├── .gitignore
├── README.md
├── INSTALLATION.md
├── PROJECT_SUMMARY.md
├── RELEASE_NOTES_v1.0.0.md
├── requirements.txt
├── app.py
├── news_bot.py
├── analytics.py
├── cache.py
├── auth.py
├── search.py
├── export.py
├── security.py
├── admin.py
├── static/
│ ├── css/
│ │ └── style.css
│ └── js/
│ └── script.js
└── templates/
├── index.html
├── demo.html
├── login.html
├── register.html
└── admin/
├── dashboard.html
├── analytics.html
├── users.html
├── content.html
├── settings.html
└── login.html
```

---

## 🏷️ Tag Information

**Tag Name:** v1.0.0
**Tag Message:** "v1.0.0 - Initial Release: Complete AI-powered news aggregation and summarization platform with all advanced features"
**Status:** ✅ Pushed to GitHub

---

## 📝 Next Steps for GitHub Release

To create a GitHub Release with the release notes:

### Option 1: Via GitHub Web Interface
1. Go to: https://github.com/rskworld/news-summary-bot/releases
2. Click "Draft a new release"
3. Select tag: `v1.0.0`
4. Title: `v1.0.0 - Initial Release`
5. Copy content from `RELEASE_NOTES_v1.0.0.md` into the description
6. Click "Publish release"

### Option 2: Via GitHub CLI (if installed)
```bash
gh release create v1.0.0 \
--title "v1.0.0 - Initial Release" \
--notes-file RELEASE_NOTES_v1.0.0.md
```

---

## 🔗 Repository Links

- **Repository:** https://github.com/rskworld/news-summary-bot
- **Releases:** https://github.com/rskworld/news-summary-bot/releases
- **Tags:** https://github.com/rskworld/news-summary-bot/tags
- **Code:** https://github.com/rskworld/news-summary-bot/tree/main

---

## ✅ Verification Checklist

- ✅ Git repository initialized
- ✅ All files committed
- ✅ Remote repository added
- ✅ Code pushed to main branch
- ✅ Tag v1.0.0 created
- ✅ Tag pushed to GitHub
- ✅ Release notes created
- ✅ .gitignore configured
- ✅ Git user configured

---

## 📊 Commit Information

**Commit Hash:** 6dcebe6
**Commit Message:** "Initial commit: News Summary Bot - Complete AI-powered news aggregation and summarization platform"
**Files Changed:** 26 files
**Insertions:** 7,630+ lines

---

## 🎯 Release Highlights

This v1.0.0 release includes:

- ✅ Complete AI-powered news aggregation system
- ✅ 25+ advanced features implemented
- ✅ Full user authentication and personalization
- ✅ Advanced search with filters
- ✅ Comprehensive analytics dashboard
- ✅ Data export in multiple formats
- ✅ Security features and rate limiting
- ✅ Voice search and PDF export
- ✅ Bookmarks/favorites system
- ✅ Admin panel with full management capabilities

---

**Status:** ✅ All files successfully pushed to GitHub
**Date:** January 2026
**Developer:** Molla Samser
**Company:** RSK World
**Website:** https://rskworld.in
🚀 Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ❤️

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer