From d75527f7eecc4e2fcdd18ab157412506717c8adb Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Mon, 7 Nov 2022 23:36:11 -0700 Subject: add blog post --- docs/posts/2021-06-25-Blog2Twitter-P1.html | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'docs/posts/2021-06-25-Blog2Twitter-P1.html') diff --git a/docs/posts/2021-06-25-Blog2Twitter-P1.html b/docs/posts/2021-06-25-Blog2Twitter-P1.html index ada9666..62233ab 100644 --- a/docs/posts/2021-06-25-Blog2Twitter-P1.html +++ b/docs/posts/2021-06-25-Blog2Twitter-P1.html @@ -57,7 +57,8 @@ I am not handling lists or images right now.

pip install tweepy

-
import os
+
+
import os
 import tweepy
 
 consumer_key = os.environ["consumer_key"]
@@ -70,13 +71,15 @@ I am not handling lists or images right now.

auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) -
+
+

The program need to convert the blog post into text fragments.

It reads the markdown file, removes the top YAML content, checks for headers and splits the content.

-
tweets = []
+
+
tweets = []
 
 first___n = 0
 
@@ -103,13 +106,15 @@ I am not handling lists or images right now.

print("ERROR") else: tweets.append(line) -
+
+

Every status update using tweepy has an id attached to it, for the next tweet in the thread, it adds that ID while calling the function.

For every tweet fragment, it also appends 1/n.

-
for idx, tweet in enumerate(tweets):
+
+
for idx, tweet in enumerate(tweets):
     tweet += " {}/{}".format(idx+1,len(tweets))
     if idx == 0:
         a = None
@@ -118,12 +123,15 @@ I am not handling lists or images right now.

a = api.update_status(tweet,in_reply_to_status_id=a.id) print(len(tweet),end=" ") print("{}/{}\n".format(idx+1,len(tweets))) -
+
+

Finally, it replies to the last tweet in the thread with the link of the post.

-
api.update_status("Web Version: {}".format(post_link))
-
+
+
api.update_status("Web Version: {}".format(post_link))
+
+

Result

-- cgit v1.2.3