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.7.4 to 1.7.5

dist/classes/Media/Dice.d.ts

8

dist/classes/Api.d.ts

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

import { Audio, ContentTypes, Document, IAnswerCallbackQueryOptions, ICopyMessageOptions, IDeleteWebhookConfig, IFile, IForwardMessageOptions, IMessage, IMessageId, InputSupportedMedia, IOptions, ISendAnimationOptions, ISendAudioOptions, ISendDocumentOptions, ISendLocationOptions, ISendMediaGroupOptions, ISendPhotoOptions, ISendVideoNoteOptions, ISendVideoOptions, ISendVoiceOptions, IUser, IWebhookConfig, Keyboard, MessageCreator, Photo, Video, Voice, IStopMessageLiveLocationOptions, ISendVenueOptions, ISendContactOptions, ISendPollOptions } from '..';
import { Audio, ContentTypes, Document, IAnswerCallbackQueryOptions, ICopyMessageOptions, IDeleteWebhookConfig, IFile, IForwardMessageOptions, IMessage, IMessageId, InputSupportedMedia, IOptions, ISendAnimationOptions, ISendAudioOptions, ISendDocumentOptions, ISendLocationOptions, ISendMediaGroupOptions, ISendPhotoOptions, ISendVideoNoteOptions, ISendVideoOptions, ISendVoiceOptions, IUser, IWebhookConfig, Keyboard, MessageCreator, Photo, Video, Voice, IStopMessageLiveLocationOptions, ISendVenueOptions, ISendContactOptions, ISendPollOptions, DiceEmojis, ISendDiceOptions, ChatActions, IUserProfilePhotos, IWebhookInfo } from '..';
import { Animation, VideoNote } from './Media';

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

getMe(): Promise<IUser>;
logOut(): Promise<true>;
close(): Promise<true>;
getWebhookInfo(): Promise<IWebhookInfo>;
setWebhook(config: IWebhookConfig): Promise<boolean>;

@@ -29,2 +32,5 @@ deleteWebhook(config?: IDeleteWebhookConfig): Promise<boolean>;

