Socket
Socket
Sign inDemoInstall

nestgram

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestgram - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

dist/classes/Message/Copy.d.ts

4

dist/classes/Api.d.ts

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

import { IMessage, ContentTypes, ISendPhotoOptions, IOptions, MessageCreator, Keyboard, IWebhookConfig, IDeleteWebhookConfig, IUser, IAnswerCallbackQueryOptions, ISendVideoOptions, Video, Photo, Audio, ISendAudioOptions, IFile } from '..';
import { IMessage, ContentTypes, ISendPhotoOptions, IOptions, MessageCreator, Keyboard, IWebhookConfig, IDeleteWebhookConfig, IUser, IAnswerCallbackQueryOptions, ISendVideoOptions, Video, Photo, Audio, ISendAudioOptions, IFile, IForwardMessageOptions, ICopyMessageOptions, IMessageId } from '..';
export declare class Api {

@@ -20,2 +20,4 @@ private readonly token?;

getFile(fileId: string): Promise<IFile>;
forward(msgId: number, fromChatId: number | string, toChatId: number | string, moreOptions?: IForwardMessageOptions): Promise<IMessage>;
copy(msgId: number, fromChatId: number | string, toChatId: number | string, keyboard?: Keyboard | null, moreOptions?: ICopyMessageOptions): Promise<IMessageId>;
}

@@ -65,3 +65,8 @@ "use strict";

moreOptions = { ...moreOptions, ...content.options };
content = content.content;
if (content instanceof __1.MessageSend) {
content = content.content;
}
else if (content instanceof __1.Alert || content instanceof __1.Toast) {
content = content.text;
}
}

@@ -80,2 +85,4 @@ if (content instanceof Media_1.Media) {

moreOptions.reply_markup = keyboard.buildMarkup();
if (!(typeof content === 'string'))
return;
return this.callApi('sendMessage', {

@@ -133,4 +140,22 @@ text: content,

}
forward(msgId, fromChatId, toChatId, moreOptions = {}) {
return this.callApi('forwardMessage', {
chat_id: toChatId,
from_chat_id: fromChatId,
message_id: msgId,
...moreOptions,
});
}
copy(msgId, fromChatId, toChatId, keyboard = null, moreOptions = {}) {
if (keyboard)
moreOptions.reply_markup = keyboard.buildMarkup();
return this.callApi('copyMessage', {
message_id: msgId,
from_chat_id: fromChatId,
chat_id: toChatId,
...moreOptions,
});
}
}
exports.Api = Api;
//# sourceMappingURL=Api.js.map

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

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

@@ -13,3 +13,5 @@ import { Api } from '../Api';

getFile(fileId: string): Promise<IFile>;
forward(toChatId: number | string, moreOptions?: IForwardMessageOptions): Promise<IMessage>;
copy(toChatId: number | string, keyboard?: Keyboard | null, moreOptions?: ICopyMessageOptions): Promise<import("../..").IMessageId>;
saveFile(path: string): Promise<boolean>;
}

