node-telegram-bots-api 0.0.1-security → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of node-telegram-bots-api might be problematic. Click here for more details.
- package/.github/ISSUE_TEMPLATE.md +68 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +23 -0
- package/CHANGELOG.md +475 -0
- package/CODE_OF_CONDUCT.md +74 -0
- package/CONTRIBUTING.md +45 -0
- package/LICENSE.md +21 -0
- package/README.md +128 -3
- package/doc/api.hbs +19 -0
- package/doc/api.md +0 -0
- package/doc/experimental.md +28 -0
- package/doc/help.md +151 -0
- package/doc/tutorials.md +12 -0
- package/doc/usage.md +269 -0
- package/index.js +13 -0
- package/lib/errors.js +104 -0
- package/lib/telegram.js +1356 -0
- package/lib/telegramPolling.js +237 -0
- package/lib/telegramWebHook.js +187 -0
- package/lib/utils.js +7 -0
- package/package.json +77 -3
- package/src/errors.js +65 -0
- package/src/telegram.js +2998 -0
- package/src/telegramPolling.js +202 -0
- package/src/telegramWebHook.js +158 -0
- package/src/utils.js +3 -0
package/lib/errors.js
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
4
|
+
|
5
|
+
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
|
6
|
+
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
8
|
+
|
9
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
10
|
+
|
11
|
+
exports.BaseError = (function (_Error) {
|
12
|
+
_inherits(BaseError, _Error);
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @class BaseError
|
16
|
+
* @constructor
|
17
|
+
* @private
|
18
|
+
* @param {String} code Error code
|
19
|
+
* @param {String} message Error message
|
20
|
+
*/
|
21
|
+
|
22
|
+
function BaseError(code, message) {
|
23
|
+
_classCallCheck(this, BaseError);
|
24
|
+
|
25
|
+
_get(Object.getPrototypeOf(BaseError.prototype), 'constructor', this).call(this, code + ': ' + message);
|
26
|
+
this.code = code;
|
27
|
+
}
|
28
|
+
|
29
|
+
_createClass(BaseError, [{
|
30
|
+
key: 'toJSON',
|
31
|
+
value: function toJSON() {
|
32
|
+
return {
|
33
|
+
code: this.code,
|
34
|
+
message: this.message
|
35
|
+
};
|
36
|
+
}
|
37
|
+
}]);
|
38
|
+
|
39
|
+
return BaseError;
|
40
|
+
})(Error);
|
41
|
+
|
42
|
+
exports.FatalError = (function (_exports$BaseError) {
|
43
|
+
_inherits(FatalError, _exports$BaseError);
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Fatal Error. Error code is `"EFATAL"`.
|
47
|
+
* @class FatalError
|
48
|
+
* @constructor
|
49
|
+
* @param {String|Error} data Error object or message
|
50
|
+
*/
|
51
|
+
|
52
|
+
function FatalError(data) {
|
53
|
+
_classCallCheck(this, FatalError);
|
54
|
+
|
55
|
+
var error = typeof data === 'string' ? null : data;
|
56
|
+
var message = error ? error.message : data;
|
57
|
+
_get(Object.getPrototypeOf(FatalError.prototype), 'constructor', this).call(this, 'EFATAL', message);
|
58
|
+
if (error) this.stack = error.stack;
|
59
|
+
}
|
60
|
+
|
61
|
+
return FatalError;
|
62
|
+
})(exports.BaseError);
|
63
|
+
|
64
|
+
exports.ParseError = (function (_exports$BaseError2) {
|
65
|
+
_inherits(ParseError, _exports$BaseError2);
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Error during parsing. Error code is `"EPARSE"`.
|
69
|
+
* @class ParseError
|
70
|
+
* @constructor
|
71
|
+
* @param {String} message Error message
|
72
|
+
* @param {http.IncomingMessage} response Server response
|
73
|
+
*/
|
74
|
+
|
75
|
+
function ParseError(message, response) {
|
76
|
+
_classCallCheck(this, ParseError);
|
77
|
+
|
78
|
+
_get(Object.getPrototypeOf(ParseError.prototype), 'constructor', this).call(this, 'EPARSE', message);
|
79
|
+
this.response = response;
|
80
|
+
}
|
81
|
+
|
82
|
+
return ParseError;
|
83
|
+
})(exports.BaseError);
|
84
|
+
|
85
|
+
exports.TelegramError = (function (_exports$BaseError3) {
|
86
|
+
_inherits(TelegramError, _exports$BaseError3);
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Error returned from Telegram. Error code is `"ETELEGRAM"`.
|
90
|
+
* @class TelegramError
|
91
|
+
* @constructor
|
92
|
+
* @param {String} message Error message
|
93
|
+
* @param {http.IncomingMessage} response Server response
|
94
|
+
*/
|
95
|
+
|
96
|
+
function TelegramError(message, response) {
|
97
|
+
_classCallCheck(this, TelegramError);
|
98
|
+
|
99
|
+
_get(Object.getPrototypeOf(TelegramError.prototype), 'constructor', this).call(this, 'ETELEGRAM', message);
|
100
|
+
this.response = response;
|
101
|
+
}
|
102
|
+
|
103
|
+
return TelegramError;
|
104
|
+
})(exports.BaseError);
|