python - 将文件上传到 Slack 在聊天中没有响应
问题描述
我正在尝试txt data
使用此代码发送一些
my_file = {'file' : ('/home/suomi/_data.txt', open('/home/suomi/_data.txt', 'r'), 'txt')}
payload={
"filename":"aaaa.txt",
"token":API_BOT,
"channel":'*my_user_id*',
}
x = requests.post("https://slack.com/api/files.upload", params=payload, files=my_file)
print(x)
print(x.json())
得到这个回应
<Response [200]>
{'ok': True, 'file': {'id': '*private_id*', 'created': 1603941396, 'timestamp': 1603941396, 'name': 'aaaa.txt', 'title': 'aaaa', 'mimetype': 'text/plain', 'filetype': 'text', 'pretty_type': 'pretty text', 'user': '*my private user_id*', 'editable': True, 'size': 18145, 'mode': 'snippet', 'is_external': False, 'external_type': '', 'is_public': False, 'public_url_shared': False, 'display_as_bot': False, 'username': '', 'url_private': '*private url_link*', 'url_private_download': '*private url_link*', 'permalink': '*private url_link*', 'permalink_public': '*private url_link*', 'edit_link': '*private url_link*', 'preview': "*somedata*", 'preview_highlight': '<div class="CodeMirror cm-s-default CodeMirrorServer" oncopy="if(event.clipboardData){event.clipboardData.setData(\'text/plain\',window.getSelection().toString().replace(/\\u200b/g,\'\'));event.preventDefault();event.stopPropagation();}">\n<div class="CodeMirror-code">\n<div><pre>*somedata*</pre></div>\n<div><pre></pre></div>\n<div><pre>*************************************</pre></div>\n<div><pre></pre></div>\n</div>\n</div>\n', 'lines': 131, 'lines_more': 126, 'preview_is_truncated': True, 'comments_count': 0, 'is_starred': False, 'shares': {}, 'channels': [], 'groups': [], 'ims': [], 'has_rich_preview': False}}
里面的值**
由于隐私而被替换。
但我的应用没有收到回复 - 我启用了正确的权限,我可以发送正常的短信。
files:write, channels:history, channels:read, chat:write, groups:history
顺便提一句。我正在尝试向用户发送文件,而不是频道
解决方案
推荐阅读
- django - Django Admin - 根据父值过滤内联内容
- python - Python:将字典键解析为表中的值
- forms - Adobe pdf表单中的中文/日文字符被截断
- reactjs - 当我得到以下符号时,如何在 React 组件中呈现问号
- go - 错误消息:protoc-gen-go:插件失败,状态码为 1
- android - 在 Android Studio 中格式化 SDCARD
- javascript - 条件传递函数作为组件的道具
- reactjs - 从 JSX 转换为 React.createElement
- python - 使用AJAX将值从html模板传递到Django中的views.py
- c++ - Microsoft NTLM (v2) 中的时间戳使用