fraschetti / Octoslack

OctoPrint plugin for Slack, Mattermost, Pushbullet, Pushover, Rocket.Chat, Discord, Riot/Matrix, & Microsoft Teams
MIT License
74 stars 34 forks source link

Support for Slack Bot including direct image uploads #22

Closed sillyfrog closed 6 years ago

sillyfrog commented 6 years ago

This PR adds support for the newer Slack Bot (in addition to the other types). The main advantage of this is the ability to upload images directly.

I have also implemented support for updating the progress messages in place, that way someone could have it update every few seconds with out spamming their channel.

Note: I have run "Black" over the code to make it PEP8, so this has resulted in most lines getting changed, even though not that many were - see the individual commits for the code changes.

Thanks!

sillyfrog commented 6 years ago

Hi, maybe I was following the wrong path when figuring out the old code (as you probably know, the Slack API is constantly changing, so I may have made the wrong assumption that the API in use did not support this, I think I was looking at the WebHook API from memory). I couldn't find the process to get the correct Token that worked (due to these changes), so starting playing around with the Bot user, and using the "Bot User OAuth Access Token" (maybe this would have worked, but I hadn't created a Bot user at that stage).

Agreed the image association is not as good (ie: you can't do "attachments" on images to have nicely formatted text in the same way), but like you say, I have a dedicated channel for my printer, so it's much easier than having a third party service.

What do you mean re the file name? There is one place where a "filename" is used, but it's just for the Slack API when a user does a download, it's never actually written to disk (or maybe I'm missing something, if you put the comment on the actual code, GitHub is not making it easy to find :/ ).

Thanks!

sillyfrog commented 6 years ago

Good catch - no clue how I missed that before, but that is sorted now (it was a left over debug line).

Thanks!

sillyfrog commented 6 years ago

I'm pulling this, I'll submit a new one that uses the Slacker module (and no need for a Slack Bot token).