puregram
Advanced tools
Comparing version 1.1.8-rc.3 to 1.1.8-rc.4
{ | ||
"name": "puregram", | ||
"version": "1.1.8-rc.3", | ||
"version": "1.1.8-rc.4", | ||
"main": "src/index.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -28,5 +28,5 @@ # puregram | ||
telegram.updates.startPolling(); | ||
console.log('Started polling'); | ||
telegram.updates.startPolling().then( | ||
() => console.log('Started polling') | ||
); | ||
``` | ||
@@ -42,6 +42,15 @@ | ||
### Bots that were made using puregram | ||
* [QiwiBot](https://t.me/qiwionebot) - helps to work with [QIWI](https://qiwi.com) wallet | ||
* [Magnit X](https://t.me/magnitxbot) - saves your money on payments in [Magnit](https://magnit.ru) shop | ||
* [Telegram Anonym Chat](https://t.me/ruanon_bot) - anonymous chat with other people in Telegram | ||
If you want to see your bot here — PM [me](https://t.me/nitrojs) _(I will add up to 10 bots here)_ | ||
## Thanks to | ||
Biggest thanks to [Negezor](https://github.com/negezor) for his [vk-io](https://github.com/negezor/vk-io) library that helped me with this package! | ||
### VK chat | ||
> https://vk.me/join/AJQ1d7n35xXnfBxIB21zACP3 | ||
### Chats | ||
[VK chat](https://vk.me/join/AJQ1d7n35xXnfBxIB21zACP3) | ||
[Telegram chat](https://t.me/puregram_chat) |
@@ -9,2 +9,3 @@ import Keyboard from './keyboard'; | ||
import HTML from './html'; | ||
import APIError from './apierror'; | ||
@@ -20,2 +21,3 @@ export = { | ||
HTML, | ||
APIError | ||
}; |
@@ -9,2 +9,3 @@ let Keyboard = require('./keyboard'); | ||
let HTML = require('./html'); | ||
let APIError = require('./apierror'); | ||
@@ -20,2 +21,3 @@ module.exports = { | ||
HTML, | ||
APIError | ||
}; |
@@ -43,3 +43,3 @@ import Params from "../../typings/params"; | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -60,3 +60,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -75,3 +75,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -89,3 +89,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -101,3 +101,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -117,3 +117,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -127,3 +127,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -135,5 +135,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -145,5 +145,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -155,5 +155,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -165,5 +165,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -186,3 +186,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -189,0 +189,0 @@ /** |
@@ -205,3 +205,3 @@ let { inspect } = require('util'); | ||
chat_id: this.message.chatId, | ||
location, | ||
...location, | ||
...params, | ||
@@ -247,3 +247,3 @@ }); | ||
chat_id: this.message.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -265,3 +265,3 @@ }); | ||
chat_id: this.message.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -283,3 +283,3 @@ }); | ||
chat_id: this.message.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -286,0 +286,0 @@ }); |
@@ -24,2 +24,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventCreated: boolean; | ||
@@ -43,3 +51,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -60,3 +68,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -75,3 +83,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -89,3 +97,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -101,3 +109,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -117,3 +125,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -127,3 +135,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -135,5 +143,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -145,5 +153,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -155,5 +163,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -165,5 +173,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -186,3 +194,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -189,0 +197,0 @@ /** |
@@ -53,2 +53,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventCreated() { | ||
@@ -197,3 +213,3 @@ return this.update.channel_chat_created; | ||
chat_id: this.chatId, | ||
location, | ||
...location, | ||
...params, | ||
@@ -239,3 +255,3 @@ }); | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -257,3 +273,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -275,3 +291,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -278,0 +294,0 @@ }); |
@@ -163,2 +163,8 @@ import Params from "../../typings/params"; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
/** | ||
@@ -180,3 +186,3 @@ * Use this method to send text messages. | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -197,3 +203,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -212,3 +218,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -226,3 +232,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -238,3 +244,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -254,3 +260,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -264,3 +270,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -272,5 +278,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -282,5 +288,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -292,5 +298,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -302,5 +308,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -323,3 +329,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -326,0 +332,0 @@ /** |
@@ -365,5 +365,17 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatId === this.senderId; | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
async send(text = '',params = {}) { | ||
@@ -508,4 +520,4 @@ let response = await this.telegram.api.sendMessage({ | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -550,3 +562,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -568,3 +580,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -586,3 +598,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -589,0 +601,0 @@ }); |
@@ -39,3 +39,3 @@ import Params from "../../typings/params"; | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -56,3 +56,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -71,3 +71,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -85,3 +85,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -97,3 +97,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -113,3 +113,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -123,3 +123,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -131,5 +131,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -141,5 +141,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -151,5 +151,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -161,5 +161,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -182,3 +182,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -185,0 +185,0 @@ /** |
@@ -40,2 +40,351 @@ let { inspect } = require('util'); | ||
async send(text = '', params = {}) { | ||
let response = await this.telegram.api.sendMessage({ | ||
chat_id: this.chatId || this.senderId, | ||
text, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
async reply(text, params = {}) { | ||
return this.send(text, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPhoto(photo, params = {}) { | ||
let response = await this.telegram.api.sendPhoto({ | ||
chat_id: this.chatId, | ||
photo, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPhoto(photo, params = {}) { | ||
return this.sendPhoto(photo, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAudio(audio, params = {}) { | ||
let response = await this.telegram.api.sendAudio({ | ||
chat_id: this.chatId, | ||
audio, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAudio(audio, params = {}) { | ||
return this.sendAudio(audio, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideo(video, params = {}) { | ||
let response = await this.telegram.api.sendVideo({ | ||
chat_id: this.chatId, | ||
video, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideo(video, params = {}) { | ||
return this.sendVideo(video, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAnimation(animation, params = {}) { | ||
let response = await this.telegram.api.sendAnimation({ | ||
chat_id: this.chatId, | ||
animation, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAnimation(animation, params = {}) { | ||
return this.sendAnimation(animation, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideoNote(videoNote, params = {}) { | ||
let response = await this.telegram.api.sendVideoNote({ | ||
chat_id: this.chatId, | ||
video_note: videoNote, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideoNote(videoNote, params = {}) { | ||
return this.sendVideoNote(videoNote, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVoice(voice, params = {}) { | ||
let response = await this.telegram.api.sendVoice({ | ||
chat_id: this.chatId, | ||
voice, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVoice(voice, params = {}) { | ||
return this.sendVoice(voice, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendMediaGroup(media, params = {}) { | ||
let response = await this.telegram.api.sendMediaGroup({ | ||
chat_id: this.chatId, | ||
media, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithMediaGroup(media, params = {}) { | ||
return this.sendMediaGroup(media, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendLocation(location, params = {}) { | ||
let response = await this.telegram.api.sendLocation({ | ||
chat_id: this.chatId, | ||
...location, | ||
...params | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithLocation(location, params = {}) { | ||
return this.sendLocation(location, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async editMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.editMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async stopMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.stopMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async sendVenue(venue, params = {}) { | ||
let response = await this.telegram.api.sendVenue({ | ||
chat_id: this.chatId, | ||
...venue, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVenue(venue, params = {}) { | ||
return this.sendVenue(venue, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendContact(contact, params = {}) { | ||
let response = await this.telegram.api.sendContact({ | ||
chat_id: this.chatId, | ||
...contact, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithContact(contact, params = {}) { | ||
return this.sendContact(contact, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPoll(poll, params = {}) { | ||
let response = await this.telegram.api.sendPoll({ | ||
chat_id: this.chatId, | ||
...poll, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPoll(poll, params = {}) { | ||
return this.sendPoll(poll, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async stopPoll(id, params = {}) { | ||
let response = await this.telegram.api.stopPoll({ | ||
chat_id: this.chatId, | ||
message_id: id, | ||
...params, | ||
}); | ||
return new Poll(response); | ||
} | ||
replyWithContact(poll, params = {}) { | ||
return this.sendPoll(poll, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
sendChatAction(action, params = {}) { | ||
return this.telegram.api.sendChatAction({ | ||
chat_id: this.chatId, | ||
action, | ||
...params, | ||
}); | ||
} | ||
async getUserProfilePhotos(params = {}) { | ||
return new UserProfilePhotos( | ||
await this.telegram.api.getUserProfilePhotos({ | ||
user_id: this.chatId, | ||
...params, | ||
}) | ||
); | ||
} | ||
async editMessageText(text, params = {}) { | ||
let response = await this.telegram.api.editMessageText({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
text, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async editMessageCaption(caption, params = {}) { | ||
let response = await this.telegram.api.editMessageCaption({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
caption, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async editMessageMedia(media, params = {}) { | ||
let response = await this.telegram.api.editMessageMedia({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
media, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async editMessageReplyMarkup(replyMarkup, params = {}) { | ||
let response = await this.telegram.api.editMessageReplyMarkup({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
reply_markup: replyMarkup, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
deleteMessage(params = {}) { | ||
return this.telegram.api.deleteMessage({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendSticker(sticker, params = {}) { | ||
let response = await this.telegram.api.sendSticker({ | ||
chat_id: this.chatId, | ||
sticker, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
async sendDice(params = {}) { | ||
let response = await this.telegram.api.sendDice({ | ||
chat_id: this.chatId, | ||
...params | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
getMyCommands() { | ||
return this.telegram.api.getMyCommands(); | ||
} | ||
setMyCommands() { | ||
return this.telegram.api.setMyCommands(); | ||
} | ||
[inspect.custom](depth, options) { | ||
@@ -42,0 +391,0 @@ let { name } = this.constructor; |
@@ -23,2 +23,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventDeleted: boolean; | ||
@@ -42,3 +50,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -59,3 +67,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -74,3 +82,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -88,3 +96,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -100,3 +108,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -116,3 +124,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -126,3 +134,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -134,5 +142,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -144,5 +152,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -154,5 +162,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -164,5 +172,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -185,3 +193,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -188,0 +196,0 @@ /** |
@@ -51,2 +51,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventDeleted() { | ||
@@ -195,4 +211,4 @@ return this.update.delete_chat_photo; | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -237,3 +253,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -255,3 +271,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -273,3 +289,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -276,0 +292,0 @@ }); |
@@ -157,2 +157,8 @@ import Params from "../../typings/params"; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
/** | ||
@@ -174,3 +180,3 @@ * Use this method to send text messages. | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -191,3 +197,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -206,3 +212,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -220,3 +226,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -232,3 +238,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -248,3 +254,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -258,3 +264,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -266,5 +272,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -276,5 +282,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -286,5 +292,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -296,5 +302,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -317,3 +323,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -320,0 +326,0 @@ /** |
@@ -365,5 +365,17 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatId === this.senderId; | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
async send(text = '',params = {}) { | ||
@@ -508,4 +520,4 @@ let response = await this.telegram.api.sendMessage({ | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -550,3 +562,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -568,3 +580,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -586,3 +598,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -589,0 +601,0 @@ }); |
@@ -157,2 +157,8 @@ import Params from "../../typings/params"; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
/** | ||
@@ -174,3 +180,3 @@ * Use this method to send text messages. | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -191,3 +197,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -206,3 +212,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -220,3 +226,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -232,3 +238,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -248,3 +254,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -258,3 +264,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -266,5 +272,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -276,5 +282,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -286,5 +292,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -296,5 +302,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -317,3 +323,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -320,0 +326,0 @@ /** |
@@ -365,5 +365,17 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatId === this.senderId; | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
async send(text = '',params = {}) { | ||
@@ -508,4 +520,4 @@ let response = await this.telegram.api.sendMessage({ | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -550,3 +562,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -568,3 +580,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -586,3 +598,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -589,0 +601,0 @@ }); |
@@ -23,2 +23,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventCreated: boolean; | ||
@@ -42,3 +50,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -59,3 +67,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -74,3 +82,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -88,3 +96,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -100,3 +108,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -116,3 +124,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -126,3 +134,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -134,5 +142,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -144,5 +152,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -154,5 +162,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -164,5 +172,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -185,3 +193,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -188,0 +196,0 @@ /** |
@@ -51,2 +51,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventCreated() { | ||
@@ -195,4 +211,4 @@ return this.update.group_chat_created; | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -237,3 +253,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -255,3 +271,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -273,3 +289,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -276,0 +292,0 @@ }); |
@@ -24,2 +24,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventInvoice: InvoiceStructure; | ||
@@ -43,3 +51,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -60,3 +68,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -75,3 +83,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -89,3 +97,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -101,3 +109,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -117,3 +125,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -127,3 +135,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -135,5 +143,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -145,5 +153,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -155,5 +163,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -165,5 +173,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -186,3 +194,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -189,0 +197,0 @@ /** |
@@ -51,2 +51,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventInvoice() { | ||
@@ -56,2 +72,327 @@ return new InvoiceStructure(this.update.invoice); | ||
async send(text = '', params = {}) { | ||
let response = await this.telegram.api.sendMessage({ | ||
chat_id: this.chatId || this.senderId, | ||
text, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
reply(text, params = {}) { | ||
return this.send(text, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPhoto(photo, params = {}) { | ||
let response = await this.telegram.api.sendPhoto({ | ||
chat_id: this.chatId, | ||
photo, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPhoto(photo, params = {}) { | ||
return this.sendPhoto(photo, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAudio(audio, params = {}) { | ||
let response = await this.telegram.api.sendAudio({ | ||
chat_id: this.chatId, | ||
audio, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAudio(audio, params = {}) { | ||
return this.sendAudio(audio, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideo(video, params = {}) { | ||
let response = await this.telegram.api.sendVideo({ | ||
chat_id: this.chatId, | ||
video, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideo(video, params = {}) { | ||
return this.sendVideo(video, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAnimation(animation, params = {}) { | ||
let response = await this.telegram.api.sendAnimation({ | ||
chat_id: this.chatId, | ||
animation, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAnimation(animation, params = {}) { | ||
return this.sendAnimation(animation, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideoNote(videoNote, params = {}) { | ||
let response = await this.telegram.api.sendVideoNote({ | ||
chat_id: this.chatId, | ||
video_note: videoNote, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideoNote(videoNote, params = {}) { | ||
return this.sendVideoNote(videoNote, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVoice(voice, params = {}) { | ||
let response = await this.telegram.api.sendVoice({ | ||
chat_id: this.chatId, | ||
voice, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVoice(voice, params = {}) { | ||
return this.sendVoice(voice, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendMediaGroup(media, params = {}) { | ||
let response = await this.telegram.api.sendMediaGroup({ | ||
chat_id: this.chatId, | ||
media, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithMediaGroup(media, params = {}) { | ||
return this.sendMediaGroup(media, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendLocation(location, params = {}) { | ||
let response = await this.telegram.api.sendLocation({ | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithLocation(location, params = {}) { | ||
return this.sendLocation(location, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async editMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.editMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async stopMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.stopMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async sendVenue(venue, params = {}) { | ||
let response = await this.telegram.api.sendVenue({ | ||
chat_id: this.chatId, | ||
...venue, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVenue(venue, params = {}) { | ||
return this.sendVenue(venue, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendContact(contact, params = {}) { | ||
let response = await this.telegram.api.sendContact({ | ||
chat_id: this.chatId, | ||
...contact, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithContact(contact, params = {}) { | ||
return this.sendContact(contact, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPoll(poll, params = {}) { | ||
let response = await this.telegram.api.sendPoll({ | ||
chat_id: this.chatId, | ||
...poll, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPoll(poll, params = {}) { | ||
return this.sendPoll(poll, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async stopPoll(id, params = {}) { | ||
let response = await this.telegram.api.stopPoll({ | ||
chat_id: this.chatId, | ||
message_id: id, | ||
...params, | ||
}); | ||
return new Poll(response); | ||
} | ||
sendChatAction(action, params = {}) { | ||
return this.telegram.api.sendChatAction({ | ||
chat_id: this.chatId, | ||
action, | ||
...params, | ||
}); | ||
} | ||
async getUserProfilePhotos(params = {}) { | ||
return new UserProfilePhotos( | ||
await this.telegram.api.getUserProfilePhotos({ | ||
user_id: this.chatId, | ||
...params, | ||
}) | ||
); | ||
} | ||
async editMessageText(text, params = {}) { | ||
let response = await this.telegram.api.editMessageText({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
text, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async editMessageCaption(caption, params = {}) { | ||
let response = await this.telegram.api.editMessageCaption({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
caption, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async editMessageMedia(media, params = {}) { | ||
let response = await this.telegram.api.editMessageMedia({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
media, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async editMessageReplyMarkup(replyMarkup, params = {}) { | ||
let response = await this.telegram.api.editMessageReplyMarkup({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
reply_markup: replyMarkup, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
deleteMessage(params = {}) { | ||
return this.telegram.api.deleteMessage({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendSticker(sticker, params = {}) { | ||
let response = await this.telegram.api.sendSticker({ | ||
chat_id: this.chatId, | ||
sticker, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
async sendDice(params = {}) { | ||
@@ -58,0 +399,0 @@ let response = await this.telegram.api.sendDice({ |
@@ -23,2 +23,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventMember: Interfaces.IUser; | ||
@@ -42,3 +50,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -59,3 +67,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -74,3 +82,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -88,3 +96,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -100,3 +108,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -116,3 +124,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -126,3 +134,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -134,5 +142,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -144,5 +152,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -154,5 +162,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -164,5 +172,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -185,3 +193,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -188,0 +196,0 @@ /** |
@@ -51,2 +51,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventMember() { | ||
@@ -195,4 +211,4 @@ return new User(this.update.left_chat_member); | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -237,3 +253,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -255,3 +271,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -273,3 +289,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -276,0 +292,0 @@ }); |
@@ -398,2 +398,17 @@ import Params from '../../typings/params'; | ||
/** | ||
* Is this message sent to the group? | ||
*/ | ||
public isGroup: boolean; | ||
/** | ||
* Is this message sent to the channel? | ||
*/ | ||
public isChannel: boolean; | ||
/** | ||
* Is this message sent to the supergroup? | ||
*/ | ||
public isSupergroup: boolean; | ||
/** | ||
* Use this method to send text messages. | ||
@@ -499,5 +514,5 @@ * | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -509,5 +524,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -519,5 +534,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -529,5 +544,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -550,3 +565,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -553,0 +568,0 @@ /** |
@@ -403,5 +403,17 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatId === this.senderId; | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
async send(text = '', params = {}) { | ||
@@ -587,3 +599,3 @@ let response = await this.telegram.api.sendMessage({ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -605,3 +617,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -623,3 +635,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -626,0 +638,0 @@ }); |
@@ -23,2 +23,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventId: number; | ||
@@ -42,3 +50,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -59,3 +67,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -74,3 +82,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -88,3 +96,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -100,3 +108,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -116,3 +124,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -126,3 +134,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -134,5 +142,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -144,5 +152,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -154,5 +162,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -164,5 +172,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -185,3 +193,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -188,0 +196,0 @@ /** |
@@ -49,2 +49,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventId() { | ||
@@ -54,2 +70,328 @@ return this.update.migrate_from_chat_id; | ||
async send(text = '', params = {}) { | ||
let response = await this.telegram.api.sendMessage({ | ||
chat_id: this.chatId || this.senderId, | ||
text, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
reply(text, params = {}) { | ||
return this.send(text, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPhoto(photo, params = {}) { | ||
let response = await this.telegram.api.sendPhoto({ | ||
chat_id: this.chatId, | ||
photo, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPhoto(photo, params = {}) { | ||
return this.sendPhoto(photo, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAudio(audio, params = {}) { | ||
let response = await this.telegram.api.sendAudio({ | ||
chat_id: this.chatId, | ||
audio, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAudio(audio, params = {}) { | ||
return this.sendAudio(audio, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideo(video, params = {}) { | ||
let response = await this.telegram.api.sendVideo({ | ||
chat_id: this.chatId, | ||
video, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideo(video, params = {}) { | ||
return this.sendVideo(video, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAnimation(animation, params = {}) { | ||
let response = await this.telegram.api.sendAnimation({ | ||
chat_id: this.chatId, | ||
animation, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAnimation(animation, params = {}) { | ||
return this.sendAnimation(animation, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideoNote(videoNote, params = {}) { | ||
let response = await this.telegram.api.sendVideoNote({ | ||
chat_id: this.chatId, | ||
video_note: videoNote, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideoNote(videoNote, params = {}) { | ||
return this.sendVideoNote(videoNote, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVoice(voice, params = {}) { | ||
let response = await this.telegram.api.sendVoice({ | ||
chat_id: this.chatId, | ||
voice, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVoice(voice, params = {}) { | ||
return this.sendVoice(voice, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendMediaGroup(media, params = {}) { | ||
let response = await this.telegram.api.sendMediaGroup({ | ||
chat_id: this.chatId, | ||
media, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithMediaGroup(media, params = {}) { | ||
return this.sendMediaGroup(media, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendLocation(location, params = {}) { | ||
let response = await this.telegram.api.sendLocation({ | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithLocation(location, params = {}) { | ||
return this.sendLocation(location, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async editMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.editMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async stopMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.stopMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async sendVenue(venue, params = {}) { | ||
let response = await this.telegram.api.sendVenue({ | ||
chat_id: this.chatId, | ||
...venue, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVenue(venue, params = {}) { | ||
return this.sendVenue(venue, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendContact(contact, params = {}) { | ||
let response = await this.telegram.api.sendContact({ | ||
chat_id: this.chatId, | ||
...contact, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithContact(contact, params = {}) { | ||
return this.sendContact(contact, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPoll(poll, params = {}) { | ||
let response = await this.telegram.api.sendPoll({ | ||
chat_id: this.chatId, | ||
...poll, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPoll(poll, params = {}) { | ||
return this.sendPoll(poll, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async stopPoll(id, params = {}) { | ||
let response = await this.telegram.api.stopPoll({ | ||
chat_id: this.chatId, | ||
message_id: id, | ||
...params, | ||
}); | ||
return new Poll(response); | ||
} | ||
sendChatAction(action, params = {}) { | ||
return this.telegram.api.sendChatAction({ | ||
chat_id: this.chatId, | ||
action, | ||
...params, | ||
}); | ||
} | ||
async getUserProfilePhotos(params = {}) { | ||
return new UserProfilePhotos( | ||
await this.telegram.api.getUserProfilePhotos({ | ||
user_id: this.chatId, | ||
...params, | ||
}) | ||
); | ||
} | ||
async editMessageText(text, params = {}) { | ||
let response = await this.telegram.api.editMessageText({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
text, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async editMessageCaption(caption, params = {}) { | ||
let response = await this.telegram.api.editMessageCaption({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
caption, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async editMessageMedia(media, params = {}) { | ||
let response = await this.telegram.api.editMessageMedia({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
media, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async editMessageReplyMarkup(replyMarkup, params = {}) { | ||
let response = await this.telegram.api.editMessageReplyMarkup({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
reply_markup: replyMarkup, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
deleteMessage(params = {}) { | ||
return this.telegram.api.deleteMessage({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendSticker(sticker, params = {}) { | ||
let response = await this.telegram.api.sendSticker({ | ||
chat_id: this.chatId, | ||
sticker, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
async sendDice(params = {}) { | ||
@@ -56,0 +398,0 @@ let response = await this.telegram.api.sendDice({ |
@@ -23,2 +23,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventId: number; | ||
@@ -42,3 +50,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -59,3 +67,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -74,3 +82,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -88,3 +96,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -100,3 +108,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -116,3 +124,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -126,3 +134,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -134,5 +142,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -144,5 +152,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -154,5 +162,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -164,5 +172,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -185,3 +193,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -188,0 +196,0 @@ /** |
@@ -49,2 +49,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventId() { | ||
@@ -54,2 +70,334 @@ return this.update.migrate_to_chat_id; | ||
async send(text = '',params = {}) { | ||
let response = await this.telegram.api.sendMessage({ | ||
chat_id: this.chatId || this.senderId, | ||
text, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
async reply(text, params = {}) { | ||
return this.send(text, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPhoto(photo, params = {}) { | ||
let response = await this.telegram.api.sendPhoto({ | ||
chat_id: this.chatId, | ||
photo, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPhoto(photo, params = {}) { | ||
return this.sendPhoto(photo, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAudio(audio, params = {}) { | ||
let response = await this.telegram.api.sendAudio({ | ||
chat_id: this.chatId, | ||
audio, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAudio(audio, params = {}) { | ||
return this.sendAudio(audio, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideo(video, params = {}) { | ||
let response = await this.telegram.api.sendVideo({ | ||
chat_id: this.chatId, | ||
video, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideo(video, params = {}) { | ||
return this.sendVideo(video, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAnimation(animation, params = {}) { | ||
let response = await this.telegram.api.sendAnimation({ | ||
chat_id: this.chatId, | ||
animation, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAnimation(animation, params = {}) { | ||
return this.sendAnimation(animation, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideoNote(videoNote, params = {}) { | ||
let response = await this.telegram.api.sendVideoNote({ | ||
chat_id: this.chatId, | ||
video_note: videoNote, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideoNote(videoNote, params = {}) { | ||
return this.sendVideoNote(videoNote, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVoice(voice, params = {}) { | ||
let response = await this.telegram.api.sendVoice({ | ||
chat_id: this.chatId, | ||
voice, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVoice(voice, params = {}) { | ||
return this.sendVoice(voice, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendMediaGroup(media, params = {}) { | ||
let response = await this.telegram.api.sendMediaGroup({ | ||
chat_id: this.chatId, | ||
media, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithMediaGroup(media, params = {}) { | ||
return this.sendMediaGroup(media, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendLocation(location, params = {}) { | ||
let response = await this.telegram.api.sendLocation({ | ||
chat_id: this.chatId, | ||
...location, | ||
...params | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithLocation(location, params = {}) { | ||
return this.sendLocation(location, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async editMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.editMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async stopMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.stopMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async sendVenue(venue, params = {}) { | ||
let response = await this.telegram.api.sendVenue({ | ||
chat_id: this.chatId, | ||
...venue, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVenue(venue, params = {}) { | ||
return this.sendVenue(venue, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendContact(contact, params = {}) { | ||
let response = await this.telegram.api.sendContact({ | ||
chat_id: this.chatId, | ||
...contact, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithContact(contact, params = {}) { | ||
return this.sendContact(contact, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPoll(poll, params = {}) { | ||
let response = await this.telegram.api.sendPoll({ | ||
chat_id: this.chatId, | ||
...poll, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPoll(poll, params = {}) { | ||
return this.sendPoll(poll, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async stopPoll(id, params = {}) { | ||
let response = await this.telegram.api.stopPoll({ | ||
chat_id: this.chatId, | ||
message_id: id, | ||
...params, | ||
}); | ||
return new Poll(response); | ||
} | ||
replyWithContact(poll, params = {}) { | ||
return this.sendPoll(poll, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
sendChatAction(action, params = {}) { | ||
return this.telegram.api.sendChatAction({ | ||
chat_id: this.chatId, | ||
action, | ||
...params, | ||
}); | ||
} | ||
async getUserProfilePhotos(params = {}) { | ||
return new UserProfilePhotos( | ||
await this.telegram.api.getUserProfilePhotos({ | ||
user_id: this.chatId, | ||
...params, | ||
}) | ||
); | ||
} | ||
async editMessageText(text, params = {}) { | ||
let response = await this.telegram.api.editMessageText({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
text, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async editMessageCaption(caption, params = {}) { | ||
let response = await this.telegram.api.editMessageCaption({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
caption, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async editMessageMedia(media, params = {}) { | ||
let response = await this.telegram.api.editMessageMedia({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
media, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async editMessageReplyMarkup(replyMarkup, params = {}) { | ||
let response = await this.telegram.api.editMessageReplyMarkup({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
reply_markup: replyMarkup, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
deleteMessage(params = {}) { | ||
return this.telegram.api.deleteMessage({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendSticker(sticker, params = {}) { | ||
let response = await this.telegram.api.sendSticker({ | ||
chat_id: this.chatId, | ||
sticker, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
async sendDice(params = {}) { | ||
@@ -56,0 +404,0 @@ let response = await this.telegram.api.sendDice({ |
@@ -23,2 +23,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventMembers: Array<Interfaces.IUser>; | ||
@@ -42,3 +50,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -59,3 +67,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -74,3 +82,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -88,3 +96,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -100,3 +108,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -116,3 +124,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -126,3 +134,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -134,5 +142,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -144,5 +152,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -154,5 +162,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -164,5 +172,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -185,3 +193,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -188,0 +196,0 @@ /** |
@@ -51,2 +51,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventMembers() { | ||
@@ -197,4 +213,4 @@ return this.update.new_chat_members.map( | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -239,3 +255,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -257,3 +273,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -275,3 +291,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -278,0 +294,0 @@ }); |
@@ -23,2 +23,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventPhoto: Interfaces.PhotoAttachment; | ||
@@ -42,3 +50,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -59,3 +67,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -74,3 +82,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -88,3 +96,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -100,3 +108,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -116,3 +124,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -126,3 +134,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -134,5 +142,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -144,5 +152,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -154,5 +162,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -164,5 +172,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -185,3 +193,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -188,0 +196,0 @@ /** |
@@ -53,2 +53,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventPhoto() { | ||
@@ -201,4 +217,4 @@ return new PhotoAttachment( | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -243,3 +259,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -261,3 +277,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -279,3 +295,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -282,0 +298,0 @@ }); |
@@ -23,2 +23,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventTitle: string; | ||
@@ -42,3 +50,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -59,3 +67,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -74,3 +82,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -88,3 +96,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -100,3 +108,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -116,3 +124,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -126,3 +134,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -134,5 +142,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -144,5 +152,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -154,5 +162,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -164,5 +172,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -185,3 +193,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -188,0 +196,0 @@ /** |
@@ -51,2 +51,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventTitle() { | ||
@@ -195,4 +211,4 @@ return this.update.new_chat_title; | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -237,3 +253,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -255,3 +271,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -273,3 +289,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -276,0 +292,0 @@ }); |
@@ -23,2 +23,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventMessage: Interfaces.IMessage; | ||
@@ -42,3 +50,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -59,3 +67,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -74,3 +82,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -88,3 +96,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -100,3 +108,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -116,3 +124,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -126,3 +134,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -134,5 +142,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -144,5 +152,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -154,5 +162,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -164,5 +172,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -185,3 +193,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -188,0 +196,0 @@ /** |
@@ -52,2 +52,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventMessage() { | ||
@@ -199,4 +215,4 @@ return new Message( | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -241,3 +257,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -259,3 +275,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -277,3 +293,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -280,0 +296,0 @@ }); |
@@ -35,3 +35,3 @@ let { inspect } = require('util'); | ||
} | ||
get invoicePayload() { | ||
@@ -38,0 +38,0 @@ return this.update.invoice_payload; |
@@ -164,2 +164,8 @@ import Params from "../../typings/params"; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
/** | ||
@@ -181,3 +187,3 @@ * Use this method to send text messages. | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -198,3 +204,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -213,3 +219,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -227,3 +233,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -239,3 +245,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -255,3 +261,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -265,3 +271,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -273,5 +279,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -283,5 +289,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -293,5 +299,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -303,5 +309,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -324,3 +330,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -327,0 +333,0 @@ /** |
@@ -43,2 +43,22 @@ let { inspect } = require('util'); | ||
get chatType() { | ||
return this.chat.type; | ||
} | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get forwardFrom() { | ||
@@ -155,3 +175,3 @@ let { forward_from: forwardFrom } = this.context; | ||
} | ||
get venue() { | ||
@@ -229,2 +249,334 @@ return this.context.venue || null; | ||
async send(text = '',params = {}) { | ||
let response = await this.telegram.api.sendMessage({ | ||
chat_id: this.chatId || this.senderId, | ||
text, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
async reply(text, params = {}) { | ||
return this.send(text, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPhoto(photo, params = {}) { | ||
let response = await this.telegram.api.sendPhoto({ | ||
chat_id: this.chatId, | ||
photo, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPhoto(photo, params = {}) { | ||
return this.sendPhoto(photo, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAudio(audio, params = {}) { | ||
let response = await this.telegram.api.sendAudio({ | ||
chat_id: this.chatId, | ||
audio, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAudio(audio, params = {}) { | ||
return this.sendAudio(audio, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideo(video, params = {}) { | ||
let response = await this.telegram.api.sendVideo({ | ||
chat_id: this.chatId, | ||
video, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideo(video, params = {}) { | ||
return this.sendVideo(video, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendAnimation(animation, params = {}) { | ||
let response = await this.telegram.api.sendAnimation({ | ||
chat_id: this.chatId, | ||
animation, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithAnimation(animation, params = {}) { | ||
return this.sendAnimation(animation, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVideoNote(videoNote, params = {}) { | ||
let response = await this.telegram.api.sendVideoNote({ | ||
chat_id: this.chatId, | ||
video_note: videoNote, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVideoNote(videoNote, params = {}) { | ||
return this.sendVideoNote(videoNote, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendVoice(voice, params = {}) { | ||
let response = await this.telegram.api.sendVoice({ | ||
chat_id: this.chatId, | ||
voice, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVoice(voice, params = {}) { | ||
return this.sendVoice(voice, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendMediaGroup(media, params = {}) { | ||
let response = await this.telegram.api.sendMediaGroup({ | ||
chat_id: this.chatId, | ||
media, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithMediaGroup(media, params = {}) { | ||
return this.sendMediaGroup(media, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendLocation(location, params = {}) { | ||
let response = await this.telegram.api.sendLocation({ | ||
chat_id: this.chatId, | ||
...location, | ||
...params | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithLocation(location, params = {}) { | ||
return this.sendLocation(location, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async editMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.editMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async stopMessageLiveLocation(params = {}) { | ||
let response = await this.telegram.api.stopMessageLiveLocation({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
return response === true | ||
? true | ||
: new MessageContext(this.telegram, response); | ||
} | ||
async sendVenue(venue, params = {}) { | ||
let response = await this.telegram.api.sendVenue({ | ||
chat_id: this.chatId, | ||
...venue, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithVenue(venue, params = {}) { | ||
return this.sendVenue(venue, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendContact(contact, params = {}) { | ||
let response = await this.telegram.api.sendContact({ | ||
chat_id: this.chatId, | ||
...contact, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithContact(contact, params = {}) { | ||
return this.sendContact(contact, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendPoll(poll, params = {}) { | ||
let response = await this.telegram.api.sendPoll({ | ||
chat_id: this.chatId, | ||
...poll, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
replyWithPoll(poll, params = {}) { | ||
return this.sendPoll(poll, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async stopPoll(id, params = {}) { | ||
let response = await this.telegram.api.stopPoll({ | ||
chat_id: this.chatId, | ||
message_id: id, | ||
...params, | ||
}); | ||
return new Poll(response); | ||
} | ||
replyWithContact(poll, params = {}) { | ||
return this.sendPoll(poll, { | ||
reply_to_message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
sendChatAction(action, params = {}) { | ||
return this.telegram.api.sendChatAction({ | ||
chat_id: this.chatId, | ||
action, | ||
...params, | ||
}); | ||
} | ||
async getUserProfilePhotos(params = {}) { | ||
return new UserProfilePhotos( | ||
await this.telegram.api.getUserProfilePhotos({ | ||
user_id: this.chatId, | ||
...params, | ||
}) | ||
); | ||
} | ||
async editMessageText(text, params = {}) { | ||
let response = await this.telegram.api.editMessageText({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
text, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async editMessageCaption(caption, params = {}) { | ||
let response = await this.telegram.api.editMessageCaption({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
caption, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async editMessageMedia(media, params = {}) { | ||
let response = await this.telegram.api.editMessageMedia({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
media, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
async editMessageReplyMarkup(replyMarkup, params = {}) { | ||
let response = await this.telegram.api.editMessageReplyMarkup({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
reply_markup: replyMarkup, | ||
...params, | ||
}); | ||
return response !== true | ||
? new MessageContext(this.telegram, response) | ||
: true; | ||
} | ||
deleteMessage(params = {}) { | ||
return this.telegram.api.deleteMessage({ | ||
chat_id: this.chatId, | ||
message_id: this.id, | ||
...params, | ||
}); | ||
} | ||
async sendSticker(sticker, params = {}) { | ||
let response = await this.telegram.api.sendSticker({ | ||
chat_id: this.chatId, | ||
sticker, | ||
...params, | ||
}); | ||
return new MessageContext(this.telegram, response); | ||
} | ||
async sendDice(params = {}) { | ||
@@ -231,0 +583,0 @@ let response = await this.telegram.api.sendDice({ |
@@ -25,2 +25,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventPayment: Interfaces.ISuccessfulPayment; | ||
@@ -44,3 +52,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -61,3 +69,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -76,3 +84,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -90,3 +98,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -102,3 +110,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -118,3 +126,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -128,3 +136,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -136,5 +144,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -146,5 +154,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -156,5 +164,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -166,5 +174,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -187,3 +195,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -190,0 +198,0 @@ /** |
@@ -52,2 +52,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventPayment() { | ||
@@ -196,4 +212,4 @@ return new SuccessfulPaymentStructure(this.update.successful_payment); | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -238,3 +254,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -256,3 +272,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -274,3 +290,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -277,0 +293,0 @@ }); |
@@ -25,2 +25,10 @@ import Params from "../../typings/params"; | ||
public isPM: boolean; | ||
public isGroup: boolean; | ||
public isChannel: boolean; | ||
public isSupergroup: boolean; | ||
public eventCreated: boolean; | ||
@@ -44,3 +52,3 @@ | ||
public replyWithPhoto(photo: string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
public replyWithPhoto(photo: Interfaces.IInputFile | string, params: Params.ISendPhotoParams): Promise<MessageContext>; | ||
@@ -61,3 +69,3 @@ /** | ||
public replyWithAudio(audio: string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
public replyWithAudio(audio: Interfaces.IInputFile | string, params: Params.ISendAudioParams): Promise<MessageContext>; | ||
@@ -76,3 +84,3 @@ /** | ||
public replyWithVideo(video: string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
public replyWithVideo(video: Interfaces.IInputFile | string, params: Params.ISendVideoParams): Promise<MessageContext>; | ||
@@ -90,3 +98,3 @@ /** | ||
public replyWithAnimation(animation: string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
public replyWithAnimation(animation: Interfaces.IInputFile | string, params: Params.ISendAnimationParams): Promise<MessageContext>; | ||
@@ -102,3 +110,3 @@ /** | ||
public replyWithVideoNote(videoNote: string, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
public replyWithVideoNote(videoNote: Interfaces.IInputFile, params: Params.ISendVideoNoteParams): Promise<MessageContext>; | ||
@@ -118,3 +126,3 @@ /** | ||
public replyWithVoice(voice: string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
public replyWithVoice(voice: Interfaces.IInputFile | string, params: Params.ISendVoiceParams): Promise<MessageContext>; | ||
@@ -128,3 +136,3 @@ /** | ||
public replyWithMediaGroup(media: string, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
public replyWithMediaGroup(media: Array<Interfaces.IInputMediaPhoto | Interfaces.IInputMediaVideo>, params: Params.ISendMediaGroupParams): Promise<MessageContext>; | ||
@@ -136,5 +144,5 @@ /** | ||
*/ | ||
public sendLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public sendLocation(location: Params.ISendLocationParams, params?: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: string, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
public replyWithLocation(location: Params.ISendLocationParams, params: Params.ISendLocationParams): Promise<MessageContext>; | ||
@@ -146,5 +154,5 @@ /** | ||
*/ | ||
public sendVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public sendVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: string, params: Params.ISendVenueParams): Promise<MessageContext>; | ||
public replyWithVenue(venue: Params.ISendVenueParams, params?: Params.ISendVenueParams): Promise<MessageContext>; | ||
@@ -156,5 +164,5 @@ /** | ||
*/ | ||
public sendContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public sendContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: string, params: Params.ISendContactParams): Promise<MessageContext>; | ||
public replyWithContact(contact: Params.ISendContactParams, params?: Params.ISendContactParams): Promise<MessageContext>; | ||
@@ -166,5 +174,5 @@ /** | ||
*/ | ||
public sendPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public sendPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: string, params: Params.ISendPollParams): Promise<MessageContext>; | ||
public replyWithPoll(poll: Params.ISendPollParams, params?: Params.ISendPollParams): Promise<MessageContext>; | ||
@@ -187,3 +195,3 @@ /** | ||
*/ | ||
public sendChatAction(action: Types.ChatActions, params: Params.ISendChatActionParams): Promise<true>; | ||
public sendChatAction(action: Types.ChatActions, params?: Params.ISendChatActionParams): Promise<true>; | ||
@@ -190,0 +198,0 @@ /** |
@@ -51,2 +51,18 @@ let { inspect } = require('util'); | ||
get isPM() { | ||
return this.chatType === 'private'; | ||
} | ||
get isGroup() { | ||
return this.chatType === 'group'; | ||
} | ||
get isChannel() { | ||
return this.chatType === 'channel'; | ||
} | ||
get isSupergroup() { | ||
return this.chatType === 'supergroup'; | ||
} | ||
get eventCreated() { | ||
@@ -195,4 +211,4 @@ return this.update.supergroup_chat_created; | ||
chat_id: this.chatId, | ||
location, | ||
...params, | ||
...location, | ||
...params | ||
}); | ||
@@ -237,3 +253,3 @@ | ||
chat_id: this.chatId, | ||
venue, | ||
...venue, | ||
...params, | ||
@@ -255,3 +271,3 @@ }); | ||
chat_id: this.chatId, | ||
contact, | ||
...contact, | ||
...params, | ||
@@ -273,3 +289,3 @@ }); | ||
chat_id: this.chatId, | ||
poll, | ||
...poll, | ||
...params, | ||
@@ -276,0 +292,0 @@ }); |
@@ -16,2 +16,3 @@ let Telegram = require('./telegram'); | ||
HTML, | ||
APIError | ||
} = require('./attachments'); | ||
@@ -33,2 +34,3 @@ | ||
CallbackQuery, | ||
APIError | ||
}; |
@@ -44,3 +44,3 @@ import Params from '../typings/params'; | ||
public startPolling(): void; | ||
public startPolling(): Promise<void>; | ||
public stopPolling(): void; | ||
@@ -47,0 +47,0 @@ public use(middleware: Middleware<Context>): this; |
@@ -127,3 +127,3 @@ let middlewareIo = require('middleware-io'); | ||
try { | ||
this.startFetchLoop(); | ||
return this.startFetchLoop(); | ||
} catch (e) { | ||
@@ -130,0 +130,0 @@ this.isStarted = false; |
@@ -15,2 +15,3 @@ import Context from '../src/contexts/context'; | ||
HTML, | ||
APIError | ||
} from '../src/index'; | ||
@@ -32,2 +33,3 @@ | ||
CallbackQuery, | ||
APIError | ||
}; |
771239
23321
55