Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

teabot

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

teabot - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

87

lib/chat.js
'use strict';
var Api = require('tg-yarl');
var Action = require('./action');

@@ -13,6 +12,4 @@ var Message = require('./message');

this.action = false;
this.url = ctx.url;
Chat.prototype._putUpdate = ctx._putUpdate.bind(ctx);
Chat.prototype.error = ctx.error.bind(ctx);
Chat.prototype._api = ctx;
}

@@ -50,3 +47,3 @@

}
}.bind(this)).catch(this.error);
}.bind(this)).catch(this._api.error);
};

@@ -66,3 +63,3 @@

this.userData[property] = data;
this._putUpdate(this);
this._api._putUpdate(this);
return this.userData[property];

@@ -85,3 +82,3 @@ } else {

delete this.userData[property];
this._putUpdate(this);
this._api._putUpdate(this);
}

@@ -92,3 +89,3 @@ };

this.userData = {};
this._putUpdate(this);
this._api._putUpdate(this);
};

@@ -99,3 +96,3 @@

this.tempData[property] = data;
this._putUpdate(this);
this._api._putUpdate(this);
return this.tempData[property];

@@ -118,3 +115,3 @@ } else {

delete this.tempData[property];
this._putUpdate(this);
this._api._putUpdate(this);
}

@@ -125,3 +122,3 @@ };

this.tempData = {};
this._putUpdate(this);
this._api._putUpdate(this);
};

@@ -162,3 +159,3 @@

this._putUpdate(this);
this._api._putUpdate(this);
return this;

@@ -177,74 +174,104 @@ };

