0.3.0 • Published 4 years ago

node-tamtam-botapi v0.3.0

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

Node.js TamTam Bot API

Bot API Build Status FOSSA Status codecov NPM version NPM download

TamTam channel

Module to interact with official TamTam Bot API.

Install

npm install --save node-tamtam-botapi

Usage

const TamTamBot = require('node-tamtam-botapi');
const express = require('express');
const bodyParser = require('body-parser');

const appName = process.env.HEROKU_APP_NAME || 'HEROKU_APP_NAME';
const path = process.env.HEROKU_APP_PATH || 'HEROKU_APP_PATH';

const config = {
    token: process.env.TOKEN,
    host: process.env.HOST,
    version: process.env.API_VERSION
};

const bot = new TamTamBot(config);
const app = express();
const PORT = process.env.PORT || 3000;

app.use(bodyParser.json());

const subscribeBody = {
    url: `https://${appName}.herokuapp.com/${path}`
};

//Subscribes bot to receive updates via WebHook
bot.subscribe(subscribeBody);

// We are receiving updates at the route below!
app.post(`/${path}`, (req, res) => {
    console.log('Request body: ', req.body);
    bot.webhookUpdateTypeHandler(req.body);
    res.send();
});

// Start Express Server
app.listen(PORT, () => {
    console.log(`Express server is listening on ${PORT}`);
});

const message = {
    text: 'Hello! this is a test message'
};
bot.on('message_created', update => {
    bot.sendMessage(undefined, update.message.recipient.chat_id, message);
});

License

The MIT License (MIT)

Copyright © 2020 vershininivan

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.10-b6

5 years ago

0.1.10-b5

5 years ago

0.1.10-b4

5 years ago

0.1.10-b3

5 years ago

0.1.10-b2

5 years ago

0.1.10-b1

5 years ago

0.1.10

5 years ago

0.1.9-2b

5 years ago

0.1.9-1b

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.7

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