本文整理汇总了Python中twython.Twython.create_block方法的典型用法代码示例。如果您正苦于以下问题:Python Twython.create_block方法的具体用法?Python Twython.create_block怎么用?Python Twython.create_block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twython.Twython
的用法示例。
在下文中一共展示了Twython.create_block方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TwythonAPITestCase
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import create_block [as 别名]
#.........这里部分代码省略.........
def test_verify_credentials(self):
'''Test representation of the authenticated user call succeeds'''
self.api.verify_credentials()
def test_update_account_settings(self):
'''Test updating a user account settings succeeds'''
self.api.update_account_settings(lang='en')
def test_update_delivery_service(self):
'''Test updating delivery settings fails because we don't have
a mobile number on the account'''
self.assertRaises(TwythonError, self.api.update_delivery_service,
device='none')
def test_update_profile(self):
'''Test updating profile succeeds'''
self.api.update_profile(include_entities='true')
def test_update_profile_colors(self):
'''Test updating profile colors succeeds'''
self.api.update_profile_colors(profile_background_color='3D3D3D')
def test_list_blocks(self):
'''Test listing users who are blocked by the authenticated user
succeeds'''
self.api.list_blocks()
def test_list_block_ids(self):
'''Test listing user ids who are blocked by the authenticated user
succeeds'''
self.api.list_block_ids()
def test_create_block(self):
'''Test blocking a user succeeds'''
self.api.create_block(screen_name='justinbieber')
def test_destroy_block(self):
'''Test unblocking a user succeeds'''
self.api.destroy_block(screen_name='justinbieber')
def test_lookup_user(self):
'''Test listing a number of user objects succeeds'''
self.api.lookup_user(screen_name='twitter,justinbieber')
def test_show_user(self):
'''Test showing one user works'''
self.api.show_user(screen_name='twitter')
def test_search_users(self):
'''Test that searching for users succeeds'''
self.api.search_users(q='Twitter API')
def test_get_contributees(self):
'''Test returning list of accounts the specified user can
contribute to succeeds'''
self.api.get_contributees(screen_name='TechCrunch')
def test_get_contributors(self):
'''Test returning list of accounts that contribute to the
authenticated user fails because we are not a Contributor account'''
self.assertRaises(TwythonError, self.api.get_contributors,
screen_name=screen_name)
def test_remove_profile_banner(self):
'''Test removing profile banner succeeds'''
示例2: TwitterHelper
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import create_block [as 别名]
#.........这里部分代码省略.........
def search(self, text, result_type="popular"):
query = quote_plus(text)
return self.twitter.search(q=query, result_type=result_type)["statuses"]
@retry(**retry_args)
def favourite(self, id_str):
try:
self.twitter.create_favorite(id=id_str)
self.identity.statistics.record_favourite()
except TwythonError as ex:
if "You have already favourited this tweet" in str(ex):
logger.warning(ex)
else:
raise
@retry(**retry_args)
def retweet(self, id_str):
try:
self.twitter.retweet(id=id_str)
self.identity.statistics.record_retweet()
except TwythonError as ex:
if "You have already retweeted this tweet" in str(ex):
logger.warning(ex)
else:
raise
@retry(**retry_args)
def add_user_to_list(self, list_id, user_id, screen_name):
self.twitter.create_list_members(list_id=list_id, user_id=user_id, screen_name=screen_name)
@retry(**retry_args)
def block_user(self, user_id, user_screen_name=None):
self.twitter.create_block(user_id=user_id, screen_name=user_screen_name)
@retry(**retry_args)
def get_user_timeline(self, **kwargs):
return self._rate_limit("/statuses/user_timeline", self.twitter.get_user_timeline, **kwargs)
def unblock_user(self, user):
self.twitter.destroy_block(user_id=user.id, screen_name=user.screen_name)
@retry(**retry_args)
def unblock_users(self):
user_ids = self.twitter.list_block_ids(stringify_ids=True)
for user_id in user_ids["ids"]:
self.twitter.destroy_block(user_id=user_id)
@retry(**retry_args)
def show_owned_lists(self):
return self.twitter.show_owned_lists()["lists"]
@retry(**retry_args)
def get_list_members(self, list_id):
return self.twitter.get_list_members(list_id=list_id, count=5000, include_entities=False)
@blocked
@retry(**retry_args)
def create_list(self, **kwargs):
return self.twitter.create_list(**kwargs)
@retry(**retry_args)
def follow(self, user_id, screen_name):
logger.info("following user id {} @{}".format(user_id, screen_name))
self.twitter.create_friendship(user_id=user_id, screen_name=screen_name)
self.identity.statistics.increment("Follows")
示例3: Twython
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import create_block [as 别名]
import sys
from twython import Twython, TwythonError
from config import *
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
l = len(sys.argv)
if l >=2:
user = sys.argv[1]
else:
user = input("User to block: ")
try:
target = int(user)
except:
target1 = user.split("/")
target = target1[-1]
if isinstance(target, str) is True:
try:
twitter.create_block(screen_name=target)
except TwythonError as e:
print(e)
elif isinstance(target, int) is True:
try:
twitter.create_block(user_id=target)
except TwythonError as e:
print(e)
示例4: TwythonAPITestCase
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import create_block [as 别名]
#.........这里部分代码省略.........
def test_verify_credentials(self):
"""Test representation of the authenticated user call succeeds"""
self.api.verify_credentials()
def test_update_account_settings(self):
"""Test updating a user account settings succeeds"""
self.api.update_account_settings(lang='en')
def test_update_delivery_service(self):
"""Test updating delivery settings fails because we don't have
a mobile number on the account"""
self.assertRaises(TwythonError, self.api.update_delivery_service,
device='none')
def test_update_profile(self):
"""Test updating profile succeeds"""
self.api.update_profile(include_entities='true')
def test_update_profile_colors(self):
"""Test updating profile colors succeeds"""
self.api.update_profile_colors(profile_background_color='3D3D3D')
def test_list_blocks(self):
"""Test listing users who are blocked by the authenticated user
succeeds"""
self.api.list_blocks()
def test_list_block_ids(self):
"""Test listing user ids who are blocked by the authenticated user
succeeds"""
self.api.list_block_ids()
def test_create_block(self):
"""Test blocking a user succeeds"""
self.api.create_block(screen_name='justinbieber')
def test_destroy_block(self):
"""Test unblocking a user succeeds"""
self.api.destroy_block(screen_name='justinbieber')
def test_lookup_user(self):
"""Test listing a number of user objects succeeds"""
self.api.lookup_user(screen_name='twitter,justinbieber')
def test_show_user(self):
"""Test showing one user works"""
self.api.show_user(screen_name='twitter')
def test_search_users(self):
"""Test that searching for users succeeds"""
self.api.search_users(q='Twitter API')
def test_get_contributees(self):
"""Test returning list of accounts the specified user can
contribute to succeeds"""
self.api.get_contributees(screen_name='TechCrunch')
def test_get_contributors(self):
"""Test returning list of accounts that contribute to the
authenticated user fails because we are not a Contributor account"""
self.assertRaises(TwythonError, self.api.get_contributors,
screen_name=screen_name)
def test_remove_profile_banner(self):
"""Test removing profile banner succeeds"""
示例5: TwythonEndpointsTestCase
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import create_block [as 别名]
#.........这里部分代码省略.........
"""Test updating a user account settings succeeds"""
self.api.update_account_settings(lang='en')
@unittest.skip('skipping non-updated test')
def test_update_delivery_service(self):
"""Test updating delivery settings fails because we don't have
a mobile number on the account"""
self.assertRaises(TwythonError, self.api.update_delivery_service,
device='none')
@unittest.skip('skipping non-updated test')
def test_update_profile(self):
"""Test updating profile succeeds"""
self.api.update_profile(include_entities='true')
@unittest.skip('skipping non-updated test')
def test_update_profile_colors(self):
"""Test updating profile colors succeeds"""
self.api.update_profile_colors(profile_background_color='3D3D3D')
@unittest.skip('skipping non-updated test')
def test_list_blocks(self):
"""Test listing users who are blocked by the authenticated user
succeeds"""
self.api.list_blocks()
@unittest.skip('skipping non-updated test')
def test_list_block_ids(self):
"""Test listing user ids who are blocked by the authenticated user
succeeds"""
self.api.list_block_ids()
@unittest.skip('skipping non-updated test')
def test_create_block(self):
"""Test blocking a user succeeds"""
self.api.create_block(screen_name='justinbieber')
@unittest.skip('skipping non-updated test')
def test_destroy_block(self):
"""Test unblocking a user succeeds"""
self.api.destroy_block(screen_name='justinbieber')
@unittest.skip('skipping non-updated test')
def test_lookup_user(self):
"""Test listing a number of user objects succeeds"""
self.api.lookup_user(screen_name='twitter,justinbieber')
@unittest.skip('skipping non-updated test')
def test_show_user(self):
"""Test showing one user works"""
self.api.show_user(screen_name='twitter')
@unittest.skip('skipping non-updated test')
def test_search_users(self):
"""Test that searching for users succeeds"""
self.api.search_users(q='Twitter API')
@unittest.skip('skipping non-updated test')
def test_get_contributees(self):
"""Test returning list of accounts the specified user can
contribute to succeeds"""
self.api.get_contributees(screen_name='TechCrunch')
@unittest.skip('skipping non-updated test')
def test_get_contributors(self):
"""Test returning list of accounts that contribute to the