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 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 that includes necessary dependencies.

install

sh $ cargo install tgreddit

requirements

Depends on yt-dlp (and for good results, yt-dlp requires ffmpeg).

bot commands

/sub <subreddit> [limit=<limit>] [time=<time>] [filter=<filter>]

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.

/unsub <subreddit>

Remove a subscription from the current conversation.

/listsubs

List all subreddit subscriptions for the current conversation.

/get <subreddit> [limit=<limit>] [time=<time>] [filter=<filter>]

Get the current top posts similarly to how subscribing to a subreddit would return new posts.

configuration

env vars

example toml configuration with the options explained

Example config without comments: 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.

telegrambottoken = "..."

How often to query each configured subreddit for new posts. Applies only if

keep_running is enabled.

checkintervalsecs = 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.

skipinitialsend = 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.

linksbaseurl = "https://teddit.net"

Set default limit of posts to fetch for each subreddit. Used when not

specified for a subreddit.

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" ```

Perhaps the simplest way to determine a Telegram channel's ID is to open the channel in Telegram Web client and observing the numeric value in page URL.

docker image

There's a prebuilt Docker image with dependencies included at rainevi/tgreddit.

Of course, you may also build your own using from the Dockerfile.

have an idea, question or a bug report?

Feel free to open an issue or start a new discussion.