Socket
Socket
Sign inDemoInstall

nestgram

Package Overview
Dependencies
10
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.2.1

dist/classes/Message/Alert.d.ts

5

dist/classes/Api.d.ts

@@ -1,2 +0,2 @@

import { IMessage, ContentTypes, ISendPhotoOptions, IOptions, MessageCreator, Keyboard, IWebhookConfig, IDeleteWebhookConfig, IUser } from '..';
import { IMessage, ContentTypes, ISendPhotoOptions, IOptions, MessageCreator, Keyboard, IWebhookConfig, IDeleteWebhookConfig, IUser, IAnswerCallbackQueryOptions } from '..';
import { Media } from './Media';

@@ -14,2 +14,5 @@ export declare class Api {

sendPhoto(chatId: string | number, photo: Media, keyboard?: Keyboard | null, moreOptions?: ISendPhotoOptions): Promise<IMessage>;
answerCallbackQuery(callback_query_id: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;
alert(callback_query_id: string, text: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;
toast(callback_query_id: string, text: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;
}

@@ -83,4 +83,16 @@ "use strict";

}
answerCallbackQuery(callback_query_id, moreOptions = {}) {
return this.callApi('answerCallbackQuery', {
callback_query_id,
...moreOptions,
});
}
alert(callback_query_id, text, moreOptions = {}) {
return this.answerCallbackQuery(callback_query_id, { text, show_alert: true });
}
toast(callback_query_id, text, moreOptions = {}) {
return this.answerCallbackQuery(callback_query_id, { text, show_alert: false });
}
}
exports.Api = Api;
//# sourceMappingURL=Api.js.map

4

dist/classes/Context/Answer.d.ts

@@ -1,2 +0,2 @@

import { ISendOptions, IMessage, IUpdate, ContentTypes, Keyboard } from '../..';
import { ISendOptions, IMessage, IUpdate, ContentTypes, Keyboard, IAnswerCallbackQueryOptions } from '../..';
import { MessageCreator } from '../Message';

@@ -10,2 +10,4 @@ import { Api } from '../Api';

send(content: MessageCreator | ContentTypes, keyboard?: Keyboard | null, moreOptions?: ISendOptions): Promise<IMessage>;
alert(text: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;
toast(text: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;
}

@@ -19,4 +19,16 @@ "use strict";

}
alert(text, moreOptions = {}) {
const queryId = Filter_1.Filter.getCallbackQueryId(this.update);
if (!queryId)
throw (0, logger_1.error)(`Can't find queryId from update`);
return this.api.alert(queryId, text, moreOptions);
}
toast(text, moreOptions = {}) {
const queryId = Filter_1.Filter.getCallbackQueryId(this.update);
if (!queryId)
throw (0, logger_1.error)(`Can't find queryId from update`);
return this.api.toast(queryId, text, moreOptions);
}
}
exports.Answer = Answer;
//# sourceMappingURL=Answer.js.map

@@ -5,2 +5,3 @@ import { IMessage, IMessageEntity, IUpdate, MessageEntityTypes } from '../..';

static getChatId(update: IUpdate): number | string | undefined;
static getCallbackQueryId(update: IUpdate): string | undefined;
static getMessage(update: IUpdate): IMessage | undefined;

@@ -7,0 +8,0 @@ static getEntity(update: IUpdate, entityType: MessageEntityTypes): IMessageEntity | undefined;

