https://github.com/madebyadem/nieuwsbot
This repository contains the source code for a project that includes functionality for scheduling news feeds, fetching the latest news, and sending them to a Telegram bot.
https://github.com/madebyadem/nieuwsbot
bash linux python telegram
Last synced: about 2 months ago
JSON representation
This repository contains the source code for a project that includes functionality for scheduling news feeds, fetching the latest news, and sending them to a Telegram bot.
- Host: GitHub
- URL: https://github.com/madebyadem/nieuwsbot
- Owner: MadeByAdem
- License: mit
- Created: 2024-07-18T08:33:47.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-18T16:00:30.000Z (almost 2 years ago)
- Last Synced: 2025-01-21T21:47:16.230Z (over 1 year ago)
- Topics: bash, linux, python, telegram
- Language: Python
- Homepage: https://madebyadem.dev
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dutch Telegram News Bot
This repository contains the source code for a project that includes functionality for scheduling news feeds, fetching the latest news, and sending them to a Telegram bot.
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Linux Service Setup](#linux-service-setup)
- [Modules](#modules)
- [License](#license)
## Installation
To install the required dependencies, run:
```bash
pip install -r requirements.txt
```
## Configuration
Make sure to configure the environment variables needed for your project. You can use the `.env.example` file as a template. Copy it to .env and update the values accordingly.
```bash
cp .env.example .env
```
### Prerequisites
- Python 3.x
- `pip` package manager
- A Telegram bot token. You can get one by creating a bot through the [BotFather](https://core.telegram.org/bots#botfather).
- Encryption key. [Check documentation how to get one](https://cryptography.io/en/latest/fernet/).
## Environment Variables
`BOT_TOKEN`: Your Telegram bot API key.
`SECRET_KEY`: Encryption key.
## Usage
You can start the application by running the appropriate Python scripts. Here is an example of how to run the main components:
For the regular bot polling:
```bash
python telegram_utils.py
```
For the scheduled tasks:
```bash
python schedule_utils.py
```
## Linux Service Setup
To set up the project as a service on a Linux system, you need to create two service files: `nieuwsbot.service` and `nieuwsbot-schedule.service`.
### nieuwsbot.service
Create a file named `nieuwsbot.service` with the following content:
```ini
[Unit]
Description=NieuwsBot
[Service]
ExecStart=/your/path/to/nieuwsbot/venv/bin/python /your/path/to/nieuwsbot/telegram_utils.py
WorkingDirectory=/your/path/to/nieuwsbot
Restart=always
User=root
[Install]
WantedBy=default.target
```
### nieuwsbot-schedule.service
Create a file named `nieuwsbot-schedule.service` with the following content and adjust the path to the python file:
```ini
[Unit]
Description=NieuwsBot Schedule
[Service]
ExecStart=/your/path/to/nieuwsbot/venv/bin/python /your/path/to/nieuwsbot/schedule_utils.py
WorkingDirectory=/your/path/to/nieuwsbot
Restart=always
User=root
[Install]
WantedBy=default.target
```
### Enabling the Services
1. Copy the `nieuwsbot.service` and `nieuwsbot-schedule.service` files to the `/etc/systemd/system` directory.
```bash
sudo cp nieuwsbot.service /etc/systemd/system/
sudo cp nieuwsbot-schedule.service /etc/systemd/system/
```
2. Reload the systemd daemon.
```bash
sudo systemctl daemon-reload
```
3. Enable and start the services.
```bash
sudo systemctl enable nieuwsbot.service
sudo systemctl start nieuwsbot.service
sudo systemctl enable nieuwsbot-schedule.service
sudo systemctl start nieuwsbot-schedule.service
```
## Modules
### latest_news.py
This module fetches the latest news using a specified news API.
### schedule_utils.py
This module contains utilities for scheduling tasks using the schedule library.
### telegram_utils.py
This module provides utilities for interacting with Telegram using the telebot library.
### Requirements
The project requires the following Python packages:
- feedparser
- telebot
- schedule
- latest_news
- Fernet
- ratelimit
- cryptography
## License
This project is licensed under the Custom License. See the [LICENSE](LICENSE) file for more details.