无法为在 Slack Bot 中发短信的人打印用户名
unable to print username for person texting in slack bot
如何获取用户名 "Jonh" 而不是 WLLACM2HK?
代码
starterbot_id = web_client.api_call("auth.test")["user_id"]
print("starterbot id------->"+starterbot_id))
以上代码的当前输出
starterbot id------->WLLACM2HK
我希望代码打印如下所示的输出
starterbot id------->Jonh
web_client.api_call("auth.test")
中的数据
{
'ok': True,
'url': 'https: //bby-sandbox-general.slack.com/',
'team': 'SandboxGeneralWorkspace',
'user': 'ipt-autobot',
'team_id': 'TFHGD33RV',
'user_id': 'WLLACM2HK',
'bot_id': 'BLDVB7EKB',
'enterprise_id': 'EFGBDRLNP',
'warning': 'superfluous_charset',
'response_metadata': {
'warnings': [
'superfluous_charset'
]
}
}
我觉得我没有调用正确的 api ,因为我没有看到上面的用户名 json ,用户属性实际上是 slack bot 的名称,我想打印用户谁在 slack 机器人中发短信
正在尝试打印(web_client.users_info(user=user))
{
'ok': True,
'user': {
'id': 'WGUHC67D1',
'team_id': 'TJK2GBSC9',
'name': 'a6002043',
'deleted': False,
'color': 'c386df',
'real_name': 'RaviKanth',
'tz': 'America/Chicago',
'tz_label': 'CentralStandardTime',
'tz_offset': -21600,
'profile': {
'title': 'CW-Other',
'phone': '+15614128585',
'skype': '',
'real_name': 'RaviKanth',
'real_name_normalized': 'RaviKanth',
'display_name': 'RaviKanth',
'display_name_normalized': 'RaviKanth',
'status_text': '',
'status_emoji': '',
'status_expiration': 0,
'avatar_hash': '8f97c61708c1',
'image_original': 'https: //avatars.slack-edge.com/2019-11-27/852421659589_8f97c61708c1553628c8_original.jpg',
'is_custom_image': True,
如何抓取 real_name 值并打印出来?
我正在努力,如果你有 user_id
那么你可以使用 user.info
方法来获取特定的用户信息。
这是一个例子:
如何获取用户名 "Jonh" 而不是 WLLACM2HK?
代码
starterbot_id = web_client.api_call("auth.test")["user_id"]
print("starterbot id------->"+starterbot_id))
以上代码的当前输出
starterbot id------->WLLACM2HK
我希望代码打印如下所示的输出
starterbot id------->Jonh
web_client.api_call("auth.test")
中的数据{
'ok': True,
'url': 'https: //bby-sandbox-general.slack.com/',
'team': 'SandboxGeneralWorkspace',
'user': 'ipt-autobot',
'team_id': 'TFHGD33RV',
'user_id': 'WLLACM2HK',
'bot_id': 'BLDVB7EKB',
'enterprise_id': 'EFGBDRLNP',
'warning': 'superfluous_charset',
'response_metadata': {
'warnings': [
'superfluous_charset'
]
}
}
我觉得我没有调用正确的 api ,因为我没有看到上面的用户名 json ,用户属性实际上是 slack bot 的名称,我想打印用户谁在 slack 机器人中发短信
正在尝试打印(web_client.users_info(user=user))
{
'ok': True,
'user': {
'id': 'WGUHC67D1',
'team_id': 'TJK2GBSC9',
'name': 'a6002043',
'deleted': False,
'color': 'c386df',
'real_name': 'RaviKanth',
'tz': 'America/Chicago',
'tz_label': 'CentralStandardTime',
'tz_offset': -21600,
'profile': {
'title': 'CW-Other',
'phone': '+15614128585',
'skype': '',
'real_name': 'RaviKanth',
'real_name_normalized': 'RaviKanth',
'display_name': 'RaviKanth',
'display_name_normalized': 'RaviKanth',
'status_text': '',
'status_emoji': '',
'status_expiration': 0,
'avatar_hash': '8f97c61708c1',
'image_original': 'https: //avatars.slack-edge.com/2019-11-27/852421659589_8f97c61708c1553628c8_original.jpg',
'is_custom_image': True,
如何抓取 real_name 值并打印出来?
我正在努力,如果你有 user_id
那么你可以使用 user.info
方法来获取特定的用户信息。
这是一个例子: