diff --git a/README.md b/README.md index c2b0324..759959e 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,6 @@ Supports Twitter API v2! 🎉🎉🎉🎉🎉🎉 -# Public Bot has been discontinued - -![](assets/announcement.png) - # Features All the following features rely on authorized users. diff --git a/assets/announcement.png b/assets/announcement.png deleted file mode 100644 index 7f6947f..0000000 Binary files a/assets/announcement.png and /dev/null differ diff --git a/teletweet/tweet.py b/teletweet/tweet.py index c625d33..ecc478d 100644 --- a/teletweet/tweet.py +++ b/teletweet/tweet.py @@ -58,16 +58,22 @@ def send_tweet(message, pics: Union[list, None] = None) -> dict: if not text: text = "" tweet_id = __get_tweet_id_from_reply(message) + client, api = __connect_twitter(chat_id) + logging.info("Tweeting...") + ids = upload_media(api, pics) try: - client, api = __connect_twitter(chat_id) - logging.info("Tweeting...") - ids = upload_media(api, pics) status = client.create_tweet(text=text, media_ids=ids, in_reply_to_tweet_id=tweet_id) logging.info("Tweeted") response = status.data except Exception as e: - logging.error(traceback.format_exc()) - response = {"error": str(e)} + if "Your Tweet text is too long." in str(e): + logging.warning("Tweet too long, trying to make it shorter...") + # try to post by making it shorter + status = client.create_tweet(text=text[:110] + "...", media_ids=ids, in_reply_to_tweet_id=tweet_id) + response = status.data + else: + logging.error(traceback.format_exc()) + response = {"error": str(e)} return response