From c504fb14f0ea97b26600d564b24778f7e5a58b2d Mon Sep 17 00:00:00 2001 From: Yago Date: Mon, 29 Jun 2015 22:19:19 +0200 Subject: [PATCH] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index a13f4b2..9432040 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,23 @@ [![Build Status](https://travis-ci.org/yagop/telegram-bot-api.svg?branch=master)](https://travis-ci.org/yagop/telegram-bot-api) [![Coverage Status](https://coveralls.io/repos/yagop/telegram-bot-api/badge.svg?branch=develop)](https://coveralls.io/r/yagop/telegram-bot-api?branch=develop) +```sh +npm install node-telegram-bot-api +``` + +```js +var TelegramBot = require('node-telegram-bot-api'); + +var token = 'YOUR_TELEGRAM_BOT_TOKEN'; +// Setup polling way +var bot = new TelegramBot(token, {polling: true}); +bot.on('message', function (msg) { + var chatId = msg.chat.id; + // photo can be: a file path, a stream or a Telegram file_id + var photo = 'bot.gif'; + bot.sendPhoto(chatId, photo, {caption: "I'm a bot!"}); +}); +``` + * * * ## Class: TelegramBot