@apidog/multibot-sdk-ts
Advanced tools
Comparing version 0.0.8-4 to 0.0.8-5
@@ -152,3 +152,3 @@ "use strict"; | ||
} | ||
resolve(); | ||
resolve(void 0); | ||
response.forEach(this.handleUpdate); | ||
@@ -155,0 +155,0 @@ }); |
@@ -5,3 +5,3 @@ import { Update, Media } from './types'; | ||
import { ArgumentMessage } from '.'; | ||
export declare const enum MatchType { | ||
export declare enum MatchType { | ||
Message = "message", | ||
@@ -29,3 +29,3 @@ MessageEdited = "message_edited", | ||
Game = "game", | ||
VideoNote = "videoNote", | ||
VideoNote = "video_note", | ||
Media = "media" | ||
@@ -32,0 +32,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TelegramMatcher = exports.handleCommand = exports.testCommand = exports.handleInlineQuery = exports.testInlineQuery = exports.handleCallbackQuery = exports.testCallbackQuery = exports.handleChannelPostEdited = exports.testChannelPostEdited = exports.handleChannelPost = exports.testChannelPost = exports.handleMessageEdited = exports.testMessageEdited = exports.handleMessage = exports.testMessage = void 0; | ||
exports.TelegramMatcher = exports.handleCommand = exports.testCommand = exports.handleInlineQuery = exports.testInlineQuery = exports.handleCallbackQuery = exports.testCallbackQuery = exports.handleChannelPostEdited = exports.testChannelPostEdited = exports.handleChannelPost = exports.testChannelPost = exports.handleMessageEdited = exports.testMessageEdited = exports.handleMessage = exports.testMessage = exports.MatchType = void 0; | ||
const utils_1 = require("./utils"); | ||
const utils_2 = require("../utils"); | ||
exports.testMessage = update => 'message' in update; | ||
exports.handleMessage = ({ message }) => ({ | ||
var MatchType; | ||
(function (MatchType) { | ||
MatchType["Message"] = "message"; | ||
MatchType["MessageEdited"] = "message_edited"; | ||
MatchType["ChannelPost"] = "channel_post"; | ||
MatchType["ChannelPostEdited"] = "channel_post_edited"; | ||
MatchType["CallbackQuery"] = "callback_query"; | ||
MatchType["InlineQuery"] = "inline_query"; | ||
MatchType["ChosenInlineResult"] = "chosen_inline_result"; | ||
MatchType["Exact"] = "text_exact"; | ||
MatchType["Command"] = "bot_command"; | ||
MatchType["RegExp"] = "regexp"; | ||
MatchType["Photo"] = "photo"; | ||
MatchType["Video"] = "video"; | ||
MatchType["Audio"] = "audio"; | ||
MatchType["Voice"] = "voice"; | ||
MatchType["Animation"] = "animation"; | ||
MatchType["Sticker"] = "sticker"; | ||
MatchType["Location"] = "location"; | ||
MatchType["Document"] = "document"; | ||
MatchType["Venue"] = "venue"; | ||
MatchType["Contact"] = "contact"; | ||
MatchType["Poll"] = "poll"; | ||
MatchType["Game"] = "game"; | ||
MatchType["VideoNote"] = "video_note"; | ||
MatchType["Media"] = "media"; | ||
})(MatchType = exports.MatchType || (exports.MatchType = {})); | ||
const testMessage = update => 'message' in update; | ||
exports.testMessage = testMessage; | ||
const handleMessage = ({ message }) => ({ | ||
message: message, | ||
@@ -12,4 +40,6 @@ chat: message.chat, | ||
}); | ||
exports.testMessageEdited = update => 'message_edited' in update; | ||
exports.handleMessageEdited = ({ edited_message }) => ({ | ||
exports.handleMessage = handleMessage; | ||
const testMessageEdited = update => 'message_edited' in update; | ||
exports.testMessageEdited = testMessageEdited; | ||
const handleMessageEdited = ({ edited_message }) => ({ | ||
message: edited_message, | ||
@@ -19,11 +49,20 @@ chat: edited_message.chat, | ||
}); | ||
exports.testChannelPost = update => 'channel_post' in update; | ||
exports.handleChannelPost = update => update.channel_post; | ||
exports.testChannelPostEdited = update => 'edited_channel_post' in update; | ||
exports.handleChannelPostEdited = update => update.edited_channel_post; | ||
exports.testCallbackQuery = update => 'callback_query' in update; | ||
exports.handleCallbackQuery = update => update.callback_query; | ||
exports.testInlineQuery = update => 'inline_query' in update; | ||
exports.handleInlineQuery = update => update.inline_query; | ||
exports.testCommand = update => { | ||
exports.handleMessageEdited = handleMessageEdited; | ||
const testChannelPost = update => 'channel_post' in update; | ||
exports.testChannelPost = testChannelPost; | ||
const handleChannelPost = update => update.channel_post; | ||
exports.handleChannelPost = handleChannelPost; | ||
const testChannelPostEdited = update => 'edited_channel_post' in update; | ||
exports.testChannelPostEdited = testChannelPostEdited; | ||
const handleChannelPostEdited = update => update.edited_channel_post; | ||
exports.handleChannelPostEdited = handleChannelPostEdited; | ||
const testCallbackQuery = update => 'callback_query' in update; | ||
exports.testCallbackQuery = testCallbackQuery; | ||
const handleCallbackQuery = update => update.callback_query; | ||
exports.handleCallbackQuery = handleCallbackQuery; | ||
const testInlineQuery = update => 'inline_query' in update; | ||
exports.testInlineQuery = testInlineQuery; | ||
const handleInlineQuery = update => update.inline_query; | ||
exports.handleInlineQuery = handleInlineQuery; | ||
const testCommand = update => { | ||
if (!exports.testMessage(update)) { | ||
@@ -35,3 +74,4 @@ return false; | ||
}; | ||
exports.handleCommand = ({ message }) => { | ||
exports.testCommand = testCommand; | ||
const handleCommand = ({ message }) => { | ||
const entities = utils_1.extractEntites(message); | ||
@@ -50,2 +90,3 @@ if (!message.entities.length) { | ||
}; | ||
exports.handleCommand = handleCommand; | ||
/* | ||
@@ -75,24 +116,24 @@ export const checkMatchRegExp: MatchCheck<RegExpMatch> = (message, rule) => { | ||
super(bot, [ | ||
{ type: "message" /* Message */, test: exports.testMessage, handle: exports.handleMessage }, | ||
{ type: "message_edited" /* MessageEdited */, test: exports.testMessageEdited, handle: exports.handleMessageEdited }, | ||
{ type: "channel_post" /* ChannelPost */, test: exports.testChannelPost, handle: exports.handleChannelPost }, | ||
{ type: "channel_post_edited" /* ChannelPostEdited */, test: exports.testChannelPostEdited, handle: exports.handleChannelPostEdited }, | ||
{ type: "callback_query" /* CallbackQuery */, test: exports.testCallbackQuery, handle: exports.handleCallbackQuery }, | ||
{ type: "inline_query" /* InlineQuery */, test: exports.testInlineQuery, handle: exports.handleInlineQuery }, | ||
{ type: MatchType.Message, test: exports.testMessage, handle: exports.handleMessage }, | ||
{ type: MatchType.MessageEdited, test: exports.testMessageEdited, handle: exports.handleMessageEdited }, | ||
{ type: MatchType.ChannelPost, test: exports.testChannelPost, handle: exports.handleChannelPost }, | ||
{ type: MatchType.ChannelPostEdited, test: exports.testChannelPostEdited, handle: exports.handleChannelPostEdited }, | ||
{ type: MatchType.CallbackQuery, test: exports.testCallbackQuery, handle: exports.handleCallbackQuery }, | ||
{ type: MatchType.InlineQuery, test: exports.testInlineQuery, handle: exports.handleInlineQuery }, | ||
// { type: MatchType.Exact, test: testExactText, handle: handleExactText }, | ||
{ type: "bot_command" /* Command */, test: exports.testCommand, handle: exports.handleCommand }, | ||
Object.assign({ type: "photo" /* Photo */ }, media('photo')), | ||
Object.assign({ type: "video" /* Video */ }, media('video')), | ||
Object.assign({ type: "audio" /* Audio */ }, media('audio')), | ||
Object.assign({ type: "document" /* Document */ }, media('document')), | ||
Object.assign({ type: "animation" /* Animation */ }, media('animation')), | ||
Object.assign({ type: "voice" /* Voice */ }, media('voice')), | ||
Object.assign({ type: "sticker" /* Sticker */ }, media('sticker')), | ||
Object.assign({ type: "location" /* Location */ }, media('location')), | ||
Object.assign({ type: "venue" /* Venue */ }, media('venue')), | ||
Object.assign({ type: "contact" /* Contact */ }, media('contact')), | ||
Object.assign({ type: "poll" /* Poll */ }, media('poll')), | ||
Object.assign({ type: "game" /* Game */ }, media('game')), | ||
{ type: MatchType.Command, test: exports.testCommand, handle: exports.handleCommand }, | ||
Object.assign({ type: MatchType.Photo }, media('photo')), | ||
Object.assign({ type: MatchType.Video }, media('video')), | ||
Object.assign({ type: MatchType.Audio }, media('audio')), | ||
Object.assign({ type: MatchType.Document }, media('document')), | ||
Object.assign({ type: MatchType.Animation }, media('animation')), | ||
Object.assign({ type: MatchType.Voice }, media('voice')), | ||
Object.assign({ type: MatchType.Sticker }, media('sticker')), | ||
Object.assign({ type: MatchType.Location }, media('location')), | ||
Object.assign({ type: MatchType.Venue }, media('venue')), | ||
Object.assign({ type: MatchType.Contact }, media('contact')), | ||
Object.assign({ type: MatchType.Poll }, media('poll')), | ||
Object.assign({ type: MatchType.Game }, media('game')), | ||
// { type: MatchType.VideoNote, ...media('video_note') }, | ||
{ type: "media" /* Media */, test: testMedia, handle: handleMedia }, | ||
{ type: MatchType.Media, test: testMedia, handle: handleMedia }, | ||
]); | ||
@@ -99,0 +140,0 @@ this.getMatches = (update) => this.rules.filter(rule => rule.test(update)); |
@@ -33,3 +33,3 @@ "use strict"; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
exports.sanitizeMarkdownV2Props = (props, key = 'text') => { | ||
const sanitizeMarkdownV2Props = (props, key = 'text') => { | ||
if (props.parse_mode === "MarkdownV2" /* MarkdownV2 */) { | ||
@@ -40,2 +40,3 @@ props[key] = MarkdownV2.sanitizeString(props[key]); | ||
}; | ||
exports.sanitizeMarkdownV2Props = sanitizeMarkdownV2Props; | ||
//# sourceMappingURL=md-v2.js.map |
@@ -13,5 +13,6 @@ "use strict"; | ||
exports.fastReply = void 0; | ||
exports.fastReply = (bot, message, text, options = {}) => __awaiter(void 0, void 0, void 0, function* () { | ||
const fastReply = (bot, message, text, options = {}) => __awaiter(void 0, void 0, void 0, function* () { | ||
return bot.request('sendMessage', Object.assign({ chat_id: message.chat.id, text }, options)); | ||
}); | ||
exports.fastReply = fastReply; | ||
//# sourceMappingURL=reply.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractEntites = void 0; | ||
exports.extractEntites = ({ text, caption, entities, caption_entities }) => { | ||
const extractEntites = ({ text, caption, entities, caption_entities }) => { | ||
const items = entities || caption_entities || []; | ||
@@ -9,2 +9,3 @@ const str = text || caption || ''; | ||
}; | ||
exports.extractEntites = extractEntites; | ||
//# sourceMappingURL=text-entites.js.map |
@@ -13,3 +13,4 @@ "use strict"; | ||
exports.delay = void 0; | ||
exports.delay = (ms) => __awaiter(void 0, void 0, void 0, function* () { return new Promise(resolve => setTimeout(resolve, ms)); }); | ||
const delay = (ms) => __awaiter(void 0, void 0, void 0, function* () { return new Promise(resolve => setTimeout(resolve, ms)); }); | ||
exports.delay = delay; | ||
//# sourceMappingURL=delay.js.map |
@@ -90,3 +90,3 @@ "use strict"; | ||
this.server.ts = response.ts; | ||
resolve(); | ||
resolve(void 0); | ||
response.updates.forEach(this.handleUpdate); | ||
@@ -93,0 +93,0 @@ }); |
@@ -16,4 +16,5 @@ "use strict"; | ||
const fetcherUser = (message, bot) => (fields) => __awaiter(void 0, void 0, void 0, function* () { return utils_1.getSender(bot, message, fields); }); | ||
exports.testMessage = update => update.type == 'message_new'; | ||
exports.handleMessage = ({ object }, bot) => { | ||
const testMessage = update => update.type == 'message_new'; | ||
exports.testMessage = testMessage; | ||
const handleMessage = ({ object }, bot) => { | ||
if ('message' in object) { | ||
@@ -33,17 +34,24 @@ return { | ||
}; | ||
exports.testMessageEdit = update => update.type === 'message_edit'; | ||
exports.handleMessageEdit = ({ object }, bot) => ({ | ||
exports.handleMessage = handleMessage; | ||
const testMessageEdit = update => update.type === 'message_edit'; | ||
exports.testMessageEdit = testMessageEdit; | ||
const handleMessageEdit = ({ object }, bot) => ({ | ||
message: object, | ||
getSender: fetcherUser(object, bot), | ||
}); | ||
exports.testMessageAllow = update => update.type === 'message_allow'; | ||
exports.handleMessageAllow = (update, bot) => ({ | ||
exports.handleMessageEdit = handleMessageEdit; | ||
const testMessageAllow = update => update.type === 'message_allow'; | ||
exports.testMessageAllow = testMessageAllow; | ||
const handleMessageAllow = (update, bot) => ({ | ||
event: update.object, | ||
getUser: () => utils_1.getUser(bot, update.object.user_id) | ||
}); | ||
exports.testMessageDeny = update => update.type === 'message_deny'; | ||
exports.handleMessageDeny = (update, bot) => ({ | ||
exports.handleMessageAllow = handleMessageAllow; | ||
const testMessageDeny = update => update.type === 'message_deny'; | ||
exports.testMessageDeny = testMessageDeny; | ||
const handleMessageDeny = (update, bot) => ({ | ||
event: update.object, | ||
getUser: () => utils_1.getUser(bot, update.object.user_id), | ||
}); | ||
exports.handleMessageDeny = handleMessageDeny; | ||
class VkMatcher extends matcher_1.Matcher { | ||
@@ -50,0 +58,0 @@ constructor(bot) { |
@@ -13,3 +13,3 @@ "use strict"; | ||
exports.getSender = exports.getUser = void 0; | ||
exports.getUser = (bot, userId, fields) => __awaiter(void 0, void 0, void 0, function* () { | ||
const getUser = (bot, userId, fields) => __awaiter(void 0, void 0, void 0, function* () { | ||
const users = yield bot.request('users.get', { | ||
@@ -21,3 +21,5 @@ user_ids: userId, | ||
}); | ||
exports.getSender = (bot, message, fields) => __awaiter(void 0, void 0, void 0, function* () { return exports.getUser(bot, message.from_id, fields); }); | ||
exports.getUser = getUser; | ||
const getSender = (bot, message, fields) => __awaiter(void 0, void 0, void 0, function* () { return exports.getUser(bot, message.from_id, fields); }); | ||
exports.getSender = getSender; | ||
//# sourceMappingURL=user.js.map |
{ | ||
"name": "@apidog/multibot-sdk-ts", | ||
"version": "0.0.8-4", | ||
"version": "0.0.8-5", | ||
"description": "Telegram and VK bot SDK for TypeScript", | ||
@@ -26,15 +26,15 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"axios": "0.19.2", | ||
"axios": "0.21.1", | ||
"form-data": "3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "26.0.15", | ||
"@types/node": "14.14.6", | ||
"@typescript-eslint/eslint-plugin": "4.6.1", | ||
"@typescript-eslint/parser": "4.6.1", | ||
"@types/jest": "26.0.19", | ||
"@types/node": "14.14.16", | ||
"@typescript-eslint/eslint-plugin": "4.11.1", | ||
"@typescript-eslint/parser": "4.11.1", | ||
"dotenv": "8.2.0", | ||
"eslint": "7.13.0", | ||
"eslint": "7.16.0", | ||
"jest": "26.6.3", | ||
"ts-jest": "26.4.4", | ||
"typescript": "4.0.5" | ||
"typescript": "4.1.3" | ||
}, | ||
@@ -41,0 +41,0 @@ "bugs": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155300
114
2325
+ Addedaxios@0.21.1(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removedaxios@0.19.2(transitive)
- Removedfollow-redirects@1.5.10(transitive)
Updatedaxios@0.21.1