发布" 0"通过`slacker`和Slack API来松弛通道

时间:2015-12-02 04:27:16

标签: python slack-api slack

我试图通过slacker包(版本0.8.6)自动将一些数字发布到我的松弛通道。有时需要打印的数字是0,但我发现发布0"0"会给我一个错误...

from slacker import Slacker
API_TOKEN = XXXXXXXXXX # I load in my api token from an environment variable
slack = Slacker(API_TOKEN)
channel = '#test-channel'
message = "0"
slack.chat.post_message(channel, message, parse='full')

我收到此错误:slacker.Error: no_text

这是我的代码slacker或Slack API本身的错误吗?

完整堆栈跟踪:

Traceback (most recent call last):
  File "field-utils/fieldutils/slack.py", line 56, in <module>
    slack.chat.post_message(channel, message, parse='full')
  File "/Users/pedro/tools/slack-bot/venv/lib/python2.7/site-packages/slacker/__init__.py", line 257, in post_message
    'icon_emoji': icon_emoji
  File "/Users/pedro/tools/slack-bot/venv/lib/python2.7/site-packages/slacker/__init__.py", line 69, in post
    return self._request(requests.post, api, **kwargs)
  File "/Users/pedro/tools/slack-bot/venv/lib/python2.7/site-packages/slacker/__init__.py", line 61, in _request
    raise Error(response.error)
slacker.Error: no_text

1 个答案:

答案 0 :(得分:2)

我转载了你的问题。我正在使用该消息查看Slackerseems like the Slack API is returning the error

尝试:message = '0\n'(这是一个愚蠢的黑客!但没有其他工作)

Slack桌面应用程序似乎将其呈现为您发送0