this.action = false;
this._putUpdate(this);
this._api._putUpdate(this);
return this;
};
Chat.prototype.hideKeyboard = function (selective) {
this._api.hideKeyboard(selective);
return this;
};
Chat.prototype.setKeyboard = function (keyboard, resize, once, selective) {
return Api.prototype.setKeyboard.call(this, keyboard, resize, once, selective);
this._api.setKeyboard(keyboard, resize, once, selective);
return this;
};
Chat.prototype.getUpdates = function (offset, limit, timeout) {
return Api.prototype.getUpdates.call(this, offset, limit, timeout).catch(this.error);
return this._api.getUpdates(offset, limit, timeout).catch(this._api.error);
};
Chat.prototype.setWebhook = function (url, cert) {
return Api.prototype.setWebhook.call(this, url, cert).catch(this.error);
return this._api.setWebhook(url, cert).catch(this._api.error);
};
Chat.prototype.getMe = function () {
return Api.prototype.getMe.call(this).catch(this.error);
return this._api.getMe().catch(this._api.error);
};
Chat.prototype.sendMessage = function (text, options) {
return Api.prototype.sendMessage.call(this, this.chatId, text, options).catch(this.error);
return this._api.sendMessage(this.chatId, text, options).catch(this._api.error);
};
Chat.prototype.forwardMessage = function (fromChatId, messageId, disableNotification) {
return Api.prototype.forwardMessage.call(this, this.chatId, fromChatId, messageId, disableNotification).catch(this.error);
return this._api.forwardMessage(this.chatId, fromChatId, messageId, disableNotification).catch(this._api.error);
};
Chat.prototype.sendPhoto = function (data, options) {
return Api.prototype.sendPhoto.call(this, this.chatId, data, options).catch(this.error);
return this._api.sendPhoto(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendPhotoFromUrl = function (data, options) {
return this._api.sendPhotoFromUrl(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendAudio = function (data, options) {
return Api.prototype.sendAudio.call(this, this.chatId, data, options).catch(this.error);
return this._api.sendAudio(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendAudioFromUrl = function (data, options) {
return this._api.sendAudioFromUrl(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendDocument = function (data, options) {
return Api.prototype.sendDocument.call(this, this.chatId, data, options).catch(this.error);
return this._api.sendDocument(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendDocumentFromUrl = function (data, options) {
return this._api.sendDocumentFromUrl(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendSticker = function (data, options) {
return Api.prototype.sendSticker.call(this, this.chatId, data, options).catch(this.error);
return this._api.sendSticker(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendStickerFromUrl = function (data, options) {
return this._api.sendStickerFromUrl(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendVideo = function (data, options) {
return Api.prototype.sendVideo.call(this, this.chatId, data, options).catch(this.error);
return this._api.sendVideo(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendVideoFromUrl = function (data, options) {
return this._api.sendVideoFromUrl(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendVoice = function (data, options) {
return Api.prototype.sendVoice.call(this, this.chatId, data, options).catch(this.error);
return this._api.sendVoice(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendVoiceFromUrl = function (data, options) {
return this._api.sendVoiceFromUrl(this.chatId, data, options).catch(this._api.error);
};
Chat.prototype.sendLocation = function (lat, lon, options) {
return Api.prototype.sendLocation.call(this, this.chatId, lat, lon, options).catch(this.error);
return this._api.sendLocation(this.chatId, lat, lon, options).catch(this._api.error);
};
Chat.prototype.sendChatAction = function (action) {
return Api.prototype.sendChatAction.call(this, this.chatId, action).catch(this.error);
return this._api.sendChatAction(this.chatId, action).catch(this._api.error);
};
Chat.prototype.getUserProfilePhotos = function (offset, limit) {
return Api.prototype.getUserProfilePhotos.call(this, this.userId, offset, limit).catch(this.error);
return this._api.getUserProfilePhotos(this.userId, offset, limit).catch(this._api.error);
};
Chat.prototype.getFile = function (fileId) {
return Api.prototype.getFile.call(this, fileId).catch(this.error);
return this._api.getFile(fileId).catch(this._api.error);
};
Chat.prototype.downloadFile = function (fileId, path) {
return Api.prototype.downloadFile.call(this, fileId, path).catch(this.error);
return this._api.downloadFile(fileId, path).catch(this._api.error);
};
module.exports = Chat;
'use strict';
var Api = require('tg-yarl');
var crypto = require('crypto');

@@ -13,5 +12,4 @@

this.results = [];
this.url = ctx.url;
Inline.prototype.error = ctx.error.bind(ctx);
Inline.prototype._api = ctx;
}

@@ -134,3 +132,3 @@

Inline.prototype.answerInlineQuery = function (results, options) {
return Api.prototype.answerInlineQuery.call(this, this.query.id, results, options).catch(this.error);
return this._api.answerInlineQuery(this.query.id, results, options).catch(this._api.error);
};

@@ -137,0 +135,0 @@

@@ -30,5 +30,5 @@ 'use strict';

Api.call(this, token);
this.version = VERSION;
this.token = token;
this.url = 'https://api.telegram.org/bot' + token + '/';
name = name.trim();

@@ -52,3 +52,3 @@ this.name = (name[0] === '@') ? name : '@' + name;

Teabot.prototype.__proto__ = Api.prototype;
Teabot.prototype = Object.create(Api.prototype);

@@ -55,0 +55,0 @@ Teabot.prototype._getUpdate = function (dialog) {

{
"name": "teabot",
"author": "Alexey Bystrov <strikeentco@gmail.com>",
"version": "2.0.1",
"version": "2.1.0",
"description": "TeaBot - a way to build interactive Telegram bots.",

@@ -20,2 +20,6 @@ "engines": {

"main": "./main.js",
"files": [
"lib",
"main.js"
],
"repository": {

@@ -30,5 +34,5 @@ "type": "git",

"matcher": "^0.1.1",
"tg-yarl": "~1.1.2"
"tg-yarl": "~1.2.0"
},
"license": "MIT"
}

@@ -28,3 +28,3 @@ teabot

TeaBot.defineCommand(function(dialog, message) {
TeaBot.defineCommand(function (dialog, message) {
dialog.sendMessage('Echo: ' + message.text);

@@ -138,9 +138,9 @@ });

TeaBot
.defineCommand(['/start', '/help'], function(dialog, message) {
.defineCommand(['/start', '/help'], function (dialog, message) {
dialog.sendMessage('Hi there. This is a ' + message.getCommand() + ' command.');
})
.defineCommand('/hi*', function(dialog, message) { // wildcard
.defineCommand('/hi*', function (dialog, message) { // wildcard
dialog.sendMessage('This command ' + message.getCommand() + ', starts with /hi');
})
.defineCommand(function(dialog) {
.defineCommand(function (dialog) {
dialog.sendMessage('Send me /help for more information.');

@@ -162,3 +162,3 @@ });

TeaBot
.defineCommand('/help', function(dialog, message) {
.defineCommand('/help', function (dialog, message) {
if (message.getArgument()) {

@@ -170,3 +170,3 @@ dialog.performAction('/help:1'); // /help argument

})
.defineCommand(function(dialog) {
.defineCommand(function (dialog) {
dialog.sendMessage('Send me /help for more information.');

@@ -176,3 +176,3 @@ });

TeaBot
.defineAction('/help:*', function(dialog) { // wildcard
.defineAction('/help:*', function (dialog) { // wildcard
dialog.endAction().sendMessage('This is ' + dialog.getAction() + ' action'); // if /help was with argument, then /help:1 action, otherwise /help:2

@@ -197,3 +197,3 @@ });

TeaBot
.inlineQuery('tay*', function(query) { // wildcard
.inlineQuery('tay*', function (query) { // wildcard
query

@@ -208,3 +208,3 @@ .addGif(

})
.inlineQuery(function(query) {
.inlineQuery(function (query) {
query

@@ -238,3 +238,3 @@ .addArticles([

TeaBot.defineCommand(function(dialog, message) {
TeaBot.defineCommand(function (dialog, message) {
dialog.sendMessage('Echo: ' + message.text); // all message events will be sent directly to botan.io

@@ -279,4 +279,4 @@ });

TeaBot.defineCommand(function(dialog, message) {
dialog.sendMessage('Echo: ' + message.text).then(function() {
TeaBot.defineCommand(function (dialog, message) {
dialog.sendMessage('Echo: ' + message.text).then(function () {
throw new Error('Test error 1');

@@ -283,0 +283,0 @@ }).catch(TeaBot.error);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc