This project is archived and no longer functional. See Why is this archived? below.
A bot that forwarded Facebook page updates to a Telegram channel.
Written in Python, it used python-telegram-bot for the Telegram Bot API and facebook-sdk for the Facebook Graph API.
This bot was built in 2017 targeting Python 3.6, Facebook Graph API v2.7, and libraries that have since been abandoned or undergone breaking rewrites. It is no longer functional for the following reasons:
Following the Cambridge Analytica scandal in 2018, Facebook (now Meta) drastically restricted its Graph API:
- Graph API v2.7 (used by this bot) was shut down long ago. The current version is v22+.
- Reading posts from pages you don't manage now requires Business Verification and App Review approval for the "Page Public Content Access" feature. Meta routinely denies hobbyist and personal projects.
- Reading posts from pages you do manage is still possible with a Page Access Token, but requires periodic token refresh (~60 days).
In short, the simple "create an app, get a token, read any public page" workflow this bot relied on no longer exists.
| Dependency | Issue |
|---|---|
facebook-sdk |
Last released in 2018. Unmaintained. |
youtube-dl |
Abandoned/DMCA'd. Superseded by yt-dlp. |
python-telegram-bot |
The bot uses the old synchronous API (v12/v13). v20+ is fully async with a completely different API surface. |
- Excessive use of global variables instead of proper encapsulation
- Uses
configparser.SafeConfigParser(removed in Python 3.12) - Uses
print()instead of the logging module throughout - Several bugs (undefined variables in error paths, dead code)
- Telegram caption limit hardcoded to 200 characters (now 1024)
Click to expand
fbpages-telegram-bot used Python 3 (developed and tested with version 3.6.0).
Required packages:
python-telegram-botfacebook-sdkyoutube-dl
Installed with:
pip3 install python-telegram-bot, facebook-sdk, youtube-dl
- Message @BotFather on Telegram to create a new bot and get its token.
- Start a conversation with your new bot and send any message to it. You can go to
https://api.telegram.org/bot<BOTID>/getUpdatesto find youruser_idorchat_idto use in the settings file. - Add your newly created bot as an administrator of the channel that will receive the posts.
- Create a Facebook App and then go to the Graph API Explorer. Choose your new app in the top right corner, and then click on
Get Token,Get App Token. TheAccess Tokenfield will now have the token required for the Facebook section of the settings file. - Clone the repository with
git clone https://github.com/s1cp/fbpages-telegram-bot.git - Enter the new directory with
cd fbpages-telegram-bot - Set the appropriate values in a file called
botsettings.ini. Useexample.botsettings.inias an example withcp example.botsettings.ini botsettings.ini && nano botsettings.ini. - Run the bot with
python3 facebook2telegram.py
| Name | Description |
|---|---|
locale |
Facebook locale. Format example: en-US |
token |
Facebook Graph API token. |
pages |
List of page IDs. Format example: ['123456789',pageusername'] |
refreshrate |
Time interval between every Facebook check, in seconds. |
status |
Allow status posts. Format: True or False |
photo |
Allow photo posts. Format: True or False |
video |
Allow video posts. Format: True or False |
link |
Allow link posts. Format: True or False |
shared |
Allow shared posts. Format: True or False |
message |
Allow message in posts. Format: True or False |
| Name | Description |
|---|---|
token |
Telegram Bot API token. |
channel |
Username of the channel that will receive the posts |
admin |
Optional. Bot creator's ID to receive the bot's status. |