Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zenwarr/telegram-feed-bot
Posts rss feeds or top reddit posts to telegram channels
https://github.com/zenwarr/telegram-feed-bot
rss telegram telegram-bot telegram-rss telegram-rss-bot
Last synced: about 1 month ago
JSON representation
Posts rss feeds or top reddit posts to telegram channels
- Host: GitHub
- URL: https://github.com/zenwarr/telegram-feed-bot
- Owner: zenwarr
- License: mit
- Created: 2022-02-19T06:07:32.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-16T18:15:39.000Z (about 1 year ago)
- Last Synced: 2024-08-04T09:06:43.171Z (5 months ago)
- Topics: rss, telegram, telegram-bot, telegram-rss, telegram-rss-bot
- Language: Python
- Homepage:
- Size: 105 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
This bot posts rss feeds to telegram channels.
It can also collect top posts from a subreddit and post them to a telegram channel hourly.It can save original post formatting (to the extent supported by Telegram).
![License](https://img.shields.io/badge/license-MIT-green?style=for-the-badge)
## Feed configuration
Configuration is stored in `data/config.yaml` file.
Example configuration:```yaml
feeds:
- url: https://xkcd.com/rss.xml # RSS feed url# Handle of a telegram channel to post to.
# You can reuse same channel for multiple feeds.
channel: "@xkcd"# Optional, `generic` by default
# Filter to convert a feed entry to a telegram message
filter: xkcd# Optional, none by default
# Regexp to not post messages not matching it.
# Matching is done against an already generated telegram message, not source html provided in a feed entry.
should_match: "^xkcd"# Optional, none by default
# Regexp to not post messages matching it. It can be an array of patterns.
# Matching is done against an already generated telegram message, not source html provided in a feed entry.
should_not_match: "^xkcd"
# Optional, none by default
# Prefix is added to the message title and can be useful if you post multiple feeds to the same telegram channel
# Title with a prefix looks like this: `[XKCD] Original entry title`
title_prefix: "XKCD"
# Optional, true by default
# If set to false, disables link previews for telegram messages
link_preview: true
# Optional, true by default
# If set to true, text in the title is going to be a clickable link to an original post.
# Setting this to true automatically disables footer.
title_link: true
# Optional, false by default
# If true, telegram messages will have footer with clickable link to an original post
footer: true
# Optional, none by default
# If set, links to original posts for this feed are going to be replaced with links to
# t.me/iv?url=original_link&rhash=instant_view_rhash, so you can use your own instant view templates
instant_view_rhash: "some_rhash"reddit:
- name: funny # Name of a subreddit
channel: "@funny" # Handle of a telegram channel to post to. You can reuse same channel for multiple subreddits.
```Filters are functions that convert incoming rss feed entry to telegram message.
`generic` filter is used by default.
It tries its best to extract content from a feed entry and convert it to simple markdown Telegram understands.There are two types of filters: built-in and custom.
Built-in filters are located in `src/builtin_filters` directory — each file here exports a function named `content_filter` and the name of the file is a name of the filter.
If a filter with given name is not found in `src/builtin_filter`, application tries to find it in `src/custom_filters` directory.
You can use it to create your custom filters (take a look at a filter in `src/builtin_filter` for example).If you are using default `docker-compose.yml` config for deploy, you do not need to modify code in the repository.
`filters` directory is mounted into `src/custom_filters`, so you can just place your custom filters there.Application does not need to be restarted to pick up a new configuration.
Updated config is going to be used on next update.### Reusing config
You can reuse configuration for multiple feeds with YAML links:
```yaml
configs:
feed: &feed
channel: "-129837198239123"
link_preview: nofeeds:
- url: https://example.com/rss.xml
title_prefix: Example
<< : *feed
```## Bot configuration
You have to set bot token in `data/.env` file.
For example:```dotenv
TELEGRAM_BOT_TOKEN=my_telegram_bot_token
```## Deployment
You can use an example provided in `prod.docker-compose.yml` file for deployment.
Create `docker-compose.yml` file and paste contents from `prod.docker-compose.yml` file into it.
You should also create `data` (for keeping `data/.env` and `data/config.yaml`) and `filters` (for keeping custom filters) directories.After setting up feeds in config and configuring bot token, you can start the bot with docker-compose.
```sh
docker-compose up --build
```