|
1 |
| -# twigramBot |
| 1 | + |
| 2 | +<p align="center"> |
| 3 | + <img src="https://img.shields.io/badge/Visual_Studio_Code-0078D4?style=for-the-badge&logo=visual%20studio%20code&logoColor=white" alt="vscode"> |
| 4 | + <img src="https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54" alt="Python"> |
| 5 | + <img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" alt="Twitter"> |
| 6 | + <img src="https://img.shields.io/badge/GitHub_Actions-2088FF?style=for-the-badge&logo=github-actions&logoColor=white" alt="GitHub Actions"> |
| 7 | + <img src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white" alt="Telegram"> |
| 8 | +</p> |
| 9 | + |
| 10 | +# tweegramBot |
| 11 | +A semi-configured respository, which help you convert your telegram messages to twitter tweets, also retweet the tweets tweeted by specific list of users. |
| 12 | + |
| 13 | +### How to use |
| 14 | +* Fork this repository. |
| 15 | +* Get your API_ID and API_HASH for telegram from [here](https://my.telegram.org/apps). |
| 16 | +* Create a python file in your local, and paste the code given below. |
| 17 | +```python |
| 18 | +from telethon.sync import TelegramClient |
| 19 | + |
| 20 | +client = TelegramClient("tweegramBot", "<API_ID>", "<API_HASH>").start() |
| 21 | +``` |
| 22 | +* Give your number and enter code you get on telegram, and that will create a `tweegramBot.session` file. Now place this `tweegramBot.session` file at the root directory of this respository you have forked. |
| 23 | +* It is recommended to not keep the repository in public, with the `*.session`, which was created in the first step, and `*.json` file which will be created when you add users to your list. |
| 24 | +* Get your BEARER_TOKEN, API_KEY, API_SECRET, ACCESS_TOKEN and ACCESS_TOKEN_SECRET for twitter from [here](https://developer.twitter.com/en/portal/dashboard). |
| 25 | +* 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](https://docs.github.com/en/actions/security-guides/encrypted-secrets). |
| 26 | +* Secrets will look like these once setup. |
| 27 | + |
| 28 | + <img src="./docs/images/secrets.png" width="400" height="400"> |
| 29 | +* Once the above steps are completed, this repo will run every hour, and convert all your telegram messages into tweets. |
| 30 | +* *IMPORTANT*: Make sure to give `read and write permission` to github action for this repository under settings section. |
| 31 | + |
| 32 | +### Command features you can use on telegram |
| 33 | +``` |
| 34 | +@add <TWITTER USERNAME> => adds the user to white list. |
| 35 | +@notice <YOUR MESSAGE> => these message will be considered as notice for telegram channel, and not be tweeted. |
| 36 | +@remove <TWITTER USERNAME> => removes the user from white list. |
| 37 | +``` |
| 38 | +#### Example |
| 39 | +Command | Twitter Tweet | Telegram message| |
| 40 | +------------- | ------------- | ---------------| |
| 41 | +@add [aps08__](https://twitter.com/aps08__) | Thank you for joining us [@aps08__](https://twitter.com/aps08__).You have been added to our list with #JBDS34B34B. | ❌ |
| 42 | +@notice Do not copy paste. | ❌ | ❌ |
| 43 | +@remove aps08__ | ❌ | [aps08__](https://twitter.com/aps08__) tweeter user has been removed. |
2 | 44 |
|
3 |
| -twigramBot is a mini-script, which helps you to convert telegram messages to twitter tweets. |
| 45 | +### Default configuration and description |
| 46 | +You can see the Default class, which is present inside the [`src/main.py`](https://github.com/aps08/tweegramBot/blob/main/src/main.py). Now you can see what each variables mean in the below table. |
4 | 47 |
|
5 |
| -## Made with |
6 |
| - |
7 |
| - |
8 |
| - |
9 |
| - |
10 |
| - |
11 | 48 |
|
12 |
| -## How to use |
13 |
| -1. Get your API secrets for telegram from [here](https://my.telegram.org/apps). |
14 |
| -2. Get your API secrets for twitter from [here](https://developer.twitter.com/en/portal/dashboard). |
15 |
| -3. Fork this reposiotry, and uncomment the commented lines in [this](https://github.com/aps08/teltotwt/blob/main/.github/workfows/actions.yml) file. |
16 |
| -4. Create secrets for this repository. Total 8 secret key-value pair need to be created, 6 of them would be the API secrets, 1 would be telegram group/user name and 1 would be your github email. You can see the keys and instructions in [this](https://github.com/aps08/teltotwt/blob/main/src/config.py) file. |
17 |
| -5. Once the above steps are completed, this repo will run everyday at mid-night, and convert all your telegram messages into tweets. |
| 49 | +Variable | Description | |
| 50 | +------------- | ------------- | |
| 51 | +USERNAME | username of the twitter account, taken from the environmental variable. |
| 52 | +FIRST_COMMENT | Default `False`, when True and if you pass a link with an image, the image will be tweeted first and the link will be tweeted in the first comment. |
| 53 | +COMMAND_CHECK | Default `True`, when False telegram commands will not work. |
| 54 | +FILE_NAME | Name of the json file, which stores the list of users. Default `member_info`. |
| 55 | +PREFIX | adds the prefix to the token for easy identification for verification. Default `GTR`. |
| 56 | +RETWEET_TEXT | Retweet quote. We cannot create a rewteet with a quote. Default `Retweeting for better reach. \U0001F603` |
| 57 | +ADD_MESSAGE | Tweet notification message when a user is added to the json file. Default `Thank you for joining us @{}.You have been added to our list with #{}.` Make sure to give 2 `{}` for token and twitter username for tagging, when making changes. |
| 58 | +REMOVE_MESSAGE | Telegram notification when user is removed from the list. Default `{} tweeter user has been removed.` Make sure to pass `{}` in the string to add the username. |
| 59 | +ONLY_IMG_MESSAGE | This Message is required when you are tweeting only an image. Default `Opening \U0001F603`. |
| 60 | +RETWEET_MENTIONED | Default `True`, when False, the retweet functinality will not work. |
| 61 | +SEND_LOG_ON_ERR | Default `True`, when False you won't receive the logs on telegram when there is an error or warning. |
18 | 62 |
|
19 |
| -## Note |
20 |
| -1. *For this to work, one time manual process is required for telegram, where a session file will be generated.* |
21 |
| -2. *Do not keep the repository in public, with the **session** file*. |
| 63 | +### Bad news |
| 64 | +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](https://twitter.com/TwitterDev/status/1621026986784337922?t=AYvhqkC0gqApLV-Qw19hlA&s=19) |
22 | 65 |
|
| 66 | +<p align="center" style="text"><strong>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.</strong></p> |
23 | 67 |
|
24 |
| -## Where to find me |
25 |
| - |
26 |
| -<p align="left"> |
| 68 | +<p align="center"> |
27 | 69 | <a href="https://twitter.com/aps08__"><img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white"></a>
|
28 | 70 | <a href="https://medium.com/@aps08"><img src="https://img.shields.io/badge/Medium-12100E?style=for-the-badge&logo=medium&logoColor=white"></a>
|
29 | 71 | <a href="https://www.linkedin.com/in/aps08"><img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"></a>
|
30 | 72 | <a href="https://github.com/aps08"><img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white"></a>
|
31 | 73 | <a href="https://www.youtube.com/channel/UC8biJQnoqm1s2FZ8LK90baA"><img src="https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white"></a>
|
32 | 74 | <a href="mailto:anoopprsingh@gmail.com"><img src="https://img.shields.io/badge/Gmail-D14836?style=for-the-badge&logo=gmail&logoColor=white"></a>
|
| 75 | + <a href="https://t.me/aps080"><img src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a> |
33 | 76 | </p>
|
0 commit comments