python-Slack api返回`is_bot`:机器人为False.其他如何检查用户是否是机器人?
作者:互联网
slackbot可能比slack更为珍贵,但他仍然是机器人,不是吗?
使用python-slackclient我做到了. slack_client.api_call(“ users.list”)
用户= self.slack_client.api_call(“ users.list”)
对于用户中的成员[“成员”]:
打印(会员)
为slackbot打印此:
{‘is_owner’:False,’tz_offset’:-28800,’is_ultra_restricted’:False,’tz’:无,’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’:无,’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’:无,’team_id’ :’T2YJG4LLV’,’名称’:’slackbot’,’tz_label’:’太平洋标准时间’,’is_restricted’:False,’id’:’USLACKBOT’,’color’:’757575′,’is_bot’:False ,’is_primary_owner’:False,’is_admin’:False,’deleted’:False,’real_name’:’slackbot’}
注意,’is_bot’:否.如何可靠地检查用户是否是机器人.我曾经检查用户个人资料信息中是否包含电子邮件字段,可以吗?
解决方法:
您是正确的,对于Slackbot is_bot将为false.但是is_bot对于其他bot都是正确的.
只需通过ID标识Slackbot,女巫便始终是USLACKBOT,其余的bot则是is_bot.
标签:slack-api,slack,python 来源: https://codeday.me/bug/20191026/1937044.html