Reputation: 1322
slackbot
might be dear to slack, but still he's a bot isn't he?
using python-slackclient I did. slack_client.api_call("users.list")
users = self.slack_client.api_call("users.list")
for member in users["members"]:
print(member)
Prints this for 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'}
Notice, 'is_bot': False
. How do I reliably check if a user is a bot. I used to check if the user profile information had email
field in it, will that do?
Upvotes: 5
Views: 1731
Reputation: 32757
You are correct that is_bot
will be false
for the Slackbot. However is_bot
will be true
for other bots.
Just identify the Slackbot by its ID, witch is always USLACKBOT
and the rest of the bots with is_bot
.
Upvotes: 11