This commit is contained in:
Lukian LEIZOUR 2022-11-19 01:49:12 +01:00
parent be4fd23bcf
commit 0bd53741af
728 changed files with 86573 additions and 0 deletions

56
node_modules/telegraf/lib/core/helpers/check.js generated vendored Normal file
View file

@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.is2D = exports.hasPropType = exports.hasProp = void 0;
/**
* Checks if a given object has a property with a given name.
*
* Example invocation:
* ```js
* let obj = { 'foo': 'bar', 'baz': () => {} }
* hasProp(obj, 'foo') // true
* hasProp(obj, 'baz') // true
* hasProp(obj, 'abc') // false
* ```
*
* @param obj An object to test
* @param prop The name of the property
*/
function hasProp(obj, prop) {
return obj !== undefined && prop in obj;
}
exports.hasProp = hasProp;
/**
* Checks if a given object has a property with a given name.
* Furthermore performs a `typeof` check on the property if it exists.
*
* Example invocation:
* ```js
* let obj = { 'foo': 'bar', 'baz': () => {} }
* hasPropType(obj, 'foo', 'string') // true
* hasPropType(obj, 'baz', 'function') // true
* hasPropType(obj, 'abc', 'number') // false
* ```
*
* @param obj An object to test
* @param prop The name of the property
* @param type The type the property is expected to have
*/
function hasPropType(obj, prop, type) {
return hasProp(obj, prop) && type === typeof obj[prop];
}
exports.hasPropType = hasPropType;
/**
* Checks if the supplied array has two dimensions or not.
*
* Example invocations:
* is2D([]) // false
* is2D([[]]) // true
* is2D([[], []]) // true
* is2D([42]) // false
*
* @param arr an array with one or two dimensions
*/
function is2D(arr) {
return Array.isArray(arr[0]);
}
exports.is2D = is2D;

13
node_modules/telegraf/lib/core/helpers/compact.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compactOptions = void 0;
function compactOptions(options) {
if (!options) {
return options;
}
const keys = Object.keys(options);
const compactKeys = keys.filter((key) => options[key] !== undefined);
const compactEntries = compactKeys.map((key) => [key, options[key]]);
return Object.fromEntries(compactEntries);
}
exports.compactOptions = compactOptions;

50
node_modules/telegraf/lib/core/helpers/formatting.js generated vendored Normal file
View file

@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.linkOrMention = exports._fmt = exports.FmtString = void 0;
class FmtString {
constructor(text, entities) {
this.text = text;
if (entities) {
this.entities = entities;
// force parse_mode to undefined if entities are present
this.parse_mode = undefined;
}
}
static normalise(content) {
if (typeof content === 'string')
return new FmtString(content);
return content;
}
}
exports.FmtString = FmtString;
function _fmt(kind, opts) {
return function fmt(parts, ...items) {
let text = '';
const entities = [];
parts = typeof parts === 'string' ? [parts] : parts;
for (let i = 0; i < parts.length; i++) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
text += parts[i];
const item = items[i];
if (!item)
continue;
if (typeof item === 'string') {
text += item;
continue;
}
for (const child of item.entities || [])
entities.push({ ...child, offset: text.length + child.offset });
text += item.text;
}
if (kind !== 'very-plain')
entities.unshift({ type: kind, offset: 0, length: text.length, ...opts });
return new FmtString(text, entities.length ? entities : undefined);
};
}
exports._fmt = _fmt;
const linkOrMention = (content, data) => {
const { text, entities = [] } = FmtString.normalise(content);
entities.unshift(Object.assign(data, { offset: 0, length: text.length }));
return new FmtString(text, entities);
};
exports.linkOrMention = linkOrMention;