kumistatus/twitools/__init__.py

39 lines
892 B
Python
Raw Normal View History

2016-03-16 12:49:28 +00:00
import setuptools, tweepy
2016-03-16 12:44:50 +00:00
def cke():
2016-07-20 17:30:51 +00:00
return setuptools.getSetting("Twitter", "cke", True)
2016-03-16 12:44:50 +00:00
def cse():
2016-07-20 17:30:51 +00:00
return setuptools.getSetting("Twitter", "cse", True)
2016-03-16 12:44:50 +00:00
def ato():
2016-07-20 17:30:51 +00:00
return setuptools.getSetting("Twitter", "ato", True)
2016-03-16 12:44:50 +00:00
def ase():
2016-07-20 17:30:51 +00:00
return setuptools.getSetting("Twitter", "ase", True)
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, replyto = None):
self.api.update_status(text, replyto)
2016-03-16 12:44:50 +00:00
def whoami(self):
return self.auth.get_username()