Created
February 21, 2017 02:33
-
-
Save ardianta/b67caece3b5ded0a4d958c9fed8adcac to your computer and use it in GitHub Desktop.
Hook.io script for telegram bot using Simsimi API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module['exports'] = function iyanChanBot(hook) { | |
| var request = require('request'); | |
| var simiUrl = 'http://sandbox.api.simsimi.com/request.p?key=API_KEY_SIMSIMI&lc=id&ft=1.0&text='+hook.params.message.text; | |
| request(simiUrl, function (error, response, body) { | |
| if (!error && response.statusCode == 200) { | |
| var data = JSON.parse(body); | |
| request.post('https://api.telegram.org/bot' + hook.env.iyan_chan_bot + '/sendMessage') | |
| .form({ | |
| "chat_id": hook.params.message.chat.id, | |
| "text": data.response | |
| }); | |
| } | |
| }); | |
| };` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment