Skip to content

Instantly share code, notes, and snippets.

@pizzacat83
Created December 4, 2018 04:55
Show Gist options
  • Save pizzacat83/d5ce7f507cfbe9df1605fb159658912a to your computer and use it in GitHub Desktop.
Save pizzacat83/d5ce7f507cfbe9df1605fb159658912a to your computer and use it in GitHub Desktop.
function doPost(e){
console.log(e.parameter.trigger_word);
var slackApp = SlackApp.create(slackAccessToken);
if(e.parameter.trigger_word=="formula:"){
var chId=e.parameter.channel_id;
var query = e.parameter.text.substr(e.parameter.trigger_word.length).trim();
var url="https://chart.googleapis.com/chart?cht=tx&chl="+encodeURIComponent(query.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>'))+"&ts="+String(Date.now());
slackApp.postMessage(chId, url, {'username':'formula','icon_url':"http://icons.iconarchive.com/icons/alecive/flatwoken/512/Apps-Libreoffice-Math-B-icon.png"});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment