Slack api返回`is_bot`:机器人为False。如何检查用户是否是机器人?

时间:2016-11-18 14:43:39

标签: python slack-api slack

slackbot可能是亲爱的,但他仍然是机器人不是吗?

使用python-slackclient我做了。 slack_client.api_call("users.list")

users = self.slack_client.api_call("users.list") for member in users["members"]: print(member)

slackbot

打印此内容

{'is_owner': False, 'tz_offset': -28800, 'is_ultra_restricted': False, 'tz': None, 'profile': {'image_48': 'https://a.slack-edge.com/2fac/plugins/slackbot/assets/service_48.png', 'image_192': 'https://a.slack-edge.com/66f9/img/slackbot_192.png', 'avatar_hash': 'sv1444671949', 'fields': None, 'image_32': 'https://a.slack-edge.com/2fac/plugins/slackbot/assets/service_32.png', 'image_512': 'https://a.slack-edge.com/1801/img/slackbot_512.png', 'image_72': 'https://a.slack-edge.com/0180/img/slackbot_72.png', 'image_24': 'https://a.slack-edge.com/0180/img/slackbot_24.png', 'real_name': 'slackbot', 'first_name': 'slackbot', 'last_name': '', 'real_name_normalized': 'slackbot'}, 'status': None, 'team_id': 'T2YJG4LLV', 'name': 'slackbot', 'tz_label': 'Pacific Standard Time', 'is_restricted': False, 'id': 'USLACKBOT', 'color': '757575', 'is_bot': False, 'is_primary_owner': False, 'is_admin': False, 'deleted': False, 'real_name': 'slackbot'}

注意,'is_bot': False。如何可靠地检查用户是否是机器人。我过去常常检查用户个人资料信息中是否有email字段,是吗?

1 个答案:

答案 0 :(得分:4)

对于Slackbot,system-startis_bot是正确的。但是其他机器人falseis_bot

只需通过其ID识别Slackbot,始终为true,其他机器人为USLACKBOT