2016-03-16 12:49:28 +00:00
|
|
|
import setuptools, tweepy
|
2016-03-16 12:44:50 +00:00
|
|
|
|
|
|
|
def cke():
|
|
|
|
try:
|
2016-03-16 12:57:57 +00:00
|
|
|
return setuptools.getSetting("Twitter", "cke")
|
2016-03-16 12:44:50 +00:00
|
|
|
except:
|
2016-03-16 12:49:28 +00:00
|
|
|
raise setuptools.SetupException()
|
2016-03-16 12:44:50 +00:00
|
|
|
|
|
|
|
def cse():
|
|
|
|
try:
|
2016-03-16 12:49:28 +00:00
|
|
|
return setuptools.getSetting("Twitter", "cse")
|
2016-03-16 12:44:50 +00:00
|
|
|
except:
|
2016-03-16 12:49:28 +00:00
|
|
|
raise setuptools.SetupException()
|
2016-03-16 12:44:50 +00:00
|
|
|
|
|
|
|
def ato():
|
|
|
|
try:
|
2016-03-16 12:49:28 +00:00
|
|
|
return setuptools.getSetting("Twitter", "ato")
|
2016-03-16 12:44:50 +00:00
|
|
|
except:
|
2016-03-16 12:49:28 +00:00
|
|
|
raise setuptools.SetupException()
|
2016-03-16 12:44:50 +00:00
|
|
|
|
|
|
|
def ase():
|
|
|
|
try:
|
2016-03-16 12:49:28 +00:00
|
|
|
return setuptools.getSetting("Twitter", "ase")
|
2016-03-16 12:44:50 +00:00
|
|
|
except:
|
2016-03-16 12:49:28 +00:00
|
|
|
raise setuptools.SetupException()
|
2016-03-16 12:44:50 +00:00
|
|
|
|
|
|
|
def user():
|
|
|
|
return twObject().whoami()
|
|
|
|
|
|
|
|
class twObject:
|
|
|
|
|
|
|
|
def __init__(self, cke = cke(), cse = cse(), ato = ato(), ase = ase()):
|
|
|
|
self.auth = tweepy.OAuthHandler(cke, cse)
|
|
|
|
self.auth.set_access_token(ato, ase)
|
|
|
|
self.api = tweepy.API(self.auth)
|
|
|
|
|
|
|
|
def delete(self, id):
|
|
|
|
self.api.destroy_status(id)
|
|
|
|
|
|
|
|
def search(self, query, savepoint = 0):
|
|
|
|
tweets = list(tweepy.Cursor(self.api.search, q=query, since_id=savepoint).items())
|
|
|
|
tweets.reverse()
|
|
|
|
return tweets
|
|
|
|
|
|
|
|
def tweet(self, text):
|
|
|
|
self.api.update_status(text)
|
|
|
|
|
|
|
|
def whoami(self):
|
|
|
|
return self.auth.get_username()
|
|
|
|
|