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.3 to 1.7.4

dist/classes/Media/Poll.d.ts

3

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 } 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 } from '..';
import { Animation, VideoNote } from './Media';

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

sendContact(chatId: number | string, phone: string, firstName: string, lastName?: string | null, keyboard?: Keyboard | null, moreOptions?: ISendContactOptions): Promise<IMessage>;
sendPoll(chatId: number | string, question: string, options: string[], keyboard?: Keyboard | null, moreOptions?: ISendPollOptions): Promise<IMessage>;
answerCallbackQuery(callback_query_id: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>;

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

@@ -114,7 +114,15 @@ "use strict";

else if (content instanceof __1.Location)
return this.sendLocation(chatId, content.latitude, content.longitude, keyboard, moreOptions);
return this.sendLocation(chatId, content.latitude, content.longitude, keyboard, {
...moreOptions,
...(content.options || {}),
});
else if (content instanceof __1.Venue)
return this.sendVenue(chatId, content.latitude, content.longitude, content.title, content.address, keyboard, moreOptions);
return this.sendVenue(chatId, content.latitude, content.longitude, content.title, content.address, keyboard, { ...moreOptions, ...(content.options || {}) });
else if (content instanceof __1.Contact)
return this.sendContact(chatId, content.phone, content.firstName, content.lastName, keyboard, moreOptions);
return this.sendContact(chatId, content.phone, content.firstName, content.lastName, keyboard, { ...moreOptions, ...(content.options || {}) });
else if (content instanceof __1.Poll)
return this.sendPoll(chatId, content.question, content.options, keyboard, {
...moreOptions,
...(content.moreOptions || {}),
});
else

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

}
sendPoll(chatId, question, options, keyboard = null, moreOptions = {}) {
if (keyboard)
moreOptions.reply_markup = keyboard.buildMarkup();
return this.callApi('sendPoll', {
chat_id: chatId,
question,
options,
...moreOptions,
});
}
answerCallbackQuery(callback_query_id, moreOptions = {}) {

@@ -270,0 +288,0 @@ return this.callApi('answerCallbackQuery', {

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

static getChatId(update) {
var _a, _b;
return (_b = (_a = Filter.getMessage(update)) === null || _a === void 0 ? void 0 : _a.chat) === null || _b === void 0 ? void 0 : _b.id;
var _a, _b, _c;
return (_c = (((_a = Filter.getMessage(update)) === null || _a === void 0 ? void 0 : _a.chat) || ((_b = update.poll_answer) === null || _b === void 0 ? void 0 : _b.user))) === null || _c === void 0 ? void 0 : _c.id;
}

@@ -10,0 +10,0 @@ static getMsgId(update) {

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

import { MiddlewareFunction, MessageEntityTypes, MediaFileTypes } from '../..';
import { NextFunction, Answer, IUpdate, MiddlewareFunction, MessageEntityTypes, MediaFileTypes } from '../..';
import { MessageSubtypes } from '../../types/listen-middlewares.types';

@@ -6,5 +6,4 @@ export declare class ListenMiddleware {

static forward(): MiddlewareFunction;
static location(): MiddlewareFunction;
static venue(): MiddlewareFunction;
static contact(): MiddlewareFunction;
static pollEdit(isAnswer?: boolean): MiddlewareFunction;
static otherMedia(type: string): (update: IUpdate, answer: Answer, params: any, next: NextFunction, fail: NextFunction) => any;
static command(commandText?: string): MiddlewareFunction;

@@ -11,0 +10,0 @@ static text(text?: string): MiddlewareFunction;

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

}
static location() {
static pollEdit(isAnswer = false) {
return function use(update, answer, params, next, fail) {
if (!update.message)
if (!isAnswer && !update.poll)
return fail();
else if (!update.message.location)
if (isAnswer && !update.poll_answer)
return fail();

@@ -30,7 +30,8 @@ next();

}
static venue() {
static otherMedia(type) {
return function use(update, answer, params, next, fail) {
if (!update.message)
const message = __1.Filter.getMessage(update);
if (!message)
return fail();
else if (!update.message.venue)
else if (!message[type])
return fail();

@@ -40,11 +41,2 @@ next();

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

@@ -51,0 +43,0 @@ return function use(update, answer, params, next, fail) {

import { KeyboardTypes, IButton, IReplyMarkup } from '../..';
export declare class Keyboard<T = any> {
readonly keyboardType: KeyboardTypes;
readonly placeholder?: string;
private placeholder?;
private oneTimeKeyboard;
unresolvedButtons: IButton[];

@@ -17,6 +18,8 @@ rows: IButton[][];

webApp(text: string, url: string, hidden?: boolean): this;
row(btnsPerLine?: number | null, hidden?: boolean): Keyboard;
save(layoutName: string): Keyboard;
use(layoutName: string): Keyboard;
row(btnsPerLine?: number | null, hidden?: boolean): this;
save(layoutName: string): this;
use(layoutName: string): this;
setPlaceholder(newPlaceholder: string): this;
oneTime(): this;
buildMarkup(): IReplyMarkup;
}

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

this.placeholder = placeholder;
this.oneTimeKeyboard = false;
this.unresolvedButtons = [];

@@ -115,5 +116,23 @@ this.rows = [];

}
setPlaceholder(newPlaceholder) {
this.placeholder = newPlaceholder;
return this;
}
oneTime() {
this.oneTimeKeyboard = !this.oneTimeKeyboard;
return this;
}
buildMarkup() {
this.row();
return { [this.keyboardType]: this.rows, placeholder: this.placeholder };
if (this.keyboardType === 'keyboard') {
return {
keyboard: this.rows,
input_field_placeholder: this.placeholder,
one_time_keyboard: this.oneTimeKeyboard,
resize_keyboard: true,
};
}
else {
return { [this.keyboardType]: this.rows };
}
}

@@ -120,0 +139,0 @@ }

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

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

@@ -52,0 +53,0 @@ const handlerMethod = handler.controller[handler.methodKey].bind(handler.controller);

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

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

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

__exportStar(require("./Venue"), exports);
__exportStar(require("./Poll"), exports);
//# sourceMappingURL=index.js.map
import { MessageEntityTypes } from '../../types';
export declare function Entity(entity: MessageEntityTypes): (target: any, propertyKey: string, parameterIndex: number) => any;
export declare const Text: () => ParameterDecorator;
export declare const GetAnswer: () => ParameterDecorator;
export declare const Answ: () => ParameterDecorator;

@@ -12,4 +13,9 @@ export declare const Message: () => ParameterDecorator;

export declare const UserId: () => ParameterDecorator;
export declare const GetLocation: () => ParameterDecorator;
export declare const ReceivedLocation: () => ParameterDecorator;
export declare const GetContact: () => ParameterDecorator;
export declare const ReceivedContact: () => ParameterDecorator;
export declare const GetVenue: () => ParameterDecorator;
export declare const ReceivedVenue: () => ParameterDecorator;
export declare const GetPoll: () => ParameterDecorator;
export declare const ReceivedPoll: () => ParameterDecorator;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReceivedVenue = exports.ReceivedContact = exports.ReceivedLocation = exports.UserId = exports.Sender = exports.Params = exports.CommandParams = exports.Entities = exports.Update = exports.Message = exports.Answ = exports.Text = exports.Entity = void 0;
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') {

@@ -27,4 +27,5 @@ Reflect.defineMetadata(metadataKey, {

exports.Text = Text;
const Answ = () => buildArgumentDecorator('answer');
exports.Answ = Answ;
const GetAnswer = () => buildArgumentDecorator('answer');
exports.GetAnswer = GetAnswer;
exports.Answ = exports.GetAnswer;
const Message = () => buildArgumentDecorator('message');

@@ -44,8 +45,14 @@ exports.Message = Message;

exports.UserId = UserId;
const ReceivedLocation = () => buildArgumentDecorator('location');
exports.ReceivedLocation = ReceivedLocation;
const ReceivedContact = () => buildArgumentDecorator('contact');
exports.ReceivedContact = ReceivedContact;
const ReceivedVenue = () => buildArgumentDecorator('venue');
exports.ReceivedVenue = ReceivedVenue;
const GetLocation = () => buildArgumentDecorator('location');
exports.GetLocation = GetLocation;
exports.ReceivedLocation = exports.GetLocation;
const GetContact = () => buildArgumentDecorator('contact');
exports.GetContact = GetContact;
exports.ReceivedContact = exports.GetContact;
const GetVenue = () => buildArgumentDecorator('venue');
exports.GetVenue = GetVenue;
exports.ReceivedVenue = exports.GetVenue;
const GetPoll = () => buildArgumentDecorator('poll');
exports.GetPoll = GetPoll;
exports.ReceivedPoll = exports.GetPoll;
//# sourceMappingURL=argumets.decorator.js.map

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

'venue',
'poll',
];

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

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

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

@@ -47,8 +47,14 @@ const middleware_decorator_1 = require("./middleware.decorator");

exports.OnDocument = OnDocument;
const OnLocation = () => buildUpdateDecorator('location');
const OnLocation = () => buildUpdateDecorator('otherMedia', 'location');
exports.OnLocation = OnLocation;
const OnVenue = () => buildUpdateDecorator('venue');
const OnVenue = () => buildUpdateDecorator('otherMedia', 'venue');
exports.OnVenue = OnVenue;
const OnContact = () => buildUpdateDecorator('contact');
const OnContact = () => buildUpdateDecorator('otherMedia', 'contact');
exports.OnContact = OnContact;
const OnPoll = () => buildUpdateDecorator('otherMedia', 'poll');
exports.OnPoll = OnPoll;
const OnPollEdit = () => buildUpdateDecorator('pollEdit');
exports.OnPollEdit = OnPollEdit;
const OnPollAnswer = () => buildUpdateDecorator('pollEdit', true);
exports.OnPollAnswer = OnPollAnswer;
const OnUpdate = () => buildUpdateDecorator('update');

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

import { IMessageEntity } from './update.types';
import { IInlineKeyboard, IReplyMarkup } from './keyboard.types';
import { InputMediaTypes } from './media.types';
import { Thumb } from '../classes';
import { InputMediaTypes } from './media.types';
export declare type IOptions = ISendOptions | ISendPhotoOptions | ISendVideoOptions;
export declare type ParseModes = 'HTML' | 'Markdown' | 'MarkdownV2';
export declare type PollTypes = 'quiz' | 'regular';
export interface ISendFetchOptions extends ISendOptions {

@@ -160,2 +161,19 @@ chat_id: number | string;

}
export interface ISendPollFetchOptions extends ISendPollOptions {
chat_id: number | string;
question: string;
options: string[];
}
export interface ISendPollOptions extends IDefaultOptions {
type?: PollTypes;
is_anonymous?: boolean;
allows_multiple_answers?: boolean;
correct_option_id?: number;
explanation?: string;
explanation_parse_mode?: string;
explanation_entities?: IMessageEntity[];
open_period?: number;
close_date?: number;
is_closed?: boolean;
}
export interface ISendMediaGroupOptions extends IDefaultOptions {

@@ -162,0 +180,0 @@ }

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

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

IContact,
IVenue
IVenue,
IPoll
];

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

import { KeyboardTypes } from '../enums';
export interface IReplyMarkup extends IInlineKeyboard, IKeyboard, IPlaceholder {
export interface IReplyMarkup extends IInlineKeyboard, IKeyboard {
}

@@ -9,6 +9,7 @@ export interface IInlineKeyboard {

keyboard?: IButton[][];
resize_keyboard?: boolean;
one_time_keyboard?: boolean;
input_field_placeholder?: string;
selective?: boolean;
}
export interface IPlaceholder {
placeholder?: string;
}
export interface IWebAppButton {

@@ -15,0 +16,0 @@ url?: string;

@@ -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';
export declare type MediaSendTypes = 'location' | 'venue' | 'contact' | 'poll';
export declare type InputMediaTypes = IInputMediaAudio | IInputMediaDocument | IInputMediaPhoto | IInputMediaVideo;

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

import { IChat, IUser } from './chat.types';
import { IReplyMarkup } from './keyboard.types';
import { 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';

@@ -11,2 +12,4 @@ export interface IUpdate {

callback_query?: ICallbackQuery;
poll?: IPoll;
poll_answer?: IPollAnswer;
}

@@ -67,3 +70,3 @@ export interface ICallbackQuery {

game?: any;
poll?: any;
poll?: IPoll;
venue?: IVenue;

@@ -162,2 +165,26 @@ location?: ILocation;

}
export interface IPollOption {
text: string;
voter_count: number;
}
export interface IPoll {
id: string;
question: string;
options: IPollOption[];
total_voter_count: number;
is_closed: boolean;
is_anonymous: boolean;
type: PollTypes;
allows_multiple_answers: boolean;
correct_option_id?: number;
explanation?: string;
explanation_entities?: IMessageEntity[];
open_period?: number;
close_date?: number;
}
export interface IPollAnswer {
poll_id: string;
user: IUser;
option_ids: number[];
}
export {};
{
"name": "nestgram",
"description": "Framework for working with Telegram Bot API on TypeScript like Nest.js",
"version": "1.7.3",
"version": "1.7.4",
"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