Skip to content

Instantly share code, notes, and snippets.

@yangwao
Created May 17, 2018 07:47
Show Gist options
  • Save yangwao/a1ac30d1bdce2046019216fc5fb21ebc to your computer and use it in GitHub Desktop.
Save yangwao/a1ac30d1bdce2046019216fc5fb21ebc to your computer and use it in GitHub Desktop.
const r2 = require('r2')
const telegramUrl = 'https://api.telegram.org/bot'
const token = '180473239:VHqX8dOnuhGlJXyurVHqX8dO8yhqX8'
/**
* A basic reply bot
* @returns {object}
*/
module.exports = async (context) => {
const m = context.params.message
const data = {
chat_id: m.chat.id,
text: 'you\'ve just sent me: ' + m.text
}
const res = await r2.post(telegramUrl + token + '/sendMessage',
{json: data}).json
return {"statusCode": 200}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment