A bot to forward Facebook page updates to a Telegram channel.
This bot is written in Python and uses the python-telegram-bot wrapper for the Telegram Bot API and the facebook-sdk client library for the Facebook Graph API.
fbpages-telegram-bot uses Python 3 (developed and tested with version 3.6.0), which can be downloaded here if you are running Windows, or by installing the python3
package with your package manager if you're running Linux.
sudo apt-get install python3 -y
You'll also need the following packages:
python-telegram-bot
facebook-sdk
youtube-dl
These can all be installed with:
pip3 install python-telegram-bot, facebook-sdk, youtube-dl
on both Windows's Command Prompt and Linux's terminal.
To get started with the bot itself:
- 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>/getUpdates
to find youruser_id
orchat_id
to 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 Token
field 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.ini
as 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. |