sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.58k stars 1.31k forks source link

checking for video/photo in retweets #912

Closed ghost closed 3 years ago

ghost commented 6 years ago

I am using a code that allows me to have a bot that retweet tweets from users of specific hashtags. its a pretty simple bot and it works well, but I want it to be more specific in the tweets that it pulls.

I've been trying for a little while to find a way to check for video and photos. I've checked the documentation, and I haven't been having any luck in implementing it. please help?

this is the code that I am using: `require 'twitter'

client = Twitter::REST::Client.new do |config| config.consumer_key = "..." config.consumer_secret = "..." config.access_token = "..." config.access_token_secret = "..." end def run(client) retweetKeyword = "#ARMS,#NintendoSwitch" while true re = client.search(retweetKeyword).first.id client.retweet(re); puts "Retweet: #{re} #{Time.now}"; sleep(60); end

end

run(client);`

thanks in advance

edit: also, two recent issues I've currently ran into are that it sometimes gives me an error that I already retweeted something and it stops the program and also, retweeting things that are months old instead of new. I would also appreciate help on these as well.