{"id":16099275,"url":"https://github.com/yvasyliev/reddit-telegram-forwarder","last_synced_at":"2025-03-22T02:45:23.118Z","repository":{"id":159191403,"uuid":"520623928","full_name":"yvasyliev/reddit-telegram-forwarder","owner":"yvasyliev","description":"Repeats Subreddit posts to Telegram.","archived":false,"fork":false,"pushed_at":"2024-05-31T17:01:14.000Z","size":6537,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T07:32:21.268Z","etag":null,"topics":["jsoup","log4j2","reddit-api","reddit-bot","spring-context","telegram-api","telegram-bot","telegram-bot-api","telegram-forward-bot","telegram-forwarder","telegrambots"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yvasyliev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-02T19:24:24.000Z","updated_at":"2024-05-31T17:01:17.000Z","dependencies_parsed_at":"2024-02-01T19:39:46.253Z","dependency_job_id":"a8b54c07-fe0d-4817-98c5-67814020cfba","html_url":"https://github.com/yvasyliev/reddit-telegram-forwarder","commit_stats":null,"previous_names":["yvasyliev/reddit-telegram-forwarder"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvasyliev%2Freddit-telegram-forwarder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvasyliev%2Freddit-telegram-forwarder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvasyliev%2Freddit-telegram-forwarder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvasyliev%2Freddit-telegram-forwarder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yvasyliev","download_url":"https://codeload.github.com/yvasyliev/reddit-telegram-forwarder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244898410,"owners_count":20528335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jsoup","log4j2","reddit-api","reddit-bot","spring-context","telegram-api","telegram-bot","telegram-bot-api","telegram-forward-bot","telegram-forwarder","telegrambots"],"created_at":"2024-10-09T18:26:38.639Z","updated_at":"2025-03-22T02:45:23.096Z","avatar_url":"https://github.com/yvasyliev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![reddit-telegram-forwarder-logo](assets/reddit-telegram-forwarder-logo.png)\n\n# Reddit-Telegram Forwarder\n\nSpring Boot-based Java application to forward Reddit posts to Telegram channel.\n\n# Requirements\n\n- `Java 21`\n- `Maven`\n- [Reddit](https://www.reddit.com/login/) profile\n- [Telegram](https://web.telegram.org/a/) profile\n- Telegram channel\n- A chat connected to your Telegram channel\n\n# Quickstart\n\n1. Go to https://www.reddit.com/prefs/apps and create an app.\n    * Application type must be `script`.\n\n      ![create-reddit-app](assets/create-reddit-app.gif)\n2. Create Telegram Bot. You'll need a bot token.\n    * [How Do I Create a Bot?](https://core.telegram.org/bots#how--o-i-create-a-bot)\n3. Get the app.\n    * Clone and build the project:\n        ```shell\n        git clone https://github.com/yvasyliev/reddit-telegram-repeater.git\n        mvn clean package -Dmaven.test.skip\n        cd target\n        ```\n    * Or\n      download [executable JAR](https://github.com/yvasyliev/reddit-telegram-forwarder/releases/latest/download/reddit-telegram-forwarder-3.2.7.jar)\n      from the [latest release](https://github.com/yvasyliev/reddit-telegram-forwarder/releases/latest).\n4. Run the app:\n   ```shell\n   java -jar reddit-telegram-forwarder-3.2.7.jar \\\n   --reddit.client.id=${REDDIT_CLIENT_ID} \\\n   --reddit.client.secret=${REDDIT_CLIENT_SECRET} \\\n   --reddit.password=${REDDIT_PASSWORD} \\\n   --reddit.subreddit=${SUBBREDDIT_NAME} \\\n   --reddit.username=${REDDIT_USERNAME} \\\n   --telegram.admin.id=${TELEGRAM_ADMIN_ID} \\\n   --telegram.bot.token=${TELEGRAM_BOT_TOKEN} \\\n   --telegram.bot.username=${TELEGRAM_BOT_USERNAME} \\\n   --telegram.channel.id=${TELEGRAM_CHANNEL_ID} \\\n   --telegram.chat.id=${TELEGRAM_CHAT_ID}\n   ```\n    * Don't forget to replace `${...}` placeholders with correct values.\n\n# How it works\n\nThis a console application built with `Spring Boot` (not Web!).\nThere is a\nmethod [ScheduledPostManager#shareNewPosts](src/main/java/com/github/yvasyliev/service/telegram/ScheduledPostManager.java#L26)\nannotated with `@Scheduled`.\nThis method retrieves subreddit new posts using [Reddit API](https://www.reddit.com/dev/api/) and forwards them to\nTelegram channel using [Telegram Bots API](https://core.telegram.org/bots/api).\nBy default, `shareNewPosts()` is invoked once per minute, and it can be configured by environment variables (see [Application variables](#application-variables)).\n\nIf post author is in block list or the post is marked as NSFW, the post will be sent to admin for validation. Admin can\neither accept or reject posts.\n\nBlock list is stored in `SQLite` database. All database configs and management are handled automatically\nby `Spring Boot Data`.\nNo user actions required.\n\nAdditionally, this application runs\na [Long Polling Bot](src/main/java/com/github/yvasyliev/bots/telegram/RedditTelegramForwarderBot.java) that helps you\nwith application management.\nThe bot can accept suggested user posts (see [Bot commands](#bot-commands)).\n\n# Application variables\n\nAs you noticed, the application relies on a set of variables.\nSince it's a `Spring Boot` project, these variables can be passed as command line arguments (see [Quickstart](#quickstart)), defined in [application.properties](src/main/resources/application.properties) or set\nglobally as environment variables (see [Spring Boot Docs](https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config)\nfor more details).\n\n|                   Variable                   | Required | Default value | Description                                                                                                                                                                                                                                               | Example                                          |\n|:--------------------------------------------:|:--------:|:-------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------|\n| `delayed.blocking.executor.delay.in.seconds` | `false`  |     `20`      | Delay in seconds used to postpone sending messages in order to avoid \"too many requests\" errors in Telegram.                                                                                                                                              | `20`                                             |\n|      `http.request.timeout.in.minutes`       | `false`  |      `2`      | Timeout in minutes applied to Reddit API call.                                                                                                                                                                                                            | `5`                                              | \n|     `reddit.authors.blocked.by.default`      | `false`  |    `false`    | `true` - check Reddit autor against Block list. `false` - ignore Block list and ask admin to validate every post.                                                                                                                                         | `true`                                           |\n|              `reddit.client.id`              |  `true`  |       -       | Reddit `client_id`.                                                                                                                                                                                                                                       | `pW134F0XNuueG4W78x9uGA`                         |\n|            `reddit.client.secret`            |  `true`  |       -       | Reddit client `secret`.                                                                                                                                                                                                                                   | `fsdT6VkTgf1WMfSW6Pd5t4DRvfVueB`                 |\n|              `reddit.password`               |  `true`  |       -       | Reddit profile password.                                                                                                                                                                                                                                  | `ETD1fqx%cfk6odj#boj`                            |\n|              `reddit.subreddit`              |  `true`  |       -       | Subreddit name without `r/` prefix.                                                                                                                                                                                                                       | `cats`                                           |\n|              `reddit.username`               |  `true`  |       -       | Reddit profile username.                                                                                                                                                                                                                                  | `RedditProfileUsername000`                       |\n|             `telegram.admin.id`              |  `true`  |       -       | Telegram user ID (Telegram channel admin ID). Bot will send error logs directly to user. \u003cul\u003e\u003cli\u003e[How to find your User ID in Telegram?](https://www.google.com/search?q=How+to+find+your+User+ID+in+Telegram%3F)\u003c/li\u003e\u003c/ul\u003e                               | `280531210`                                      |\n|           `telegram.bot.username`            |  `true`  |       -       | Telegram bot username.                                                                                                                                                                                                                                    | `SubredditForwarderBot`                          |\n|             `telegram.bot.token`             |  `true`  |       -       | Telegram bot token.                                                                                                                                                                                                                                       | `4336854599:BBFqVLRq9ixVdxORFWQgaSywzCfRo5-tBus` |\n|            `telegram.channel.id`             |  `true`  |       -       | Telegram channel ID. Subreddit posts will be sent to this channel. \u003cul\u003e\u003cli\u003e[How to get the channel ID](https://gist.github.com/mraaroncruz/e76d19f7d61d59419002db54030ebe35#new-improved-next-steps)\u003c/li\u003e\u003c/ul\u003e                                            | `-1001572613876` or `@SubredditPostChannel`      |\n|              `telegram.chat.id`              |  `true`  |       -       | The ID of the chat where users can leave comments under posts. Bot will send additional photos to this chat if orginal subreddit post contains more than 10 images. \u003cul\u003e\u003cli\u003e[How to get chat ID](https://stackoverflow.com/a/69302407/21234935)\u003c/li\u003e\u003c/ul\u003e | `-1003121089009` or `@SubbredditPostChannelChat` |\n| `telegram.schedule.posting.delay.in.minutes` | `false`  |      `1`      | How often (in minutes) the application should scan subreddit for new posts.                                                                                                                                                                               | `5`                                              |\n|     `telegram.schedule.posting.enabled`      | `false`  |    `true`     | Should application start forwarding right after startup or not. Can be paused/resumed via [Bot commands](#bot-commands).                                                                                                                                  | `false`                                          |\n\n# Bot commands\n\nThere are two types of commands:\n\n- `user` - available for all users;\n- `admin` - available for admin only.\n\n|     Command      |  Type   | Description                                                                                                                                                                                                                                                                                         |\n|:----------------:|:-------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n|  `/blockauthor`  | `admin` | Add Reddit user to Block list.                                                                                                                                                                                                                                                                      |\n|    `/cancel`     | `user`  | Cancel current command.                                                                                                                                                                                                                                                                             |\n| `/contactadmin`  | `user`  | Send message to admin.                                                                                                                                                                                                                                                                              |\n|     `/done`      | `user`  | Same as `/cancel`.                                                                                                                                                                                                                                                                                  |\n|  `/getblocked`   | `admin` | Show block list.                                                                                                                                                                                                                                                                                    |\n|     `/help`      | `user`  | Show list of commands.                                                                                                                                                                                                                                                                              |\n| `/pauseposting`  | `admin` | Pause posts forwarding.                                                                                                                                                                                                                                                                             |\n| `/resumeposting` | `admin` | Resume posts forwarding.                                                                                                                                                                                                                                                                            |\n|     `/start`     | `user`  | Same as `/help`.                                                                                                                                                                                                                                                                                    |\n|     `/stop`      | `admin` | Completely stop the application. \u003cul\u003e\u003cli\u003eYou can start it again by executing `java -jar ...`.\u003c/li\u003e\u003cli\u003eIt takes up to ~30 seconds to stop all the processes.\u003c/li\u003e\u003cli\u003eSome exceptions can be thrown because of interrupted threads or closed application context. It's fine to ignore them.\u003c/li\u003e\u003c/ul\u003e |\n|  `/suggestpost`  | `user`  | Suggest a post to channel. The post will be sent to admin for validation.                                                                                                                                                                                                                           |\n| `/unblockauthor` | `admin` | Remove Reddit user from block list.                                                                                                                                                                                                                                                                 |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyvasyliev%2Freddit-telegram-forwarder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyvasyliev%2Freddit-telegram-forwarder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyvasyliev%2Freddit-telegram-forwarder/lists"}