Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.7.0 to 1.7.1

dist/classes/Media/MediaGroup.d.ts

6

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, IForwardMessageOptions, ICopyMessageOptions, IMessageId, Document, ISendDocumentOptions, ISendAnimationOptions, Voice, ISendVoiceOptions, ISendVideoNoteOptions } from '..';
import { Audio, ContentTypes, Document, IAnswerCallbackQueryOptions, ICopyMessageOptions, IDeleteWebhookConfig, IFile, IForwardMessageOptions, IMessage, IMessageId, InputSupportedMedia, IOptions, ISendAnimationOptions, ISendAudioOptions, ISendDocumentOptions, ISendMediaGroupOptions, ISendPhotoOptions, ISendVideoNoteOptions, ISendVideoOptions, ISendVoiceOptions, IUser, IWebhookConfig, Keyboard, MessageCreator, Photo, Video, Voice } from '..';
import { Animation, VideoNote } from './Media';

@@ -10,2 +10,3 @@ export declare class Api {

private buildFormData;
private buildAttachFormData;
private static saveMediaFileId;

@@ -15,3 +16,3 @@ getMe(): Promise<IUser>;

deleteWebhook(config?: IDeleteWebhookConfig): Promise<boolean>;
send(chatId: string | number, content: MessageCreator | ContentTypes, keyboard?: Keyboard | null, moreOptions?: IOptions): Promise<IMessage>;
send(chatId: string | number, content: MessageCreator | ContentTypes, keyboard?: Keyboard | null, moreOptions?: IOptions): Promise<IMessage | IMessage[]>;
sendPhoto(chatId: string | number, photo: Photo, keyboard?: Keyboard | null, moreOptions?: ISendPhotoOptions): Promise<IMessage>;

@@ -24,2 +25,3 @@ sendVideo(chatId: string | number, video: Video, keyboard?: Keyboard | null, moreOptions?: ISendVideoOptions): Promise<IMessage>;

sendAnimation(chatId: string | number, animation: Animation, keyboard?: Keyboard | null, moreOptions?: ISendAnimationOptions): Promise<IMessage>;
sendMediaGroup(chatId: string | number, mediaGroup: InputSupportedMedia[], moreOptions?: ISendMediaGroupOptions): Promise<IMessage[]>;
answerCallbackQuery(callback_query_id: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;

@@ -26,0 +28,0 @@ alert(callback_query_id: string, text: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;

@@ -58,2 +58,12 @@ "use strict";

}
buildAttachFormData(config) {
const formData = new FormData();
Object.keys(config).forEach((key) => {
const data = config[key];
if (!data)
return;
formData.append(key, typeof data === 'object' ? JSON.stringify(data) : data);
});
return formData;
}
static saveMediaFileId(path, mediaKey, message) {

@@ -102,2 +112,4 @@ if (!MediaCache_1.mediaCache.getMediaFileId(path)) {

return this.sendVoice(chatId, content, keyboard, moreOptions);
else if (content instanceof __1.MediaGroup)
return this.sendMediaGroup(chatId, content.mediaGroup, moreOptions);
else

@@ -187,2 +199,33 @@ throw (0, logger_1.error)("Media file type is not defined. Don't use Media class, use Photo, Video class instead");

}
async sendMediaGroup(chatId, mediaGroup, moreOptions = {}) {
const formData = this.buildAttachFormData({
chat_id: chatId,
media: mediaGroup.map((media, index) => {
return {
type: media.type,
media: MediaCache_1.mediaCache.getMediaFileId(media.media) || `attach://${index}`,
...(media.thumb
? { thumb: MediaCache_1.mediaCache.getMediaFileId(media.thumb.media) || `attach://${index}_thumb` }
: {}),
...(media instanceof __1.Video ? media.resolution : {}),
...(media.options || {}),
};
}),
...moreOptions,
});
mediaGroup.forEach((media, index) => {
if (!MediaCache_1.mediaCache.getMediaFileId(media.media))
Api.appendMediaToFormData(formData, index.toString(), media);
if (media.thumb) {
if (!MediaCache_1.mediaCache.getMediaFileId(media.thumb.media))
Api.appendMediaToFormData(formData, `${index.toString()}_thumb`, media.thumb);
}
});
const sentMessages = await this.callApi('sendMediaGroup', formData);
for (const sentMessage of sentMessages) {
const media = mediaGroup[sentMessages.indexOf(sentMessage)];
Api.saveMediaFileId(media.media, media.type, sentMessage);
}
return sentMessages;
}
answerCallbackQuery(callback_query_id, moreOptions = {}) {

@@ -189,0 +232,0 @@ return this.callApi('answerCallbackQuery', {

@@ -9,3 +9,3 @@ import { ISendOptions, IMessage, IUpdate, ContentTypes, Keyboard, IAnswerCallbackQueryOptions, IFile, IForwardMessageOptions, ICopyMessageOptions } from '../..';

constructor(token: string, update: IUpdate);
send(content: MessageCreator | ContentTypes, keyboard?: Keyboard | null, moreOptions?: ISendOptions): Promise<IMessage>;
send(content: MessageCreator | ContentTypes, keyboard?: Keyboard | null, moreOptions?: ISendOptions): Promise<IMessage | IMessage[]>;
alert(text: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;

@@ -12,0 +12,0 @@ toast(text: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;

import { Video } from './Video';
import { MediaFileTypes } from '../../types';
export declare class Animation extends Video {
type: MediaFileTypes;
}

@@ -6,4 +6,8 @@ "use strict";

class Animation extends Video_1.Video {
constructor() {
super(...arguments);
this.type = 'animation';
}
}
exports.Animation = Animation;
//# sourceMappingURL=Animation.js.map
import { Media } from './Media';
import { MediaFileTypes } from '../../types';
export declare class Audio extends Media {
type: MediaFileTypes;
}

@@ -6,4 +6,8 @@ "use strict";

class Audio extends Media_1.Media {
constructor() {
super(...arguments);
this.type = 'audio';
}
}
exports.Audio = Audio;
//# sourceMappingURL=Audio.js.map
import { Media } from './Media';
import { MediaFileTypes } from '../../types';
export declare class Document extends Media {
type: MediaFileTypes;
}

@@ -6,4 +6,8 @@ "use strict";

class Document extends Media_1.Media {
constructor() {
super(...arguments);
this.type = 'document';
}
}
exports.Document = Document;
//# sourceMappingURL=Document.js.map

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

export * from './Animation';
export * from './MediaGroup';

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

__exportStar(require("./Animation"), exports);
__exportStar(require("./MediaGroup"), exports);
//# sourceMappingURL=index.js.map

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

import { MediaPassTypes } from '../../types';
import { MediaFileTypes, MediaPassTypes } from '../../types';
import { Thumb } from './Thumb';

@@ -6,5 +6,7 @@ export declare class Media {

media: string;
readonly options?: any;
type: MediaFileTypes;
thumb?: Thumb;
constructor(passType: MediaPassTypes, media: string);
constructor(passType: MediaPassTypes, media: string, options?: any);
setThumb(thumb: Thumb): this;
}

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

class Media {
constructor(passType, media) {
constructor(passType, media, options) {
this.passType = passType;
this.media = media;
this.options = options;
}

@@ -10,0 +11,0 @@ setThumb(thumb) {

import { Media } from './Media';
import { MediaFileTypes } from '../../types';
export declare class Photo extends Media {
type: MediaFileTypes;
}

@@ -6,4 +6,8 @@ "use strict";

class Photo extends Media_1.Media {
constructor() {
super(...arguments);
this.type = 'photo';
}
}
exports.Photo = Photo;
//# sourceMappingURL=Photo.js.map
import { Media } from './Media';
import { IResolution } from '../../types';
import { IResolution, MediaFileTypes } from '../../types';
export declare class Video extends Media {
type: MediaFileTypes;
resolution: IResolution;
setResolution(width?: number | null, height?: number | null): this;
}

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

super(...arguments);
this.type = 'video';
this.resolution = { width: 1920, height: 1080 };

@@ -10,0 +11,0 @@ }

import { Media } from './Media';
import { MediaFileTypes } from '../../types';
export declare class VideoNote extends Media {
type: MediaFileTypes;
}

@@ -6,4 +6,8 @@ "use strict";

class VideoNote extends Media_1.Media {
constructor() {
super(...arguments);
this.type = 'video_note';
}
}
exports.VideoNote = VideoNote;
//# sourceMappingURL=VideoNote.js.map
import { Media } from './Media';
import { MediaFileTypes } from '../../types';
export declare class Voice extends Media {
type: MediaFileTypes;
}

@@ -6,4 +6,8 @@ "use strict";

class Voice extends Media_1.Media {
constructor() {
super(...arguments);
this.type = 'voice';
}
}
exports.Voice = Voice;
//# sourceMappingURL=Voice.js.map
import { IMessageEntity } from './update.types';
import { ReplyMarkup } from './keyboard.types';
import { Thumb } from '../classes';
import { InputMediaTypes } from './media.types';
export declare type IOptions = ISendOptions | ISendPhotoOptions | ISendVideoOptions;

@@ -19,2 +20,12 @@ export declare type ParseModes = 'HTML' | 'Markdown' | 'MarkdownV2';

}
export interface ISendMediaGroupFetchOptions extends ISendMediaGroupOptions {
chat_id: number | string;
media: InputMediaTypes[];
}
export interface ISendMediaGroupOptions {
disable_notification?: boolean;
protect_content?: boolean;
reply_to_message_id?: number;
allow_sending_without_reply?: boolean;
}
export interface ISendPhotoFetchOptions extends ISendPhotoOptions {

@@ -21,0 +32,0 @@ chat_id: number | string;

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

import { ParseModes } from './api.types';
import { IMessageEntity } from './update.types';
import { Audio, Document, Photo, Video } from '../classes';
export declare type MediaFileTypes = 'photo' | 'video' | 'thumb' | 'audio' | 'document' | 'animation' | 'voice' | 'video_note';
export declare type InputMediaTypes = IInputMediaAudio | IInputMediaDocument | IInputMediaPhoto | IInputMediaVideo;
export declare type InputSupportedMedia = Audio | Document | Photo | Video;
export declare type MediaPassTypes = 'url' | 'path';

@@ -7,1 +12,30 @@ export interface IResolution {

}
export interface IInputMediaDefault {
type: 'audio' | 'video' | 'photo' | 'document';
media: string;
caption?: string;
parse_mode?: ParseModes;
caption_entities?: IMessageEntity[];
}
export interface IInputMediaAudio extends IInputMediaDefault {
type: 'audio';
thumb?: string;
duration?: number;
performer?: string;
title?: string;
}
export interface IInputMediaDocument extends IInputMediaDefault {
type: 'document';
thumb?: string;
}
export interface IInputMediaPhoto extends IInputMediaDefault {
type: 'photo';
}
export interface IInputMediaVideo extends IInputMediaDefault {
type: 'video';
thumb?: string;
width?: number;
height?: number;
duration?: number;
supports_streaming?: boolean;
}
{
"name": "nestgram",
"description": "Framework for working with Telegram Bot API on TypeScript like Nest.js",
"version": "1.7.0",
"version": "1.7.1",
"main": "dist/index.js",

@@ -51,5 +51,4 @@ "types": "dist/index.d.ts",

"form-data": "^4.0.0",
"mongoose": "^6.3.5",
"reflect-metadata": "^0.1.13"
}
}

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