Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Snippets to Gist when passed to IRC #140

Open
voycey opened this issue Jul 5, 2016 · 4 comments
Open

Code Snippets to Gist when passed to IRC #140

voycey opened this issue Jul 5, 2016 · 4 comments

Comments

@voycey
Copy link

voycey commented Jul 5, 2016

One of Slack's outstanding features is the ability to include formatted code snippets, in cases where we have an extended community across IRC and Slack using this plugin when Slack users post code snippets (which we dont want to discourage) - it makes IRC unreadable.

I am happy to contribute to fixing this using the Github public GIST api, but a discussion & some pointers of where to do it would be great :)

@ekmartin
Copy link
Owner

ekmartin commented Jul 5, 2016

Hi, that's a really cool idea! Aren't snippets ignored at the moment though? Since snippet messages have a subtype of file_share they should be ignored by this: https://github.com/ekmartin/slack-irc/blob/master/lib/bot.js#L99

Would love a PR implementing what you're suggesting though. A few quick pointers:
You can either modify the existing message listener to check for messages with the correct subtype (file_share) and the correct file mode (snippet, see https://api.slack.com/types/file), or you could add another listener that listens only for file_shared-events. The latter is probably cleaner, to avoid too much logic in the message listener.

When you've hooked up the listener and verified that the file mode is correct, you'll need to create an anonymous Gist. Doesn't really matter if you do it directly with an API call (with e.g. node-fetch) or if you use something like https://github.com/michael/github - both use promises so it's up to you. After you've received a valid gist url you probably want to notify the IRC channel with the url. The easiest way to do this is just using sendToIRC with the original message object but with a modified text property containing a message and a link to the Gist.

Would be nice with some tests as well. Feel free to ask in the Gitter channel if you have any questions 😀

@voycey
Copy link
Author

voycey commented Jul 5, 2016

Currently ours get pushed through (but I am not 100% sure that it hasnt been modified to do that - I haven't tried out the original as of yet), I just know this is something we need :)

Ill have a look at implementing this in the coming weeks and will fire over PR for it!

@janl
Copy link

janl commented Feb 18, 2018

Somewhat related: it’d be nice if long messages would get truncated on IRC and a message to that effect sent back to the slack user.

@janl
Copy link

janl commented Feb 18, 2018

Has any progress been made on this? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants