本文整理匯總了Python中Core.Util.UtilBot.is_user_blocked方法的典型用法代碼示例。如果您正苦於以下問題:Python UtilBot.is_user_blocked方法的具體用法?Python UtilBot.is_user_blocked怎麽用?Python UtilBot.is_user_blocked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Core.Util.UtilBot
的用法示例。
在下文中一共展示了UtilBot.is_user_blocked方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: block
# 需要導入模塊: from Core.Util import UtilBot [as 別名]
# 或者: from Core.Util.UtilBot import is_user_blocked [as 別名]
def block(bot, event, username=None, *args):
if not username:
segments = [hangups.ChatMessageSegment("Blocked Users: ", is_bold=True),
hangups.ChatMessageSegment("\n", segment_type=hangups.SegmentType.LINE_BREAK),
hangups.ChatMessageSegment("No users blocked.")]
if len(UtilBot.get_blocked_users_in_conversations(event.conv_id)) > 0:
segments.pop()
for user in event.conv.users:
if UtilBot.is_user_blocked(event.conv_id, user.id_):
segments.append(hangups.ChatMessageSegment(user.full_name))
segments.append(hangups.ChatMessageSegment("\n", segment_type=hangups.SegmentType.LINE_BREAK))
segments.pop()
bot.send_message_segments(event.conv, segments)
return
username_lower = username.strip().lower()
for u in sorted(event.conv.users, key=lambda x: x.full_name.split()[-1]):
if not username_lower in u.full_name.lower() or event.user.is_self:
continue
if u.id_ == event.user.id_:
bot.send_message(event.conv, "Aborting block as it would block calling user. ({})".format(u.full_name))
return
if UtilBot.is_user_blocked(event.conv_id, u.id_):
UtilBot.remove_from_blocklist(event.conv_id, u.id_)
bot.send_message(event.conv, "Unblocked User: {}".format(u.full_name))
return
UtilBot.add_to_blocklist(event.conv_id, u.id_)
bot.send_message(event.conv, "Blocked User: {}".format(u.full_name))
return