You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
GochoMugo 1169f8e430
chore: Use npm script prepublishOnly instead of deprecated prepublish
8 years ago
.github chore: Update npm script `gen-doc` to `doc` 8 years ago
doc chore/deps: Update dependencies 8 years ago
examples test: Fix previously-uncaught lint errors 8 years ago
src doc: Improve deprecation messages 8 years ago
test src/telegram: Add TelegramBot#sendMediaGroup() 8 years ago
.babelrc Babel compile ES2015 to ES5 for publishing, support for old NodeJS versions. JSDoc can't parse class-properties, generate lib-doc. Run tests against lib. #90 10 years ago
.editorconfig refactor: rewrite to babel, es6 & eslint 10 years ago
.eslintignore refactor: rewrite to babel, es6 & eslint 10 years ago
.eslintrc refactor: rewrite to babel, es6 & eslint 10 years ago
.gitignore chore: Ignore package lock file 8 years ago
.npmignore Deprecate support for Node.js v0.12 9 years ago
.travis.yml test: Disable tests on Node.js v0.12 8 years ago
CHANGELOG.md chore/deps: Update dependencies 8 years ago
CODE_OF_CONDUCT.md doc: Improve project documentation 9 years ago
CONTRIBUTING.md chore: Update npm script `gen-doc` to `doc` 8 years ago
LICENSE.md docs: Docs improvements (#291) 9 years ago
README.md doc: Showcase and update contributor list 8 years ago
index.js src: Load transpiled code for Node 5 9 years ago
package.json chore: Use npm script prepublishOnly instead of deprecated prepublish 8 years ago

README.md

Node.js Telegram Bot API

Bot API Build Status Build status Coverage Status bitHound Score https://telegram.me/node_telegram_bot_api https://telegram.me/Yago_Perez

Node.js module to interact with official Telegram Bot API. A bot token is required and can be obtained by talking to @botfather.

Install

npm install --save node-telegram-bot-api

Usage

const TelegramBot = require('node-telegram-bot-api');

// replace the value below with the Telegram token you receive from @BotFather
const token = 'YOUR_TELEGRAM_BOT_TOKEN';

// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot(token, {polling: true});

// Matches "/echo [whatever]"
bot.onText(/\/echo (.+)/, (msg, match) => {
  // 'msg' is the received Message from Telegram
  // 'match' is the result of executing the regexp above on the text content
  // of the message

  const chatId = msg.chat.id;
  const resp = match[1]; // the captured "whatever"

  // send back the matched "whatever" to the chat
  bot.sendMessage(chatId, resp);
});

// Listen for any kind of message. There are different kinds of
// messages.
bot.on('message', (msg) => {
  const chatId = msg.chat.id;

  // send a message to the chat acknowledging receipt of their message
  bot.sendMessage(chatId, 'Received your message');
});

Documentation

Note: Development is done against the master branch. Code for the latest release resides on the release branch Experimental features reside on the experimental branch.

Community

We thank all the developers in the Open-Source community who continuously take their time and effort in advancing this project. See our list of contributors.

We have a Telegram channel where we post updates on the Project. Head over and subscribe!

Some things built using this library that might interest you:

License

The MIT License (MIT)

Copyright © 2017 Yago