From c5b81973ed7248f6a8c56ca88877b3836532dc95 Mon Sep 17 00:00:00 2001 From: avaakash Date: Sun, 9 Jan 2022 00:30:04 +0530 Subject: [PATCH] Fixed security flaw with other tweet commands; Updated README Signed-off-by: avaakash --- README.md | 33 ++++++++++++++++++++++++--------- telegram_handler/tweet.py | 2 ++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 24dbaf1..233ce08 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,27 @@ # Tweet From Message -This application will tweet anything to forward to your Telegram bot. -How to create Telegram Bot: -How to get Twitter API keys: +This application will tweet anything you forward to your Telegram bot. +- How to create Telegram Bot: [Telegram Botfather](https://core.telegram.org/bots#6-botfather) +- How to get Twitter API keys: [Twitter API docs](https://developer.twitter.com/en/docs/twitter-api) -Give the tokens and keys to the env.json file (a sample is given, follow that naming convention only) -Run the main.py file and voila, now send any text to your telegram bot and it will tweet it -Or you can run the start.sh file to start a background process. And stop.sh to kill the process +### Steps to Run +1. Give the tokens and keys to the env.json file (a sample is given, follow that naming convention only) +2. Run the start.sh script (or you can run the main.py file) +3. Send a message to bot and it will tweet it. +4. Run stop.sh to stop the bot server -Telegram bot commands -/start: displays a info message -/delete: deletes the last tweet done through the bot \ No newline at end of file +### Telegram bot commands +- /start: displays an info message +- \: tweets the message +- /delete: deletes the last tweet done through the bot +- /comment \: adds a comment to the last tweet done through the bot + +*Note*: change "\" with your tweet message + +### Security +The bot will only respond to specified telegram user ids only. Enter your telegram user ids in the env.json file. +## Upcoming Features +- Option to reply to comment tweet +- Option to reply to any of the last 7 tweets +- Last 7 tweet stats +- Popular hashtag auto-addition +- Option to like all retweets of the last 7 tweets \ No newline at end of file diff --git a/telegram_handler/tweet.py b/telegram_handler/tweet.py index 1eceda4..49d765e 100644 --- a/telegram_handler/tweet.py +++ b/telegram_handler/tweet.py @@ -37,6 +37,7 @@ def send_tweet(update: Update, context: CallbackContext): else: update_message(update, context) +@restricted def delete_tweet(update: Update, context: CallbackContext): """Delete a tweet command""" if update.message is not None: @@ -52,6 +53,7 @@ def delete_tweet(update: Update, context: CallbackContext): else: update_message(update, context, "delete") +@restricted def comment_tweet(update: Update, context: CallbackContext): """Tweets as a comment to the last tweet""" if update.message is not None: