Simple python code i created for my twitter bots using Tweepy. It is able to listen to keyword and retweet and/or favorite them. Exmaple: @Jothipala_Bot
Tweepy (installed).
Need to have twitter app with Oauth keys and etc.
Python 3.4 recommended.
Fill in Oauth info to
ckey = 'here'csecret = 'here'atoken = 'here'asecret = 'here'
To favorite a tweet you would add
fav(tweet_cid)in on_data method.
To retweet a tweet you would add
retweet(tweet_cid)in on_data method.
To unfavorite a tweet you would add
unfav(tweet_cid)in on_data method.
track_words=["#SriLanka"]
...
twt.filter(track= track_words)
This will listen to "#SriLanka" tag live.
If you want to listen to tweets from a certian account:
follow_acc = ['2312312' , '1234332'] # all username converted to user ids
...
twt.filter(follow = follow_acc)
If you want to listen to tweets from a certian location:
loc = [-74.255735,40.496044,-73.7002721,40.9152555] #Box cordinations at the location
...
twt.filter(locations=loc)
If you want to not retweet or favorite a tweet from a certian account or tweets with words, put them into the following arrays.
banned_accs = ['twitter' , 'twittersupport'] # banned account screen name goes in here
banned_words = ['hate' , 'derp'] # banned words goes in here whitelist_acc = ['twitter' , 'twittersupport'] # banned account screen name goes in here
whitelist_words = ['Hellow' , 'Daft Punk'] # banned words goes in here