simion / sublime-slack-integration

A ST3 plugin which sends messages, code selections and files to slack.com channels/groups/users.
http://simionbaws.ro/sublime-text-3-slack-integration-plugin/
GNU General Public License v2.0
70 stars 7 forks source link

Ability to set the type of snippet #1

Open Anahkiasen opened 10 years ago

Anahkiasen commented 10 years ago

In Slack now you can specify the type of the snippet (PHP, JSON, etc). Any way to add a way to set that (or recognize it automatically) when sending files and stuff ?

simion commented 10 years ago

Actually the chat.postMessage method does not have an option to send a code snippet (or i cannot see it).

simion commented 10 years ago

Also when sending files they are recognized automatically by their extension i think.

mattparcher commented 10 years ago

Thanks for the awesome plugin, @simion!

Based on my reading of the files.upload docs at https://api.slack.com/methods/files.upload:

It looks like with files.upload you can specify the filetype, which overrides the automatic filetype generated from the file extension.

It also seems that files.upload would be the right way to send a code snippet—basically sending the currently selected text in Sublime as the "content" of a new file to Slack, and optionally specifiying the filetype of the snippet (especially since filename and title are both optional in the Slack API).

Maybe I’m mistaken? My Python is pretty limited, or else I would try to test this myself.

simion commented 10 years ago

@mattparcher Honestly, I thought about this method, to upload a file containing the current selection and the name of the file you selected code from. This way, you will have automatic syntax highlighting.

As a workaround, I've added "pre" wrappers, temporarily. http://simionbaws.ro/sublime-slack/sublime-slack-preformatted-text/

Soon, i will implement your suggestion.

Thanks for your feedback.