本文整理汇总了Python中Core.Util.UtilBot.get_blocked_users_in_conversations方法的典型用法代码示例。如果您正苦于以下问题:Python UtilBot.get_blocked_users_in_conversations方法的具体用法?Python UtilBot.get_blocked_users_in_conversations怎么用?Python UtilBot.get_blocked_users_in_conversations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core.Util.UtilBot
的用法示例。
在下文中一共展示了UtilBot.get_blocked_users_in_conversations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: block
# 需要导入模块: from Core.Util import UtilBot [as 别名]
# 或者: from Core.Util.UtilBot import get_blocked_users_in_conversations [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