text stringlengths 0 828 |
|---|
Add a user to list |
:param list_id: list ID number |
:param user_id: user ID number |
:return: :class:`~responsebot.models.List` object |
"""""" |
return List(tweepy_list_to_json(self._client.add_list_member(list_id=list_id, user_id=user_id)))" |
1760,"def remove_list_member(self, list_id, user_id): |
"""""" |
Remove a user from a list |
:param list_id: list ID number |
:param user_id: user ID number |
:return: :class:`~responsebot.models.List` object |
"""""" |
return List(tweepy_list_to_json(self._client.remove_list_member(list_id=list_id, user_id=user_id)))" |
1761,"def list_members(self, list_id): |
"""""" |
List users in a list |
:param list_id: list ID number |
:return: list of :class:`~responsebot.models.User` objects |
"""""" |
return [User(user._json) for user in self._client.list_members(list_id=list_id)]" |
1762,"def is_list_member(self, list_id, user_id): |
"""""" |
Check if a user is member of a list |
:param list_id: list ID number |
:param user_id: user ID number |
:return: :code:`True` if user is member of list, :code:`False` otherwise |
"""""" |
try: |
return bool(self._client.show_list_member(list_id=list_id, user_id=user_id)) |
except TweepError as e: |
if e.api_code == TWITTER_USER_IS_NOT_LIST_MEMBER_SUBSCRIBER: |
return False |
raise" |
1763,"def subscribe_list(self, list_id): |
"""""" |
Subscribe to a list |
:param list_id: list ID number |
:return: :class:`~responsebot.models.List` object |
"""""" |
return List(tweepy_list_to_json(self._client.subscribe_list(list_id=list_id)))" |
1764,"def unsubscribe_list(self, list_id): |
"""""" |
Unsubscribe to a list |
:param list_id: list ID number |
:return: :class:`~responsebot.models.List` object |
"""""" |
return List(tweepy_list_to_json(self._client.unsubscribe_list(list_id=list_id)))" |
1765,"def list_subscribers(self, list_id): |
"""""" |
List subscribers of a list |
:param list_id: list ID number |
:return: :class:`~responsebot.models.User` object |
"""""" |
return [User(user._json) for user in self._client.list_subscribers(list_id=list_id)]" |
1766,"def is_subscribed_list(self, list_id, user_id): |
"""""" |
Check if user is a subscribed of specified list |
:param list_id: list ID number |
:param user_id: user ID number |
:return: :code:`True` if user is subscribed of list, :code:`False` otherwise |
"""""" |
try: |
return bool(self._client.show_list_subscriber(list_id=list_id, user_id=user_id)) |
except TweepError as e: |
if e.api_code == TWITTER_USER_IS_NOT_LIST_MEMBER_SUBSCRIBER: |
return False |
raise" |
1767,"def auth(config): |
"""""" |
Perform authentication with Twitter and return a client instance to communicate with Twitter |
:param config: ResponseBot config |
:type config: :class:`~responsebot.utils.config_utils.ResponseBotConfig` |
:return: client instance to execute twitter action |
:rtype: :class:`~responsebot.responsebot_client.ResponseBotClient` |
:raises: :class:`~responsebot.common.exceptions.AuthenticationError`: If failed to authenticate |
:raises: :class:`~responsebot.common.exceptions.APIQuotaError`: If API call rate reached limit |
"""""" |
auth = tweepy.OAuthHandler(config.get('consumer_key'), config.get('consumer_secret')) |
auth.set_access_token(config.get('token_key'), config.get('token_secret')) |
api = tweepy.API(auth) |
try: |
api.verify_credentials() |
except RateLimitError as e: |
raise APIQuotaError(e.args[0][0]['message']) |
except TweepError as e: |
raise AuthenticationError(e.args[0][0]['message']) |
else: |
logging.info('Successfully authenticated as %s' % api.me().screen_name) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.