teabot-botan
v1.0.1
Published
Botan.io analytics plugin for TeaBot
Maintainers
Readme
teabot-botan

teabot-botan a Botan.io analytics plugin for TeaBot.
Usage
$ npm install teabot-botan --saveYou also should install TeaBot.
const TeaBot = require('teabot')('TELEGRAM_BOT_TOKEN', 'TELEGRAM_BOT_NAME');
TeaBot.use('analytics', require('teabot-botan')('BOTAN_TOKEN'));
TeaBot.defineCommand(function (dialog, message) {
dialog.sendMessage('Echo: ' + message.text); // all message events will be sent directly to botan.io
});
TeaBot.startPolling();By default analytics is disabled for inline mode, but you can enable it with allowQuery option.
You can use teabot-botan in manual mode with TeaBot.track() method and manualMode option:
TeaBot.use('analytics', require('teabot-botan')('BOTAN_TOKEN', {manualMode: true}));
TeaBot.defineCommand(function (dialog, message) {
dialog.sendMessage('Echo: ' + message.text);
TeaBot.track(dialog.userId, message, message.getCommand());
});Also you can use shortenUrl method, it will create shortened url. shortenUrl is external method for TeaBot, so you should use it by using TeaBot.getPlugin() method:
TeaBot.use('analytics', require('teabot-botan')('BOTAN_TOKEN'));
TeaBot
.defineCommand('/shortenurl', function (dialog, message) {
if (message.getArgument()) {
dialog.performAction('/shortenurl');
} else {
dialog.startAction('/shortenurl').sendMessage('Please, send me the link.');
}
})
.defineCommand(function(dialog, message) {
dialog.sendMessage('Echo: ' + message.text);
});
TeaBot
.defineAction('/shortenurl', function (dialog, message) {
TeaBot.getPlugin('analytics').shortenUrl(dialog.userId, message.getArgument()).then(function (url) {
dialog.endAction().sendMessage(url);
}).catch(TeaBot.error);
});License
The MIT License (MIT) Copyright (c) 2016 Alexey Bystrov
