Skip to content

Instantly share code, notes, and snippets.

@carlo-colombo
Forked from Marak/echoHttpRequest.js
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save carlo-colombo/b26806b75156effc5069 to your computer and use it in GitHub Desktop.

Select an option

Save carlo-colombo/b26806b75156effc5069 to your computer and use it in GitHub Desktop.
Echo HTTP requests
module['exports'] = function echoHttp (hook) {
hook.debug("Debug messages are sent to the debug console");
hook.debug(hook.params);
hook.debug(hook.req.path);
hook.debug(hook.req.method);
hook.debug(hook.env);
var resp = {
chat_id: hook.params.message.chat.id,
message: "echo: " + hook.params.message.text
}
//var api = 'api.telegram.org/bot118147581:AAHJDImMGI7GiDjD0D_kt68qCjvwG6pRcn0/sendMessage'
//hook.open(api+"?chat_id="+resp.chat_id+"&message=echo:"+resp.message)
hook.open('https://posthere.io/34ed-4c57-bdd9',{
method: 'POST'
}, function(){
hook.res.end(arguments)
})
/* hook.open('https://posthere.io/34ed-4c57-bdd9', {
form: resp,
method: 'POST'
}, function(){
hook.res.end(JSON.stringify(resp))
})
*/
// hook.res.end(JSON.stringify(resp))
//hook.res.end(api+"?chat_id="+resp.chat_id+"&message=echo:"+resp.message);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment