Open tehranian opened 7 years ago
@tehranian , i got the same problem.
It is possible to send file by using direct api requests with 'files.upload' method. All you need is channel id.
import requests channel_id = message.channel._body['id'] api_token = %your_token_here% file_params = { 'token' : api_token ,'initial_comment': 'comment' ,'title': 'file_title' ,'channels': channel_id } file_object = { 'file': open(%path_to_file%, 'rb') } requests.post('https://slack.com/api/files.upload', params = file_params, files = file_object)
@elv1z Yea, that'll work. Kind of annoying to have to use requests
to POST to a URL, deal with API token, etc. I was thinking to grab the slackclient object at message._client
and use that to POST.
I believe this is a dupe of #61. We have a list of users and channels that's populated only once, on bot start. If you get added to a new channel or a new user is added, various things break. Is the channel/group in question new, @tehranian?
Hi @jtatum ,
Yes - The channel/groups in question were new, and yes - Looking through the code, that was my assessment as well: That the list of uses & channels is populated once, upon startup.
Thanks! Dan
Trace:
I'm trying to call
message.channel.upload_file()
and it occasionally fails with a KeyError. This seems to happen when a user is talking directly to the Bot (ex: a 1:1, private conversation). It does not seem to happen in a public channel.Let me know if there is any further info I can provide. Thanks!