0.0.7 • Published 5 years ago

simple-telegram-bot-api v0.0.7

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

Simple Telegram Bot API Wrapper

Installation

# npm
npm install simple-telegram-bot-api --save-dev

# yarn
yarn add simple-telegram-bot-api --dev

Usage

const TelgramBot = require('simple-telegram-bot-api');

const token = 'bot123456789:BBHukdff2134mOYi123asdap7byDwO7dasdasP1231';
const username = 'jarvisbot';
const bot = new TelegramBot(token, username);

// With async/await
(async () => {
  try {
    await bot.sendMessage('123456', 'Hello World with async/await');
    console.log('Message sent')
  } catch (err) {
    console.error(err);
  }
})();

// With Promises
bot.sendMessage('123456', 'Hello World with Promise')
  .then(() => console.log('Message sent'))
  .catch(console.error)

Try out the examples

First you need to install dotenv

# npm
npm install dotenv

# yarn
yarn add dotenv

Create a file named .env in the root directory. The file should have the following values

APIKEY=
BOTUSERNAME=
WEBHOOK_URL=
RECEIVER=

Then run the examples from the root dir

node Examples/sendMessage.js

node Examples/sendPhoto
0.0.7

5 years ago

0.0.62

5 years ago

0.0.61

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago