This is the first Qiita post in my life. Read this article with a Buddha-like heart. I would be grateful if you could point out any mistakes.
At school, I took a rest only in the afternoon because of the troublesomeness of the class, so I decided to write a program, so I went to the industrial mechanics and English class.
So I decided to make a "Twitter Bot that uses the automatic tweet of #contributter_report to scatter myself if I was not committed that day" that I wanted to make from before, and I want to make a quote RT in it, so I will investigate However, even if I googled the official document, it does not come out easily. I finally found it there, so I decided to write a Qiita article so that if there is a person like me, I can easily find it in the search results.
This is a well-known fact and it would be very embarrassing if only I didn't know it. Quote RT can be done by ** tweeting the URL of the source tweet at the same time as the characters that match the quote RT **.
As an example, if the tweet below is quoted RT, copy the URL of this tweet Just paste the URL of the quoted tweet along with the text to be quoted RT and tweet You can quote RT like this.
API key and access token are set in key.py of another file and imported first.
import tweepy from key import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET auth = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET) auth.set_access_token(ACCESS_TOKEN_KEY,ACCESS_TOKEN_SECRET) api = tweepy.API(auth) tmp = 'https://twitter.com/genshi0916/status/' for tweet in tweepy.Cursor(api.search, q='genshi0916 contribution 0').items(1): text = tweet.text id = tweet.id try: print(text) print("Number of contributions:What does 0 mean?????????????Please make progress\n" + tmp + str(id)) api.update_status("Number of contributions:What does 0 mean?????????????Please make progress\n" + tmp + str(id)) except: print('error')
Get the id of the tweet with tweet.id, and put the part other than the tweet ID in tmp (This time it is'https://twitter.com/genshi0916/status/' because it is a bot that responds only to tweets of genshi0916)
If you keep the user name in this source,
user_name = tweet.user.screen_name
I think it is good to add such as and move tmp to the next line as shown below.
tmp = 'https://twitter.com/'+user_name+'/status/'
Quote RT ** Tweet the characters and the URL of the source tweet **! !! !! !! !! !!
I hope this article has helped someone. Have a good Twitter life with Twitter Bot! !! !!
The source is published on Github, so I will post the url. https://github.com/Genshi0916/genshi-contribution-check