@@ -36,2 +36,20 @@ "use strict";

}
forward(toChatId, moreOptions) {
const chatId = Filter_1.Filter.getChatId(this.update);
if (!chatId)
throw (0, logger_1.error)(`Can't find chatId from update`);
const msgId = Filter_1.Filter.getMsgId(this.update);
if (!msgId)
throw (0, logger_1.error)(`Can't find msgId from update`);
return this.api.forward(msgId, chatId, toChatId, moreOptions);
}
copy(toChatId, keyboard, moreOptions) {
const chatId = Filter_1.Filter.getChatId(this.update);
if (!chatId)
throw (0, logger_1.error)(`Can't find chatId from update`);
const msgId = Filter_1.Filter.getMsgId(this.update);
if (!msgId)
throw (0, logger_1.error)(`Can't find msgId from update`);
return this.api.copy(msgId, chatId, toChatId, keyboard, moreOptions);
}
async saveFile(path) {

@@ -38,0 +56,0 @@ var _a, _b, _c;

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

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

@@ -7,0 +8,0 @@ static getMessage(update: IUpdate): IMessage | undefined;

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

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

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

@@ -5,3 +5,4 @@ import { MiddlewareFunction, MessageEntityTypes, MediaFileTypes } from '../..';

static update(): MiddlewareFunction;
static command(commandText: string): MiddlewareFunction;
static forward(): MiddlewareFunction;
static command(commandText?: string): MiddlewareFunction;
static text(text?: string): MiddlewareFunction;

@@ -8,0 +9,0 @@ static entity(entityType?: MessageEntityTypes): MiddlewareFunction;

@@ -11,2 +11,11 @@ "use strict";

}
static forward() {
return function use(update, answer, params, next, fail) {
if (!update.message)
return fail();
else if (!update.message.forward_date)
return fail();
next();
};
}
static command(commandText) {

@@ -20,2 +29,4 @@ return function use(update, answer, params, next, fail) {

return fail();
if (!commandText)
return next();
if (message.text.slice(entity.offset, entity.length) !== `/${commandText}`)

@@ -22,0 +33,0 @@ return fail();

@@ -59,6 +59,16 @@ "use strict";

if (resultMessageToSend instanceof Message_1.MessageCreator) {
if (['alert', 'toast'].includes(resultMessageToSend.sendType)) {
if (resultMessageToSend instanceof Message_1.Alert || resultMessageToSend instanceof Message_1.Toast) {
sendMethodKey = resultMessageToSend.sendType;
answerCallArgs.push(resultMessageToSend.content, resultMessageToSend.options);
answerCallArgs.push(resultMessageToSend.text, resultMessageToSend.options);
}
else if (resultMessageToSend instanceof Message_1.Forward || resultMessageToSend instanceof Message_1.Copy) {
sendMethodKey = resultMessageToSend.sendType;
if (resultMessageToSend instanceof Message_1.Forward)
answerCallArgs.push(resultMessageToSend.toChatId, resultMessageToSend.options);
else if (resultMessageToSend instanceof Message_1.Copy)
answerCallArgs.push(resultMessageToSend.toChatId, resultMessageToSend.keyboard, resultMessageToSend.options);
}
else if (resultMessageToSend instanceof Message_1.MessageSend) {
answerCallArgs.push(resultMessageToSend.content, resultMessageToSend.keyboard, resultMessageToSend.options);
}
else {

@@ -65,0 +75,0 @@ answerCallArgs.push(resultMessageToSend);

import { MessageCreator } from './MessageCreator';
import { IAnswerCallbackQueryOptions, SendTypes } from '../../types';
import { IAnswerCallbackQueryOptions, MessageCreatorTypes, SendTypes } from '../../types';
export declare class Alert extends MessageCreator {

@@ -7,3 +7,4 @@ readonly text: string;

sendType: SendTypes;
type: MessageCreatorTypes;
constructor(text: string, options?: IAnswerCallbackQueryOptions);
}

@@ -7,6 +7,7 @@ "use strict";

constructor(text, options = {}) {
super(text, null, options);
super(options);
this.text = text;
this.options = options;
this.sendType = 'alert';
this.type = 'text';
}

@@ -13,0 +14,0 @@ }

@@ -5,1 +5,3 @@ export * from './MessageCreator';

export * from './Toast';
export * from './Forward';
export * from './Copy';

@@ -21,2 +21,4 @@ "use strict";

__exportStar(require("./Toast"), exports);
__exportStar(require("./Forward"), exports);
__exportStar(require("./Copy"), exports);
//# sourceMappingURL=index.js.map

@@ -1,11 +0,7 @@

import { Keyboard } from '../Keyboard/Keyboard';
import { ContentTypes, MediaFileTypes, SendTypes } from '../../types';
import { MessageCreatorTypes, SendTypes } from '../../types';
export declare class MessageCreator {
readonly content: ContentTypes;
readonly keyboard: Keyboard | null;
readonly options: any;
type: MediaFileTypes | 'text';
type: MessageCreatorTypes;
sendType: SendTypes;
constructor(content: ContentTypes, keyboard?: Keyboard | null, options?: any);
setThumb(): void;
constructor(options?: any);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageCreator = void 0;
const logger_1 = require("../../logger");
const Media_1 = require("../Media");
class MessageCreator {
constructor(content, keyboard = null, options = {}) {
this.content = content;
this.keyboard = keyboard;
constructor(options = {}) {
this.options = options;
if (!content)
throw (0, logger_1.error)('[new Message]'.bgGreen, 'You must provide content if you want to send message');
if (content instanceof Media_1.Media) {
this.type = content.fileType;
}
else {
this.type = 'text';
}
if (keyboard)
options.reply_markup = keyboard.buildMarkup();
}
setThumb() { }
}
exports.MessageCreator = MessageCreator;
//# sourceMappingURL=MessageCreator.js.map
import { MessageCreator } from './MessageCreator';
import { SendTypes } from '../../types/message-creator.types';
import { ContentTypes, ISendOptions } from '../../types';
import { ContentTypes, ISendOptions, MessageCreatorTypes, SendTypes } from '../../types';
import { Keyboard } from '../Keyboard/Keyboard';

@@ -10,3 +9,4 @@ export declare class MessageSend extends MessageCreator {

sendType: SendTypes;
type: MessageCreatorTypes;
constructor(content: ContentTypes, keyboard?: Keyboard | null, options?: ISendOptions);
}

@@ -7,3 +7,3 @@ "use strict";

constructor(content, keyboard = null, options = {}) {
super(content, keyboard, options);
super(options);
this.content = content;

@@ -13,2 +13,5 @@ this.keyboard = keyboard;

this.sendType = 'send';
this.type = 'text';
if (keyboard)
options.reply_markup = keyboard.buildMarkup();
}

@@ -15,0 +18,0 @@ }

import { MessageCreator } from './MessageCreator';
import { IAnswerCallbackQueryOptions, SendTypes } from '../../types';
import { IAnswerCallbackQueryOptions, MessageCreatorTypes, SendTypes } from '../../types';
export declare class Toast extends MessageCreator {

@@ -7,3 +7,4 @@ readonly text: string;

sendType: SendTypes;
type: MessageCreatorTypes;
constructor(text: string, options?: IAnswerCallbackQueryOptions);
}

@@ -7,6 +7,7 @@ "use strict";

constructor(text, options = {}) {
super(text, null, options);
super(options);
this.text = text;
this.options = options;
this.sendType = 'toast';
this.type = 'text';
}

@@ -13,0 +14,0 @@ }

import { MediaFileTypes, MessageEntityTypes } from '../../types';
import { MessageSubtypes } from '../../types/listen-middlewares.types';
export declare function buildUpdateDecorator(listenMiddlewareName: string, ...args: any[]): MethodDecorator;
export declare const OnCommand: (commandText: string) => MethodDecorator;
export declare const OnCommand: (commandText?: string) => MethodDecorator;
export declare const OnText: (text?: string) => MethodDecorator;

@@ -17,1 +17,2 @@ export declare const OnMessage: (subtype?: MessageSubtypes) => MethodDecorator;

export declare const OnUpdate: () => MethodDecorator;
export declare const OnForward: () => MethodDecorator;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OnUpdate = exports.OnAudio = exports.OnVideo = exports.OnPhoto = exports.OnMedia = exports.OnClick = exports.OnEntity = exports.OnPostEdit = exports.OnPost = exports.OnMessageEdit = exports.OnMessage = exports.OnText = exports.OnCommand = exports.buildUpdateDecorator = void 0;
exports.OnForward = exports.OnUpdate = exports.OnAudio = exports.OnVideo = exports.OnPhoto = exports.OnMedia = exports.OnClick = exports.OnEntity = exports.OnPostEdit = exports.OnPost = exports.OnMessageEdit = exports.OnMessage = exports.OnText = exports.OnCommand = exports.buildUpdateDecorator = void 0;
const setup_arguments_1 = require("./setup-arguments");

@@ -41,2 +41,4 @@ const middleware_decorator_1 = require("./middleware.decorator");

exports.OnUpdate = OnUpdate;
const OnForward = () => buildUpdateDecorator('forward');
exports.OnForward = OnForward;
//# sourceMappingURL=update.decorators.js.map

@@ -5,2 +5,3 @@ import { IMessageEntity } from './update.types';

export declare type IOptions = ISendOptions | ISendPhotoOptions | ISendVideoOptions;
export declare type ParseModes = 'HTML' | 'Markdown' | 'MarkdownV2';
export interface ISendFetchOptions extends ISendOptions {

@@ -11,3 +12,3 @@ chat_id: number | string;

export interface ISendOptions {
parse_mode?: 'HTML' | 'Markdown' | 'MarkdownV2';
parse_mode?: ParseModes;
entities?: IMessageEntity[];

@@ -67,1 +68,24 @@ disable_notification?: boolean;

}
export interface IForwardMessageOptions {
disable_notification?: boolean;
protect_content?: boolean;
}
export interface IForwardMessageFetchOptions extends IForwardMessageOptions, IMessageId {
chat_id: string | number;
from_chat_id: string | number;
}
export interface ICopyMessageOptions extends ISendPhotoOptions {
parse_mode?: ParseModes;
disable_notification?: boolean;
protect_content?: boolean;
reply_to_message_id?: number;
allow_sending_without_reply?: boolean;
reply_markup?: ReplyMarkup;
}
export interface ICopyMessageFetchOptions extends ICopyMessageOptions, IMessageId {
chat_id: number | string;
from_chat_id: number | string;
}
export interface IMessageId {
message_id: number;
}

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

export declare type SendTypes = 'send' | 'alert' | 'toast';
import { MediaFileTypes } from './media.types';
export declare type SendTypes = 'send' | 'alert' | 'toast' | 'forward' | 'copy';
export declare type MessageCreatorTypes = MediaFileTypes | 'text';
{
"name": "nestgram",
"description": "Framework for working with Telegram Bot API on TypeScript like Nest.js",
"version": "1.4.0",
"version": "1.5.0",
"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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc