Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slack api returns `is_bot`: False for a bot. How else to check if an user is bot?

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?

like image 655
Prashanth Avatar asked Dec 24 '22 23:12

Prashanth


1 Answers

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.

like image 52
Erik Kalkoken Avatar answered Dec 31 '22 00:12

Erik Kalkoken