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, replyto = None): self.api.update_status(text, replyto) def whoami(self): return self.auth.get_username()