Created
December 31, 2017 18:10
-
-
Save ffr4nz/0592f73c3bd8cdaf1786490cf07f1a8c to your computer and use it in GitHub Desktop.
Simple python script to tweet including random user mention
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from twitter import * | |
import requests | |
import random | |
config = {} | |
execfile("config.py", config) | |
twitter = Twitter( | |
auth = OAuth(config["access_key"], config["access_secret"], config["consumer_key"], config["consumer_secret"])) | |
lines = open('words.txt').read().splitlines() | |
rand_user =random.choice(lines) | |
print rand_user | |
results = twitter.users.search(q = rand_user) | |
for user in results: | |
print "@%s (%s): %s" % (user["screen_name"], user["name"], user["location"]) | |
rand_user = user["screen_name"] | |
break | |
new_status = "Today random mention to @"+rand_user+" #nosensetweet #justforfun Bot hosted by @pythonanywhere. More details: https://goo.gl/ecyjTR" | |
results = twitter.statuses.update(status = new_status) | |
print "updated status: %s" % new_status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment