TweegramBot is a repository made using python which integrates with twitter and telegram APIs, and helps you convert telegram messages to tweet using github action on hourly basis.
- Fork this repository.
- Get your API_ID and API_HASH for telegram from here.
- Create a python file in your local, and paste the code given below.
from telethon.sync import TelegramClient
client = TelegramClient("tweegramBot", "<API_ID>", "<API_HASH>").start()-
Give your number and enter code you get on telegram, and that will create a
tweegramBot.sessionfile. Now place thistweegramBot.sessionfile at the root directory of this respository you have forked. -
It is recommended to not keep the repository in public, with the
*.session, which was created in the first step, and*.jsonfile which will be created when you add users to your list. -
Get your BEARER_TOKEN, API_KEY, API_SECRET, ACCESS_TOKEN and ACCESS_TOKEN_SECRET for twitter from here.
-
Set the API secrets you generated in the 2nd and 6th step. A total of 9 secret need to be created, which inclued 7 API secret, USERNAME (twitter username of the bot) and ENTITY(telegram username for the account from which you want to transfer the text to twitter). Learn how to create repository secrets here.
-
Secrets will look like these once setup.
-
Once the above steps are completed, this repo will run every hour, and convert all your telegram messages into tweets.
-
IMPORTANT: Make sure to give
read and write permissionto github action for this repository under settings section.
@add <TWITTER USERNAME> => adds the user to white list.
@notice <YOUR MESSAGE> => these message will be considered as notice for telegram channel, and not be tweeted.
@remove <TWITTER USERNAME> => removes the user from white list.
| Command | Twitter Tweet | Telegram message |
|---|---|---|
| @add aps08__ | Thank you for joining us @aps08__.You have been added to our list with #JBDS34B34B. | ❌ |
| @notice Do not copy paste. | ❌ | ❌ |
| @remove aps08__ | ❌ | aps08__ tweeter user has been removed. |
You can see the Default class, which is present inside the src/main.py. Now you can see what each variables mean in the below table.
This project was in progress from past few weeks, so I am releasing it. The decision by twitter and API cost might affect the future of this project. Read here
If you liked something about this repository, do give it a 🌟. It will motivate me come up with more such project. You can reach out to me on my social media given below.