@@ -9,2 +9,6 @@ "use strict";

}
static getCallbackQueryId(update) {
var _a;
return (_a = update.callback_query) === null || _a === void 0 ? void 0 : _a.id;
}
static getMessage(update) {

@@ -11,0 +15,0 @@ var _a;

@@ -6,2 +6,3 @@ "use strict";

const Filter_1 = require("../Context/Filter");
const Message_1 = require("../Message");
const logger_1 = require("../../logger");

@@ -14,11 +15,11 @@ class Handler {

}
getNextFunction(update, answer, params, middlewares, index, handler, failFunction) {
const nextFunction = middlewares[++index];
getNextFunction(update, answer, params, middlewares, middlewareIndex, handlerIndex, handler, failFunction) {
const nextFunction = middlewares[++middlewareIndex];
return () => {
if (this.logging)
(0, logger_1.log)('blue', 'Calling next middleware', `(${update.update_id})`.grey);
return (nextFunction || handler)(update, answer, params, this.getNextFunction(update, answer, params, middlewares, index, handler, failFunction.bind(null, index)), failFunction.bind(null, index));
return (nextFunction || handler)(update, answer, params, this.getNextFunction(update, answer, params, middlewares, middlewareIndex, handlerIndex, handler, failFunction.bind(null, middlewareIndex, handlerIndex)), failFunction.bind(null, middlewareIndex, handlerIndex));
};
}
handleMiddleware(index, update, answer) {
handleMiddleware(index, update, answer, middlewareIndex = 0) {
const handler = this.handlers[index];

@@ -57,12 +58,26 @@ if (!handler)

return;
await answer.send(resultMessageToSend);
let sendMethodKey = 'send';
const answerCallArgs = [];
if (resultMessageToSend instanceof Message_1.MessageCreator) {
if (['alert', 'toast'].includes(resultMessageToSend.sendType)) {
sendMethodKey = resultMessageToSend.sendType;
answerCallArgs.push(resultMessageToSend.content, resultMessageToSend.options);
}
else {
answerCallArgs.push(resultMessageToSend);
}
}
await answer[sendMethodKey](...answerCallArgs);
};
const failNextFunction = (i = index) => {
const failNextFunction = (middlewareIndex, handlerIndex) => {
if (this.logging)
(0, logger_1.log)('blue', 'Middleware called fail function', `(${update.update_id})`.grey);
return this.handleMiddleware(i + 1, update, answer);
if (handler.middlewares[middlewareIndex]) {
return this.handleMiddleware(handlerIndex, update, answer, middlewareIndex);
}
return this.handleMiddleware(handlerIndex + 1, update, answer, 0);
};
if (this.logging)
(0, logger_1.log)('blue', 'Calling first middleware/handler', `(${update.update_id})`.grey);
handler.middlewares[0](update, answer, params, this.getNextFunction(update, answer, params, handler.middlewares, 0, baseNextFunction, failNextFunction) || baseNextFunction, failNextFunction);
handler.middlewares[middlewareIndex](update, answer, params, this.getNextFunction(update, answer, params, handler.middlewares, middlewareIndex, index, baseNextFunction, failNextFunction) || baseNextFunction, failNextFunction.bind(null, middlewareIndex + 1, index));
const isContinue = Reflect.getMetadata('continue', handler.controller[handler.methodKey]);

@@ -69,0 +84,0 @@ if (!isContinue)

import { Keyboard } from '../Keyboard/Keyboard';
import { ContentTypes } from '../../types';
import { ContentTypes, SendTypes } from '../../types';
export declare class MessageCreator {

@@ -8,3 +8,4 @@ readonly content: ContentTypes;

type: 'photo' | 'text';
sendType: SendTypes;
constructor(content: ContentTypes, keyboard?: Keyboard | null, options?: any);
}

@@ -1,2 +0,3 @@

export declare function Entity(entity: string): (target: any, propertyKey: string, parameterIndex: number) => any;
import { MessageEntityTypes } from '../../types';
export declare function Entity(entity: MessageEntityTypes): (target: any, propertyKey: string, parameterIndex: number) => any;
export declare const Text: () => ParameterDecorator;

@@ -3,0 +4,0 @@ export declare const Answ: () => ParameterDecorator;

@@ -24,1 +24,10 @@ import { IMessageEntity } from './update.types';

}
export interface IAnswerCallbackQueryOptions {
text?: string;
show_alert?: boolean;
url?: string;
cache_time?: number;
}
export interface IAnswerCallbackQueryFetchOptions extends IAnswerCallbackQueryOptions {
callback_query_id: string;
}

@@ -10,1 +10,2 @@ export * from './api.types';

export * from './update.types';
export * from './message-creator.types';

@@ -26,2 +26,3 @@ "use strict";

__exportStar(require("./update.types"), exports);
__exportStar(require("./message-creator.types"), exports);
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

export declare type SendTypes = 'send';
export declare type SendTypes = 'send' | 'alert' | 'toast';
{
"name": "nestgram",
"description": "Framework for working with Telegram Bot API on TypeScript like Nest.js",
"version": "1.2.0",
"version": "1.2.1",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "types": "dist/index.d.ts",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc