Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raine/tgreddit
Get the top posts of your favorite subreddits to Telegram
https://github.com/raine/tgreddit
reddit telegram
Last synced: about 1 month ago
JSON representation
Get the top posts of your favorite subreddits to Telegram
- Host: GitHub
- URL: https://github.com/raine/tgreddit
- Owner: raine
- Created: 2022-06-21T15:04:12.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-23T21:08:04.000Z (7 months ago)
- Last Synced: 2024-11-19T00:17:01.997Z (about 1 month ago)
- Topics: reddit, telegram
- Language: Rust
- Homepage:
- Size: 108 KB
- Stars: 28
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tgreddit
A telegram bot that gives you a feed of top posts from your favorite subreddits.
The killer feature: No need to visit Reddit, as all media is embedded thanks to
[yt-dlp][yt-dlp] and Telegram's excellent media support.Intended to be self-hosted, as Reddit's API has rate-limiting and downloading
videos with `yt-dlp` can be resource intensive. The simplest way to self-host is
to use the prebuilt [docker image](#docker-image) that includes necessary
dependencies.
## install
```sh
$ cargo install tgreddit
```### requirements
Depends on [yt-dlp][yt-dlp] (and for good results, yt-dlp requires ffmpeg).
## bot commands
### `/sub [limit=] [time=
Add a subscription to subreddit's top posts with optional options. Subscriptions
are conversation specific, and may be added in channels where the bot is
participating or in private chats with the bot.If the options are not given, when checking for new posts, the program will
default to configuration in config.toml, if any.Example: `/sub AnimalsBeingJerks limit=5 time=week filter=video`
Explanation: Subscribe to top posts in r/AnimalsBeingJerks so that the top 5
posts of the weekly top list are considered. Whenever a new post appears among
those top 5 posts, they will be posted in the conversation.See the
[example configuration](#example-toml-configuration-with-the-options-explained)
below for further explanation on `limit`, `time`, and `filter`.### `/unsub `
Remove a subscription from the current conversation.
### `/listsubs`
List all subreddit subscriptions for the current conversation.
### `/get [limit=] [time=
Get the current top posts similarly to how subscribing to a subreddit would
return new posts.## configuration
### env vars
- `CONFIG_PATH`: Path to TOML configuration file. **required**
- `RUST_LOG`: Logging level. `info` recommended to see meaningful output.### example toml configuration with the options explained
Example config without comments:
[config.example.toml](https://raw.githubusercontent.com/raine/tgreddit/master/config.example.toml)```toml
# Path to a SQLite database used to track seen posts.
# Optional. Defaults to $HOME/.local/state/tgreddit/data.db3.
db_path = "/path/to/data.db3"# List of Telegram user ids that can use the commands provided by the bot.
authorized_users = [
123123123
]# Token of your Telegram bot - you get this from @botfather.
telegram_bot_token = "..."# How often to query each configured subreddit for new posts. Applies only if
# keep_running is enabled.
check_interval_secs = 600# Whether posts seen on the first check of a new subreddit are considered new
# or not. Generally having this enabled is better unless you want multiple new
# messages when a new subreddit is added.
# Optional. Defaults to true.
skip_initial_send = true# Set the post comments links to use an alternative frontend. Useful as the
# official Reddit web app is increasingly user hostile on mobile. Possible
# alternative frontends include teddit.net and libredd.it, but you can use any.
# Optional. Defaults to official Reddit.
links_base_url = "https://teddit.net"# Set default limit of posts to fetch for each subreddit. Used when not
# specified for a subreddit in the /sub command.
#
# Explanation in more detail: Whenever the bot gets the list of top posts for a
# subreddit, it will only consider the first posts. For example, if
# your limit is 5, the first time around bot will see 5 new posts and mark those
# as seen and not post anything because it's the first check. Next time around, if
# there's an unseen post among those 5 top posts, it will be posted in Telegram.
#
# So essentially larger the number used as limit, the more posts you can
# expect to see. For example, with time=month and limit=1 you would see a new post
# only when the montly top post changes, which is not that often.
#
# Optional. The default is 1.
default_limit = 1# Set default time period of top list fetched. Used when not specified for a
# subreddit. String and one of: hour, day, week, month, year, all.
# Optional. The default is `day`.
default_time = "day"# Set default filter for post type. When fetching for new posts, only posts
# matching the filter are considered.
# String and one of: image, video, link, self_text, gallery
# Optional and unset by default, meaning all post types are considered.
default_filter = "video"
```Perhaps the simplest way to determine a Telegram channel's ID is to open the
channel in [Telegram Web client][telegram-web] and observing the numeric value
in page URL.## development
The project uses [`just`][just], [`direnv`][direnv] and [`entr`][entr].
```sh
$ just dev
```## docker image
There's a prebuilt Docker image with dependencies included at
[rainevi/tgreddit](https://hub.docker.com/repository/docker/rainevi/tgreddit).Of course, you may also build your own using from the
[Dockerfile](https://raw.githubusercontent.com/raine/tgreddit/master/Dockerfile).## cross compiling for Raspberry Pi
You can cross-compile tgreddit for Raspberry Pi using a Docker container. The
resulting executable will be statically linked and should work across different
Linux distributions on the Raspberry Pi.```sh
docker run --rm -it \
-v "$(pwd)":/home/rust/src messense/rust-musl-cross:aarch64-musl \
cargo build --release --target aarch64-unknown-linux-gnu --features vendored-openssl
```## have an idea, question or a bug report?
Feel free to open an issue or start a new discussion.
[yt-dlp]: https://github.com/yt-dlp/yt-dlp
[telegram-web]: https://web.telegram.org/
[just]: https://github.com/casey/just
[direnv]: https://direnv.net/
[entr]: https://github.com/eradman/entr