Skip to content
No description, website, or topics provided.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
core
test - add method 'getMessageById' Feb 16, 2020
.gitignore add new tests Jun 19, 2019
.jshintrc some fix and add new method -> getAdmins Oct 23, 2019
.travis.yml update version API to 0.2.0 Dec 17, 2019
README.md - Update README.md Feb 16, 2020
index.js update readme Jul 4, 2019
package-lock.json update version API to 0.2.0 Dec 17, 2019
package.json - Up to BotApi version 0.2.1 Feb 16, 2020

README.md

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 © 2019 vershininivan

You can’t perform that action at this time.