kumistatus/twitools/__init__.py
2016-07-20 19:30:51 +02:00

38 lines
867 B
Python

import setuptools, tweepy
def cke():
return setuptools.getSetting("Twitter", "cke", True)
def cse():
return setuptools.getSetting("Twitter", "cse", True)
def ato():
return setuptools.getSetting("Twitter", "ato", True)
def ase():
return setuptools.getSetting("Twitter", "ase", True)
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()