Keep from echoing retweets/replies. Added reply field in tweet converter

This commit is contained in:
Alex Huddleston 2019-02-28 18:54:47 -06:00
parent e060e0d45d
commit 03e6c21120
3 changed files with 14 additions and 23 deletions

View file

@ -14,7 +14,8 @@ def convert_tweets(tweets):
'retweet':('RT @' in tweet.text),
'text':str(tweet.text.encode('utf-8'))[1:],
'hashtags':tweet.entities.get('hashtags'),
'mentions':tweet.entities.get('user_metions')
'mentions':tweet.entities.get('user_metions'),
'reply':(tweet.in_reply_to_status_id_str)
})
except:
@ -25,7 +26,8 @@ def convert_tweets(tweets):
'retweet':('RT @' in tweet.full_text),
'text':str(tweet.full_text.encode('utf-8'))[1:],
'hashtags':tweet.entities.get('hashtags'),
'mentions':tweet.entities.get('user_metions')
'mentions':tweet.entities.get('user_metions'),
'reply':(tweet.in_reply_to_status_id_str)
})
except:
@ -35,7 +37,8 @@ def convert_tweets(tweets):
'retweet':True,
'text':str(tweet.retweeted_status.text.encode("utf-8"))[1:],
'hashtags':tweet.entities.get('hashtags'),
'mentions':tweet.entities.get('user_metions')
'mentions':tweet.entities.get('user_metions'),
'reply':(tweet.in_reply_to_status_id_str)
})
return outtweets

View file

@ -85,13 +85,13 @@ def echo_recent_tweets(screen_name):
language=None,
idempotency_key=None)
'''
mastodon.status_post(
t['text'][1:-1],
visibility='public',
spoiler_text='Twitter Echo, I\'m not on Masto rn.'
)
print(t['date'] + '\t' + t['text'])
if((not t['reply']) and (not t['retweet'])):
mastodon.status_post(
t['text'][1:-1],
visibility='public',
spoiler_text='Twitter Echo, I\'m not on Masto rn.'
)
print(t['date'] + '\t' + t['text'])
sleep(30)
fresh_start = False
@ -100,16 +100,4 @@ def echo_recent_tweets(screen_name):
if __name__ == '__main__':
with open('users.txt', 'r') as f:
for l in f:
echo_recent_tweets(l.rstrip())
# Clean these up
'''
#write the csv
with open('%s_tweets.csv' % screen_name, 'w') as f:
writer = csv.writer(f)
writer.writerow(["id","created_at","retweet","text","hashtags","user_mentions"])
writer.writerows(outtweets)
pass
'''
echo_recent_tweets(l.rstrip())