From 12a946c88ad8b8ef3f84e51a70350606eebd3653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20J=C4=99dyk?= Date: Tue, 1 Feb 2022 13:50:40 +0100 Subject: [PATCH] fix twt text trim --- ayct_backend/__init__.py | 2 -- ayct_backend/campaign/__init__.py | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ayct_backend/__init__.py b/ayct_backend/__init__.py index 0145152..0775ac3 100644 --- a/ayct_backend/__init__.py +++ b/ayct_backend/__init__.py @@ -20,9 +20,7 @@ def create_app(): twitter_db.init_app(app) campaign_db.init_app(app) - twitter_db.drop_all(app=app) twitter_db.create_all(app=app) - campaign_db.drop_all(app=app) campaign_db.create_all(app=app) app.register_blueprint(twitter, url_prefix='/twitter') diff --git a/ayct_backend/campaign/__init__.py b/ayct_backend/campaign/__init__.py index 577ded2..a1cd3c5 100644 --- a/ayct_backend/campaign/__init__.py +++ b/ayct_backend/campaign/__init__.py @@ -68,9 +68,9 @@ def add_twitter_account(): dot_index = trimmed_text.rfind(".") space_index = trimmed_text.rfind(" ") if dot_index > 0: - tweet_text = trimmed_text[:dot_index].capitalize() + tweet_text = trimmed_text[:dot_index + 1].capitalize() else: - tweet_text = trimmed_text[:space_index].capitalize() + tweet_text = trimmed_text[:space_index + 1].capitalize() # create post on twitter oauth = OAuth1Session( @@ -82,7 +82,7 @@ def add_twitter_account(): response = oauth.post( "https://api.twitter.com/2/tweets", - json={"text": tweet_text + str(dot_index) + str(space_index)}, + json={"text": tweet_text}, ).json()['data'] # save campaign to database