sendPoll(chatId: number | string, question: string, options: string[], keyboard?: Keyboard | null, moreOptions?: ISendPollOptions): Promise<IMessage>;
sendDice(chatId: number | string, emoji?: DiceEmojis | null, keyboard?: Keyboard | null, moreOptions?: ISendDiceOptions): Promise<IMessage>;
chatAction(chatId: number | string, action: ChatActions): Promise<true>;
getUserProfilePhotos(userId: number, limit?: number, offset?: number): Promise<IUserProfilePhotos>;
answerCallbackQuery(callback_query_id: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;

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

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

}
logOut() {
return this.callApi('logOut');
}
close() {
return this.callApi('close');
}
getWebhookInfo() {
return this.callApi('getWebhookInfo');
}
setWebhook(config) {

@@ -128,2 +137,7 @@ return this.callApi('setWebhook', config);

});
else if (content instanceof __1.Dice)
return this.sendDice(chatId, content.emoji, keyboard, {
...moreOptions,
...(content.moreOptions || {}),
});
else

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

}
sendDice(chatId, emoji = null, keyboard = null, moreOptions = {}) {
if (keyboard)
moreOptions.reply_markup = keyboard.buildMarkup();
return this.callApi('sendDice', {
chat_id: chatId,
emoji: emoji || '🎲',
...moreOptions,
});
}
chatAction(chatId, action) {
return this.callApi('sendChatAction', {
chat_id: chatId,
action,
});
}
getUserProfilePhotos(userId, limit, offset) {
return this.callApi('getUserProfilePhotos', {
user_id: userId,
limit,
offset,
});
}
answerCallbackQuery(callback_query_id, moreOptions = {}) {

@@ -289,0 +325,0 @@ return this.callApi('answerCallbackQuery', {

7

dist/classes/Context/Answer.d.ts

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

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

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

send(content: MessageCreator | ContentTypes, keyboard?: Keyboard | null, moreOptions?: ISendOptions): Promise<IMessage | IMessage[]>;
chatAction(action: ChatActions): Promise<true>;
getUserProfilePhotos(limit?: number, offset?: number): Promise<IUserProfilePhotos>;
stopLiveLocation(keyboard?: Keyboard | null, moreOptions?: IStopMessageLiveLocationOptions): Promise<IMessage | true>;

@@ -17,3 +19,4 @@ alert(text: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;

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

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

}
chatAction(action) {
const chatId = Filter_1.Filter.getChatId(this.update);
if (!chatId)
throw (0, logger_1.error)(`Can't find chatId from update`);
return this.api.chatAction(chatId, action);
}
getUserProfilePhotos(limit, offset) {
const userId = Filter_1.Filter.getUserId(this.update);
if (!userId)
throw (0, logger_1.error)(`Can't find userId from update`);
return this.api.getUserProfilePhotos(userId, limit, offset);
}
stopLiveLocation(keyboard = null, moreOptions = {}) {

@@ -64,11 +76,29 @@ const chatId = Filter_1.Filter.getChatId(this.update);

}
async saveFile(path) {
var _a, _b, _c;
async saveProfilePhoto(path, index = 0) {
var _a;
const userProfilePhotosInfo = await this.getUserProfilePhotos();
if (!userProfilePhotosInfo)
return false;
const photos = userProfilePhotosInfo.photos[index];
if (!photos)
return false;
const fileId = (_a = photos[photos.length - 1]) === null || _a === void 0 ? void 0 : _a.file_id;
if (!fileId)
return false;
return this.saveFile(path, fileId);
}
async saveFile(path, fileId) {
var _a, _b, _c, _d, _e, _f;
const msg = this.update.message;
if (!msg)
return false;
const fileId = ((_a = msg.audio) === null || _a === void 0 ? void 0 : _a.file_id) ||
((_b = msg.video) === null || _b === void 0 ? void 0 : _b.file_id) ||
(msg.photo && ((_c = msg.photo[msg.photo.length - 1]) === null || _c === void 0 ? void 0 : _c.file_id));
if (!fileId)
fileId =
((_a = msg.audio) === null || _a === void 0 ? void 0 : _a.file_id) ||
((_b = msg.video) === null || _b === void 0 ? void 0 : _b.file_id) ||
((_c = msg.animation) === null || _c === void 0 ? void 0 : _c.file_id) ||
((_d = msg.document) === null || _d === void 0 ? void 0 : _d.file_id) ||
((_e = msg.voice) === null || _e === void 0 ? void 0 : _e.file_id) ||
(msg.photo && ((_f = msg.photo[msg.photo.length - 1]) === null || _f === void 0 ? void 0 : _f.file_id));
if (!fileId)
return false;

@@ -86,3 +116,3 @@ const fileInfo = await this.getFile(fileId);

}
catch (_d) {
catch (_g) {
return false;

@@ -89,0 +119,0 @@ }

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

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

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

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

}
static getUserId(update) {
var _a, _b;
return (_b = (_a = Filter.getMessage(update)) === null || _a === void 0 ? void 0 : _a.from) === null || _b === void 0 ? void 0 : _b.id;
}
static getMsgId(update) {

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

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

(message === null || message === void 0 ? void 0 : message.poll) || (update === null || update === void 0 ? void 0 : update.poll),
message === null || message === void 0 ? void 0 : message.dice,
];

@@ -68,8 +69,10 @@ const handlerMethod = handler.controller[handler.methodKey].bind(handler.controller);

if (resultMessageToSend instanceof Message_1.MessageCreator) {
sendMethodKey = resultMessageToSend.sendType;
if (resultMessageToSend instanceof Message_1.Alert || resultMessageToSend instanceof Message_1.Toast) {
sendMethodKey = resultMessageToSend.sendType;
answerCallArgs.push(resultMessageToSend.text, resultMessageToSend.options);
}
else if (resultMessageToSend instanceof Message_1.ChatAction) {
answerCallArgs.push(resultMessageToSend.action);
}
else if (resultMessageToSend instanceof Message_1.Forward || resultMessageToSend instanceof Message_1.Copy) {
sendMethodKey = resultMessageToSend.sendType;
if (resultMessageToSend instanceof Message_1.Forward)

@@ -81,2 +84,3 @@ answerCallArgs.push(resultMessageToSend.toChatId, resultMessageToSend.options);

else if (resultMessageToSend instanceof Message_1.MessageSend) {
sendMethodKey = 'send';
answerCallArgs.push(resultMessageToSend.content, resultMessageToSend.keyboard, resultMessageToSend.options);

@@ -83,0 +87,0 @@ }

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

export * from './Poll';
export * from './Dice';

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

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

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

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

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

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

@@ -21,1 +21,2 @@ import { MessageEntityTypes } from '../../types';

export declare const ReceivedPoll: () => ParameterDecorator;
export declare const GetDice: () => ParameterDecorator;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReceivedPoll = exports.GetPoll = exports.ReceivedVenue = exports.GetVenue = exports.ReceivedContact = exports.GetContact = exports.ReceivedLocation = exports.GetLocation = exports.UserId = exports.Sender = exports.Params = exports.CommandParams = exports.Entities = exports.Update = exports.Message = exports.Answ = exports.GetAnswer = exports.Text = exports.Entity = void 0;
exports.GetDice = exports.ReceivedPoll = exports.GetPoll = exports.ReceivedVenue = exports.GetVenue = exports.ReceivedContact = exports.GetContact = exports.ReceivedLocation = exports.GetLocation = exports.UserId = exports.Sender = exports.Params = exports.CommandParams = exports.Entities = exports.Update = exports.Message = exports.Answ = exports.GetAnswer = exports.Text = exports.Entity = void 0;
function defineArgumentMetadata(target, propertyKey, parameterIndex, gotIndexName, metadataKey = 'gotIndex') {

@@ -56,2 +56,4 @@ Reflect.defineMetadata(metadataKey, {

exports.ReceivedPoll = exports.GetPoll;
const GetDice = () => buildArgumentDecorator('dice');
exports.GetDice = GetDice;
//# sourceMappingURL=argumets.decorator.js.map

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

'poll',
'dice',
];

@@ -20,0 +21,0 @@ function setupArguments(target, propertyName, descriptor) {

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

export declare const OnPollAnswer: () => MethodDecorator;
export declare const OnDice: () => MethodDecorator;
export declare const OnUpdate: () => MethodDecorator;
export declare const OnForward: () => MethodDecorator;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OnForward = exports.OnUpdate = exports.OnPollAnswer = exports.OnPollEdit = exports.OnPoll = exports.OnContact = exports.OnVenue = exports.OnLocation = exports.OnDocument = exports.OnAnimation = exports.OnVoice = exports.OnVideoNote = 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.OnDice = exports.OnPollAnswer = exports.OnPollEdit = exports.OnPoll = exports.OnContact = exports.OnVenue = exports.OnLocation = exports.OnDocument = exports.OnAnimation = exports.OnVoice = exports.OnVideoNote = 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");

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

exports.OnPollAnswer = OnPollAnswer;
const OnDice = () => buildUpdateDecorator('otherMedia', 'dice');
exports.OnDice = OnDice;
const OnUpdate = () => buildUpdateDecorator('update');

@@ -61,0 +63,0 @@ exports.OnUpdate = OnUpdate;

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

import { IMessageEntity } from './update.types';
import { IMessageEntity, IPhotoSize } from './update.types';
import { IInlineKeyboard, IReplyMarkup } from './keyboard.types';

@@ -8,2 +8,4 @@ import { InputMediaTypes } from './media.types';

export declare type PollTypes = 'quiz' | 'regular';
export declare type DiceEmojis = '🎲' | '🎯' | '🏀' | '⚽' | '🎳' | '🎰';
export declare type ChatActions = 'typing' | 'upload_photo' | 'record_video' | 'upload_video' | 'record_voice' | 'upload_voice' | 'upload_document' | 'choose_sticker' | 'find_location' | 'record_video_note' | 'upload_video_note';
export interface ISendFetchOptions extends ISendOptions {

@@ -179,2 +181,32 @@ chat_id: number | string;

}
export interface ISendChatActionFetchOptions {
chat_id: number | string;
action: ChatActions;
}
export interface ISendDiceFetchOptions extends ISendDiceOptions {
chat_id: string | number;
emoji?: DiceEmojis;
}
export interface IGetUserProfilePhotosFetchOptions {
user_id: number;
offset?: number;
limit?: number;
}
export interface IUserProfilePhotos {
total_count: number;
photos: IPhotoSize[][];
}
export interface IWebhookInfo {
url: string;
has_custom_certificate: boolean;
pending_update_count: number;
ip_address?: string;
last_error_date?: number;
last_error_message?: string;
last_synchronization_error_date?: number;
max_connections?: number;
allowed_updates?: string[];
}
export interface ISendDiceOptions extends IDefaultOptions {
}
export interface ISendMediaGroupOptions extends IDefaultOptions {

@@ -181,0 +213,0 @@ }

import { ControllerClass } from './decorators.types';
import { MiddlewareFunction } from './middleware.types';
import { IContact, ILocation, IMessage, IMessageEntity, IPoll, IUpdate, IVenue } from './update.types';
import { IContact, IDice, ILocation, IMessage, IMessageEntity, IPoll, IUpdate, IVenue } from './update.types';
import { Answer, Media, MessageCreator } from '../classes';

@@ -24,3 +24,4 @@ import { IUser } from './chat.types';

IVenue,
IPoll
IPoll,
IDice
];

@@ -27,0 +28,0 @@ export declare type ContentTypes = Media | string | undefined | null;

@@ -5,3 +5,3 @@ import { ParseModes } from './api.types';

export declare type MediaFileTypes = 'photo' | 'video' | 'thumb' | 'audio' | 'document' | 'animation' | 'voice' | 'video_note';
export declare type MediaSendTypes = 'location' | 'venue' | 'contact' | 'poll';
export declare type MediaSendTypes = 'location' | 'venue' | 'contact' | 'poll' | 'dice';
export declare type InputMediaTypes = IInputMediaAudio | IInputMediaDocument | IInputMediaPhoto | IInputMediaVideo;

@@ -8,0 +8,0 @@ export declare type InputSupportedMedia = Audio | Document | Photo | Video;

import { MediaFileTypes } from './media.types';
export declare type SendTypes = 'send' | 'alert' | 'toast' | 'forward' | 'copy';
export declare type SendTypes = 'send' | 'alert' | 'toast' | 'forward' | 'copy' | 'chatAction';
export declare type MessageCreatorTypes = MediaFileTypes | 'text' | 'location';
import { IChat, IUser } from './chat.types';
import { IReplyMarkup } from './keyboard.types';
import { PollTypes } from './api.types';
import { DiceEmojis, PollTypes } from './api.types';
export declare type MessageEntityTypes = 'mention' | 'hashtag' | 'cashtag' | 'bot_command' | 'url' | 'email' | 'phone_number' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'code' | 'pre' | 'text_link' | 'text_mention';

@@ -67,3 +67,3 @@ export interface IUpdate {

contact?: IContact;
dice?: any;
dice?: IDice;
game?: any;

@@ -188,2 +188,6 @@ poll?: IPoll;

}
export interface IDice {
emoji: DiceEmojis;
value: number;
}
export {};
{
"name": "nestgram",
"description": "Framework for working with Telegram Bot API on TypeScript like Nest.js",
"version": "1.7.4",
"version": "1.7.5",
"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

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