nestgram
Advanced tools
Comparing version 1.7.2 to 1.7.3
@@ -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 } 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 } from '..'; | ||
import { Animation, VideoNote } from './Media'; | ||
@@ -24,3 +24,5 @@ export declare class Api { | ||
sendMediaGroup(chatId: string | number, mediaGroup: InputSupportedMedia[], moreOptions?: ISendMediaGroupOptions): Promise<IMessage[]>; | ||
sendLocation(chatId: number | string, latitude: number, longitude: number, moreOptions?: ISendLocationOptions): Promise<IMessage>; | ||
sendLocation(chatId: number | string, latitude: number, longitude: number, keyboard?: Keyboard | null, moreOptions?: ISendLocationOptions): Promise<IMessage>; | ||
sendVenue(chatId: number | string, latitude: number, longitude: number, title: string, address: string, keyboard?: Keyboard | null, moreOptions?: ISendVenueOptions): Promise<IMessage>; | ||
sendContact(chatId: number | string, phone: string, firstName: string, lastName?: string | null, keyboard?: Keyboard | null, moreOptions?: ISendContactOptions): Promise<IMessage>; | ||
answerCallbackQuery(callback_query_id: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>; | ||
@@ -27,0 +29,0 @@ alert(callback_query_id: string, text: string, moreOptions?: IAnswerCallbackQueryOptions): Promise<boolean>; |
@@ -95,5 +95,2 @@ "use strict"; | ||
} | ||
else if (content instanceof __1.Location) { | ||
return this.sendLocation(chatId, content.latitude, content.longitude, moreOptions); | ||
} | ||
} | ||
@@ -117,2 +114,8 @@ if (content instanceof Media_1.Media) { | ||
return this.sendMediaGroup(chatId, content.mediaGroup, moreOptions); | ||
else if (content instanceof __1.Location) | ||
return this.sendLocation(chatId, content.latitude, content.longitude, keyboard, moreOptions); | ||
else if (content instanceof __1.Venue) | ||
return this.sendVenue(chatId, content.latitude, content.longitude, content.title, content.address, keyboard, moreOptions); | ||
else if (content instanceof __1.Contact) | ||
return this.sendContact(chatId, content.phone, content.firstName, content.lastName, keyboard, moreOptions); | ||
else | ||
@@ -233,3 +236,5 @@ throw (0, logger_1.error)("Media file type is not defined. Don't use Media class, use Photo, Video class instead"); | ||
} | ||
sendLocation(chatId, latitude, longitude, moreOptions = {}) { | ||
sendLocation(chatId, latitude, longitude, keyboard = null, moreOptions = {}) { | ||
if (keyboard) | ||
moreOptions.reply_markup = keyboard.buildMarkup(); | ||
return this.callApi('sendLocation', { | ||
@@ -242,2 +247,25 @@ chat_id: chatId, | ||
} | ||
sendVenue(chatId, latitude, longitude, title, address, keyboard = null, moreOptions = {}) { | ||
if (keyboard) | ||
moreOptions.reply_markup = keyboard.buildMarkup(); | ||
return this.callApi('sendVenue', { | ||
chat_id: chatId, | ||
latitude, | ||
longitude, | ||
title, | ||
address, | ||
...moreOptions, | ||
}); | ||
} | ||
sendContact(chatId, phone, firstName, lastName = null, keyboard = null, moreOptions = {}) { | ||
if (keyboard) | ||
moreOptions.reply_markup = keyboard.buildMarkup(); | ||
return this.callApi('sendContact', { | ||
chat_id: chatId, | ||
phone_number: phone, | ||
first_name: firstName, | ||
last_name: lastName, | ||
...moreOptions, | ||
}); | ||
} | ||
answerCallbackQuery(callback_query_id, moreOptions = {}) { | ||
@@ -244,0 +272,0 @@ return this.callApi('answerCallbackQuery', { |
@@ -7,2 +7,4 @@ import { MiddlewareFunction, MessageEntityTypes, MediaFileTypes } from '../..'; | ||
static location(): MiddlewareFunction; | ||
static venue(): MiddlewareFunction; | ||
static contact(): MiddlewareFunction; | ||
static command(commandText?: string): MiddlewareFunction; | ||
@@ -9,0 +11,0 @@ static text(text?: string): MiddlewareFunction; |
@@ -29,2 +29,20 @@ "use strict"; | ||
} | ||
static venue() { | ||
return function use(update, answer, params, next, fail) { | ||
if (!update.message) | ||
return fail(); | ||
else if (!update.message.venue) | ||
return fail(); | ||
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) { | ||
@@ -31,0 +49,0 @@ return function use(update, answer, params, next, fail) { |
@@ -47,2 +47,5 @@ "use strict"; | ||
(_a = message === null || message === void 0 ? void 0 : message.from) === null || _a === void 0 ? void 0 : _a.id, | ||
message === null || message === void 0 ? void 0 : message.location, | ||
message === null || message === void 0 ? void 0 : message.contact, | ||
message === null || message === void 0 ? void 0 : message.venue, | ||
]; | ||
@@ -49,0 +52,0 @@ const handlerMethod = handler.controller[handler.methodKey].bind(handler.controller); |
@@ -11,1 +11,4 @@ export * from './Photo'; | ||
export * from './MediaGroup'; | ||
export * from './Location'; | ||
export * from './Contact'; | ||
export * from './Venue'; |
@@ -27,2 +27,5 @@ "use strict"; | ||
__exportStar(require("./MediaGroup"), exports); | ||
__exportStar(require("./Location"), exports); | ||
__exportStar(require("./Contact"), exports); | ||
__exportStar(require("./Venue"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { MediaFileTypes, MediaPassTypes } from '../../types'; | ||
import { MediaFileTypes, MediaPassTypes, MediaSendTypes } from '../../types'; | ||
import { Thumb } from './Thumb'; | ||
@@ -7,3 +7,3 @@ export declare class Media { | ||
readonly options?: any; | ||
type: MediaFileTypes; | ||
type: MediaFileTypes | MediaSendTypes; | ||
thumb?: Thumb; | ||
@@ -10,0 +10,0 @@ constructor(passType: MediaPassTypes, media: string, options?: any); |
@@ -5,4 +5,3 @@ export * from './MessageCreator'; | ||
export * from './Toast'; | ||
export * from './Location'; | ||
export * from './Forward'; | ||
export * from './Copy'; |
@@ -21,5 +21,4 @@ "use strict"; | ||
__exportStar(require("./Toast"), exports); | ||
__exportStar(require("./Location"), exports); | ||
__exportStar(require("./Forward"), exports); | ||
__exportStar(require("./Copy"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -12,1 +12,4 @@ import { MessageEntityTypes } from '../../types'; | ||
export declare const UserId: () => ParameterDecorator; | ||
export declare const ReceivedLocation: () => ParameterDecorator; | ||
export declare const ReceivedContact: () => ParameterDecorator; | ||
export declare const ReceivedVenue: () => ParameterDecorator; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.UserId = exports.Sender = exports.Params = exports.CommandParams = exports.Entities = exports.Update = exports.Message = exports.Answ = exports.Text = exports.Entity = void 0; | ||
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; | ||
function defineArgumentMetadata(target, propertyKey, parameterIndex, gotIndexName, metadataKey = 'gotIndex') { | ||
@@ -43,2 +43,8 @@ Reflect.defineMetadata(metadataKey, { | ||
exports.UserId = UserId; | ||
const ReceivedLocation = () => buildArgumentDecorator('location'); | ||
exports.ReceivedLocation = ReceivedLocation; | ||
const ReceivedContact = () => buildArgumentDecorator('contact'); | ||
exports.ReceivedContact = ReceivedContact; | ||
const ReceivedVenue = () => buildArgumentDecorator('venue'); | ||
exports.ReceivedVenue = ReceivedVenue; | ||
//# sourceMappingURL=argumets.decorator.js.map |
@@ -14,2 +14,5 @@ "use strict"; | ||
'userId', | ||
'location', | ||
'contact', | ||
'venue', | ||
]; | ||
@@ -16,0 +19,0 @@ function setupArguments(target, propertyName, descriptor) { |
@@ -21,3 +21,5 @@ import { MediaFileTypes, MessageEntityTypes } from '../../types'; | ||
export declare const OnLocation: () => MethodDecorator; | ||
export declare const OnVenue: () => MethodDecorator; | ||
export declare const OnContact: () => MethodDecorator; | ||
export declare const OnUpdate: () => MethodDecorator; | ||
export declare const OnForward: () => MethodDecorator; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OnForward = exports.OnUpdate = 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.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"); | ||
@@ -49,2 +49,6 @@ const middleware_decorator_1 = require("./middleware.decorator"); | ||
exports.OnLocation = OnLocation; | ||
const OnVenue = () => buildUpdateDecorator('venue'); | ||
exports.OnVenue = OnVenue; | ||
const OnContact = () => buildUpdateDecorator('contact'); | ||
exports.OnContact = OnContact; | ||
const OnUpdate = () => buildUpdateDecorator('update'); | ||
@@ -51,0 +55,0 @@ exports.OnUpdate = OnUpdate; |
@@ -109,9 +109,4 @@ import { IMessageEntity } from './update.types'; | ||
} | ||
export interface ICopyMessageOptions extends ISendPhotoOptions { | ||
export interface ICopyMessageOptions extends ISendPhotoOptions, IDefaultOptions { | ||
parse_mode?: ParseModes; | ||
disable_notification?: boolean; | ||
protect_content?: boolean; | ||
reply_to_message_id?: number; | ||
allow_sending_without_reply?: boolean; | ||
reply_markup?: IReplyMarkup; | ||
} | ||
@@ -144,2 +139,24 @@ export interface ICopyMessageFetchOptions extends ICopyMessageOptions, IMessageId { | ||
} | ||
export interface ISendVenueFetchOptions extends ISendVenueOptions { | ||
chat_id: string | number; | ||
latitude: number; | ||
longitude: number; | ||
title: string; | ||
address: string; | ||
} | ||
export interface ISendVenueOptions extends IDefaultOptions { | ||
foursquare_id?: string; | ||
foursquare_type?: string; | ||
google_place_id?: string; | ||
google_place_type?: string; | ||
} | ||
export interface ISendContactFetchOptions extends ISendContactOptions { | ||
chat_id: string | number; | ||
phone_number: string; | ||
first_name: string; | ||
last_name?: string; | ||
} | ||
export interface ISendContactOptions extends IDefaultOptions { | ||
vcard?: string; | ||
} | ||
export interface ISendMediaGroupOptions extends IDefaultOptions { | ||
@@ -146,0 +163,0 @@ } |
import { ControllerClass } from './decorators.types'; | ||
import { MiddlewareFunction } from './middleware.types'; | ||
import { IMessage, IMessageEntity, IUpdate } from './update.types'; | ||
import { Answer, Location, Media, MessageCreator } from '../classes'; | ||
import { IContact, ILocation, IMessage, IMessageEntity, IUpdate, IVenue } from './update.types'; | ||
import { Answer, Media, MessageCreator } from '../classes'; | ||
import { IUser } from './chat.types'; | ||
@@ -20,5 +20,8 @@ export interface IHandler { | ||
IUser | undefined, | ||
number | undefined | ||
number | undefined, | ||
ILocation, | ||
IContact, | ||
IVenue | ||
]; | ||
export declare type ContentTypes = Media | Location | string | undefined | null; | ||
export declare type ContentTypes = Media | string | undefined | null; | ||
export declare type HandlerMethod = ((...args: ArgsTypes) => MessageCreator | ContentTypes) & { | ||
@@ -25,0 +28,0 @@ prototype: { |
@@ -5,2 +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 InputMediaTypes = IInputMediaAudio | IInputMediaDocument | IInputMediaPhoto | IInputMediaVideo; | ||
@@ -7,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' | 'location'; | ||
export declare type SendTypes = 'send' | 'alert' | 'toast' | 'forward' | 'copy'; | ||
export declare type MessageCreatorTypes = MediaFileTypes | 'text' | 'location'; |
@@ -63,7 +63,7 @@ import { IChat, IUser } from './chat.types'; | ||
caption_entities?: IMessageEntity[]; | ||
contact?: any; | ||
contact?: IContact; | ||
dice?: any; | ||
game?: any; | ||
poll?: any; | ||
venue?: any; | ||
venue?: IVenue; | ||
location?: ILocation; | ||
@@ -145,2 +145,18 @@ new_chat_members?: IUser[]; | ||
} | ||
export interface IVenue { | ||
location: ILocation; | ||
title: string; | ||
address: string; | ||
foursquare_id?: string; | ||
foursquare_type?: string; | ||
google_place_id?: string; | ||
google_place_type?: string; | ||
} | ||
export interface IContact { | ||
phone_number: string; | ||
first_name: string; | ||
last_name?: string; | ||
user_id?: number; | ||
vcard?: string; | ||
} | ||
export {}; |
{ | ||
"name": "nestgram", | ||
"description": "Framework for working with Telegram Bot API on TypeScript like Nest.js", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"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
200043
186
2772