This README is your one-stop guide to understanding and using the super cool Python code for a bot that acts like a tweet-retrieving superhero 🦸♀️, bringing the latest tweets from your favorite accounts straight to your Telegram channel!
🔎 Scans Twitter Accounts: Like a tireless detective 🕵️♂️, the bot keeps a watchful eye on a list of Twitter usernames you provide. 📥 Grabs New Tweets (Optional Replies Too!): It swoops in and snatches up any new tweets (including replies, if you want them ✉️) from those accounts. 📩 Sends Them to Your Telegram Channel: Faster than a speeding tweet ⚡️, the bot delivers those fresh tweets directly to your designated Telegram channel, keeping you in the loop 🪢. 👤 Manages Usernames with Ease: Feeling overwhelmed by all the tweets? No worries! The bot provides special Telegram channel commands 📜 that let you add, remove, or even delete usernames from the monitored list. 📆 Daily Reports Keep You Informed: Every day at noon (like a clockwork owl 🦉!), the bot sends you a report summarizing the number of tweets retrieved for each user.
✔️ Python 3 (the coding language that makes the magic happen 🪄) ✔️ These awesome libraries (pip install them to join the party):
- telebot (talks to Telegram for you 📲)
- tweepy (chats with Twitter like a pro 🐦)
- pymongo (keeps track of things in a fancy database 💾)
- schedule (makes sure things happen on time ⏰)
- and a few other helpful ones ✔️ Your own unique Telegram bot token (find it in the BotFather settings 🤖) ✔️ A MongoDB connection string (where the bot stores its info 🗃️)
To authorize and obtain the session for the bot, please refer to the Signing In — Tweety 1.0.9.6 documentation. This documentation provides step-by-step instructions on how to sign in to Twitter using Tweety. Once you have obtained the authenticated session file, named 'session.tw_session', you can load the session using the connect
method.
To obtain the session information of a webpage, you can navigate to the website and open the Developer Tools by right-clicking on the page and selecting "Inspect." In the "Network" tab of the Developer Tools, you can locate the initial request sent to the server, and the session information can be found there.
- Install the libraries (mentioned above) using pip.
- Grab the code and replace these placeholders with your info:
- API : Your Telegram bot token (don't share this with anyone! 🔒)
- ID : The ID of your Telegram channel (where the tweets will land 📢)
- URL : Your MongoDB connection string (keep your data safe 🔐)
- Generate the session file ('session.tw_session') by following the link i provided.
- Run the script from the command line:
-
python twitter_to_telegram.py
🚨 Use code with caution.
- /start: Gets things going (use this initially, but not required afterwards).
- /help: Confused? This command shows you all the available commands (like a helpful genie 🧞♀️).
- /add <@username>: Want to add a new Twitter account to the monitored list? Use this command!
- /rem <@username>: Feeling overwhelmed? This command removes a username from the list (but don't worry, you can bring it back later!).
- /del <@username>: Need to permanently delete a username? This command does the trick (bye-bye birdie 🐦).
- /ls: Curious to see all the usernames currently monitored? This command shows you the list.
- /replies {true/false}: Want to include replies in the monitoring? Set it to true or exclude them with false (the choice is yours! ✔️/❌).
- The script uses a fancy multi-threading approach (like having multiple superheroes working together 🦸♂️) to handle tweet monitoring and Telegram communication at the same time.
- It uses MongoDB as its memory palace to store information about monitored users and retrieved tweets.
- The script schedules reports and data checks to keep things running smoothly (like a well-oiled machine ⚙️).
Please let me know if there's anything else I can help you with! 🎉
This project was created by Dawit Neri
If you encounter any issues or have any questions, feel free to reach out to [email protected] or open an issue in the GitHub repository.