def tw_unfollow(channel, user_profile, silent_ex=False): """ Task for unfollowing a twitter screen name. :param channel: Used to grab the twitter credentials we are using for the unfollow action. :param screen_name: The twitter screen name we are going to unfollow :param silent_ex: Optional, if true any exceptions will just be silently ignored """ from solariat_bottle.settings import get_var, LOGGER from solariat_bottle.db.user_profiles.user_profile import UserProfile, get_brand_profile_id, get_native_user_id_from_channel result = {} if not get_var('ON_TEST') and get_var('APP_MODE') == 'prod': from solariat_bottle.utils.oauth import get_twitter_oauth_credentials (consumer_key, consumer_secret, _, access_token_key, access_token_secret) = get_twitter_oauth_credentials(channel) try: result = tw_destroy_friendship( consumer_key=consumer_key, consumer_secret=consumer_secret, access_token_key=access_token_key, access_token_secret=access_token_secret, screen_name=user_profile.screen_name) except Exception, ex: LOGGER.error("tasks.tw_unfollow: " + str(ex)) if silent_ex: result = dict(error=str(ex)) else: raise
def _get_stream_opts(self, channel): options = Namespace() options.channel = str(channel.id) (consumer_key, consumer_secret, _, access_token_key, access_token_secret) = get_twitter_oauth_credentials(channel) # Extract options here and pass to channel since we need this # when we compare for new channels. options.CONSUMER_KEY = consumer_key options.CONSUMER_SECRET = consumer_secret options.ACCESS_KEY = access_token_key options.ACCESS_SECRET = access_token_secret options.title = channel.title return options
def tw_share_post(channel, status_id=None, screen_name=None): """ Share a twitter post from a given channel. :param channel: The SO channle from where we are retweeting :param status_id: The twitter id which we are retweeting. :param screen_name: The screen name of the creator of the status we are retweeting """ from solariat_bottle.utils.oauth import get_twitter_oauth_credentials (consumer_key, consumer_secret, _, access_token_key, access_token_secret) = get_twitter_oauth_credentials(channel) return tw_retweet_status(consumer_key, consumer_secret, access_token_key, access_token_secret, status_id, screen_name)
def tw_direct_reply(channel, status, screen_name): """ Send a twitter direct message as a reply to the given post. :param channel: The channel from which we are replying with a DM :param status: The actual message we are replying with. :param screen_name: The screen name of the creator of the status we are retweeting """ from solariat_bottle.utils.oauth import get_twitter_oauth_credentials (consumer_key, consumer_secret, _, access_token_key, access_token_secret) = get_twitter_oauth_credentials(channel) return _send_direct_message(consumer_key, consumer_secret, access_token_key, access_token_secret, status, screen_name)
def tw_normal_reply(channel, status, status_id=None, post=None, media=None): """ Send a normal twitter reply to the given post. :param channel: The channel from which we are replying with a DM :param status: The actual message we are replying with. :param status_id: The twitter post id to which we are replying to :param post: The SO post object to which we are replying. """ from solariat_bottle.utils.oauth import get_twitter_oauth_credentials consumer_key, consumer_secret, _, access_token_key, access_token_secret \ = get_twitter_oauth_credentials(channel) return tw_update_status(consumer_key, consumer_secret, access_token_key, access_token_secret, status, status_id, post, media)