/usr/share/pyshared/jsb/utils/twitter.py is in jsonbot 0.84.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # jsb/utils/twitter.py
#
#
""" twitter related helper functions .. uses tweepy. """
## tweepy imports
from jsb.contrib.tweepy.auth import OAuthHandler
from jsb.contrib.tweepy.api import API
from jsb.contrib.tweepy import oauth
## basic imports
import logging
## defines
go = True
## twitterapi function
def twitterapi(CONSUMER_KEY, CONSUMER_SECRET, token=None, *args, **kwargs):
""" return twitter API object - with or without access token. """
if not go:
logging.warn("the twitter plugin needs the credentials.py file in the .jsb/data/config dir. see .jsb/data/examples".upper())
return None
if token:
auth = OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(token.key, token.secret)
return API(auth, *args, **kwargs)
## twittertoken function
def twittertoken(CONSUMER_KEY, CONSUMER_SECRET, twitteruser, username):
""" get access token from stored token string. """
token = twitteruser.data.get(username)
if not token: return
return oauth.OAuthToken(CONSUMER_KEY, CONSUMER_SECRET).from_string(token)
|