Added several methods introduced in node-telegram-bot-api v0.30.0

This commit is contained in:
xc-zhang-office
2018-06-01 15:28:16 +08:00
parent 9fb3214e64
commit 698e6953ad
2 changed files with 34 additions and 2 deletions

View File

@@ -4,13 +4,14 @@
// Agadar <https://github.com/agadar>
// Giorgio Garasto <https://github.com/Dabolus>
// Kallu609 <https://github.com/Kallu609>
// XC-Zhang <https://github.com/XC-Zhang>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
import { EventEmitter } from 'events';
import { Stream } from 'stream';
import { Stream, Readable } from 'stream';
import { ServerOptions } from 'https';
import { Options } from 'request';
@@ -58,6 +59,11 @@ declare namespace TelegramBot {
restart?: boolean;
}
interface StopPollingOptions {
cancel?: boolean;
reason?: string;
}
interface SetWebHookOptions {
url?: string;
certificate?: string | Stream;
@@ -136,6 +142,10 @@ declare namespace TelegramBot {
type SendLocationOptions = SendBasicOptions;
type EditMessageLiveLocationOptions = EditMessageCaptionOptions;
type StopMessageLiveLocationOptions = EditMessageCaptionOptions;
interface SendVenueOptions extends SendBasicOptions {
foursquare_id?: string;
}
@@ -147,6 +157,7 @@ declare namespace TelegramBot {
type SendGameOptions = SendBasicOptions;
interface SendInvoiceOptions extends SendBasicOptions {
provider_data?: string;
photo_url?: string;
photo_size?: number;
photo_width?: number;
@@ -818,7 +829,7 @@ declare class TelegramBot extends EventEmitter {
startPolling(options?: TelegramBot.StartPollingOptions): Promise<any>;
stopPolling(): Promise<any>;
stopPolling(options?: TelegramBot.StopPollingOptions): Promise<any>;
isPolling(): boolean;
@@ -886,6 +897,11 @@ declare class TelegramBot extends EventEmitter {
unpinChatMessage(chatId: number | string): Promise<boolean | Error>;
answerCallbackQuery(callbackQueryId: string, options?: Partial<TelegramBot.AnswerCallbackQueryOptions>): Promise<boolean | Error>;
/**
* @deprecated since version 0.30.0
*/
answerCallbackQuery(options?: TelegramBot.AnswerCallbackQueryOptions): Promise<boolean | Error>;
editMessageText(text: string, options?: TelegramBot.EditMessageTextOptions): Promise<TelegramBot.Message | boolean | Error>;
@@ -898,6 +914,10 @@ declare class TelegramBot extends EventEmitter {
sendLocation(chatId: number | string, latitude: number, longitude: number, options?: TelegramBot.SendLocationOptions): Promise<TelegramBot.Message | Error>;
editMessageLiveLocation(latitude: number, longitude: number, options?: TelegramBot.EditMessageLiveLocationOptions): Promise<TelegramBot.Message | boolean | Error>;
stopMessageLiveLocation(options?: TelegramBot.StopMessageLiveLocationOptions): Promise<TelegramBot.Message | boolean | Error>;
sendVenue(chatId: number | string, latitude: number, longitude: number, title: string, address: string, options?: TelegramBot.SendVenueOptions): Promise<TelegramBot.Message | Error>;
sendContact(chatId: number | string, phoneNumber: string, firstName: string, options?: TelegramBot.SendContactOptions): Promise<TelegramBot.Message | Error>;
@@ -906,6 +926,8 @@ declare class TelegramBot extends EventEmitter {
getFileLink(fileId: string): Promise<string | Error>;
getFileStream(fileId: string): Readable;
downloadFile(fileId: string, downloadDir: string): Promise<string | Error>;
onText(regexp: RegExp, callback: ((msg: TelegramBot.Message, match: RegExpExecArray | null) => void)): void;
@@ -926,6 +948,10 @@ declare class TelegramBot extends EventEmitter {
leaveChat(chatId: number | string): Promise<boolean | Error>;
setChatStickerSet(chatId: number | string, stickerSetName: string): Promise<boolean | Error>;
deleteChatStickerSet(chatId: number | string): Promise<boolean | Error>;
sendGame(chatId: number | string, gameShortName: string, options?: TelegramBot.SendGameOptions): Promise<TelegramBot.Message | Error>;
setGameScore(userId: string, score: number, options?: TelegramBot.SetGameScoreOptions): Promise<TelegramBot.Message | boolean | Error>;

View File

@@ -44,6 +44,7 @@ MyTelegramBot.setChatTitle(1234, 'Chat Title');
MyTelegramBot.setChatDescription(1234, 'Chat Description');
MyTelegramBot.pinChatMessage(1234, 'Pinned Message');
MyTelegramBot.unpinChatMessage(1234);
MyTelegramBot.answerCallbackQuery('432832');
MyTelegramBot.answerCallbackQuery({ callback_query_id: '432832' });
MyTelegramBot.editMessageText('test-text', { disable_web_page_preview: true });
MyTelegramBot.editMessageCaption('My Witty Caption', { message_id: 1245 });
@@ -52,10 +53,13 @@ MyTelegramBot.editMessageReplyMarkup({ inline_keyboard: [[{
}]] }, { message_id: 1244 });
MyTelegramBot.getUserProfilePhotos('myUserID', { limit: 10 });
MyTelegramBot.sendLocation(1234, 100, 200, { reply_to_message_id: 1234 });
MyTelegramBot.editMessageLiveLocation(100, 200, { message_id: 1245 });
MyTelegramBot.stopMessageLiveLocation({ message_id: 1245 });
MyTelegramBot.sendVenue(1234, 100, 200, 'Venue Title', '123 Fake St.', { reply_to_message_id: 1234 });
MyTelegramBot.sendContact(1234, '345-555-0192', 'John', { last_name: 'Smith' });
MyTelegramBot.getFile('My/File/ID');
MyTelegramBot.getFileLink('My/File/ID');
MyTelegramBot.getFileStream('My/File/ID');
MyTelegramBot.downloadFile('My/File/ID', 'mydownloaddir/');
MyTelegramBot.onText(/regex/, (msg, match) => { });
MyTelegramBot.removeTextListener(/regex/);
@@ -66,6 +70,8 @@ MyTelegramBot.getChatAdministrators(1234);
MyTelegramBot.getChatMembersCount(1234);
MyTelegramBot.getChatMember(1234, 'myUserID');
MyTelegramBot.leaveChat(1234);
MyTelegramBot.setChatStickerSet(1234, 'sticker');
MyTelegramBot.deleteChatStickerSet(1234);
MyTelegramBot.sendGame(1234, 'MygameName', { reply_to_message_id: 1234 });
MyTelegramBot.setGameScore('myUserID', 99, { message_id: 1234 });
MyTelegramBot.getGameHighScores('myUserID', { message_id: 1234 });