Add Typings for node-telegram-bot-api (#16734)

* Add types file for node-telegram-bot-api@0.27

* Switch object to any

* Use all double-quotes

* Fix for lint breaking with OBJECT.Entries error

* Fix tslint.json structure

* Revert changes to tslint

* Add version info to fix dts error

* Fix lint issues
This commit is contained in:
Alex Muench
2017-05-31 22:33:50 -07:00
committed by Mohamed Hegazy
parent 3537f59e0b
commit f38b79a46d
4 changed files with 135 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
// Type definitions for node-telegram-bot-api 0.27
// Project: https://github.com/yagop/node-telegram-bot-api
// Definitions by: Alex Muench <https://github.com/ammuench>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
declare class TelegramBot {
constructor(token: string, opts?: any);
startPolling(options?: any): Promise<any>;
initPolling(options?: any): Promise<any>;
stopPolling(): Promise<any>;
isPolling(): boolean;
openWebHook(): Promise<any>;
closeWebHook(): Promise<any>;
hasOpenWebHook(): boolean;
getMe(): Promise<any>;
setWebHook(url: string, options?: any): Promise<any>;
deleteWebHook(): Promise<any>;
getWebHookInfo(): Promise<any>;
getUpdates(options?: any): Promise<any>;
processUpdate(update: any): void;
sendMessage(chatId: number | string, text: string, options?: any): Promise<any>;
answerInlineQuery(inlineQueryId: string, results: any[], options?: any): Promise<any>;
forwardMessage(chatId: number | string, fromChatId: number | string, messageId: number | string, options?: any): Promise<any>;
sendPhoto(chatId: number | string, photo: any, options?: any): Promise<any>;
sendAudio(chatId: number | string, audio: any, options?: any): Promise<any>;
sendDocument(chatId: number | string, doc: any, options?: any, fileOpts?: any): Promise<any>;
sendSticker(chatId: number | string, sticker: any, options?: any): Promise<any>;
sendVideo(chatId: number | string, video: any, options?: any): Promise<any>;
sendVoice(chatId: number | string, voice: any, options?: any): Promise<any>;
sendChatAction(chatId: number | string, action: string): Promise<any>;
kickChatMember(chatId: number | string, userId: string): Promise<any>;
unbanChatMember(chatId: number | string, userId: string): Promise<any>;
answerCallbackQuery(callbackQueryId: number | string, text: string, showAlert: boolean, options?: any): Promise<any>;
editMessageText(text: string, options?: any): Promise<any>;
editMessageCaption(caption: string, options?: any): Promise<any>;
editMessageReplyMarkup(replyMarkup: any, options?: any): Promise<any>;
getUserProfilePhotos(userId: string, options?: any): Promise<any>;
sendLocation(chatId: number | string, latitude: number, longitude: number, options?: any): Promise<any>;
sendVenue(chatId: number | string, latitude: number, longitude: number, title: string, address: string, options?: any): Promise<any>;
sendContact(chatId: number | string, phoneNumber: string, firstName: string, options?: any): Promise<any>;
getFile(fileId: string): Promise<any>;
getFileLink(fileId: string): Promise<any>;
downloadFile(fileId: string, downloadDir: string): Promise<any>;
onText(regexp: any, callback: ((msg: any, match: any[]) => void)): void;
onReplyToMessage(chatId: number | string, messageId: number | string, callback: ((msg: any) => void)): number;
removeReplyListener(replyListenerId: number): any;
getChat(chatId: number | string): Promise<any>;
getChatAdministrators(chatId: number | string): Promise<any>;
getChatMembersCount(chatId: number | string): Promise<any>;
getChatMember(chatId: number | string, userId: string): Promise<any>;
leaveChat(chatId: number | string): Promise<any>;
sendGame(chatId: number | string, gameShortName: string, options?: any): Promise<any>;
setGameScore(userId: string, score: number, options?: any): Promise<any>;
getGameHighScores(userId: string, options?: any): Promise<any>;
}
export = TelegramBot;
@@ -0,0 +1,51 @@
import TelegramBot = require("node-telegram-bot-api");
const MyTelegramBot = new TelegramBot("token");
MyTelegramBot.startPolling({ foo: "bar" });
MyTelegramBot.initPolling({ foo: "bar" });
MyTelegramBot.stopPolling();
MyTelegramBot.isPolling();
MyTelegramBot.openWebHook();
MyTelegramBot.closeWebHook();
MyTelegramBot.hasOpenWebHook();
MyTelegramBot.getMe();
MyTelegramBot.setWebHook("http://typescriptlang.org", { foo: "bar" });
MyTelegramBot.deleteWebHook();
MyTelegramBot.getWebHookInfo();
MyTelegramBot.getUpdates({ foo: "bar" });
MyTelegramBot.processUpdate("Update Method/Stream/Etc");
MyTelegramBot.sendMessage(1234, "test-text", { foo: "bar" });
MyTelegramBot.answerInlineQuery("queryId", ["test", "test", "test"], { foo: "bar" });
MyTelegramBot.forwardMessage(1234, 5678, "memberID", { foo: "bar" });
MyTelegramBot.sendPhoto(1234, "photo/path", { foo: "bar" });
MyTelegramBot.sendAudio(1234, "audio/path", { foo: "bar" });
MyTelegramBot.sendDocument(1234, "doc/path", { foo: "bar" }, { fileOption: true });
MyTelegramBot.sendSticker(1234, "sticker/path", { foo: "bar" });
MyTelegramBot.sendVideo(1234, "video/path", { foo: "bar" });
MyTelegramBot.sendVoice(1234, "voice/path", { foo: "bar" });
MyTelegramBot.sendChatAction(1234, "ACTION!");
MyTelegramBot.kickChatMember(1234, "myUserID");
MyTelegramBot.unbanChatMember(1234, "myUserID");
MyTelegramBot.answerCallbackQuery("myCallbackQueryID", "test-text", false, { foo: "bar" });
MyTelegramBot.editMessageText("test-text", { foo: "bar" });
MyTelegramBot.editMessageCaption("My Witty Caption", { foo: "bar" });
MyTelegramBot.editMessageReplyMarkup({ replyMarkup: "something" }, { foo: "bar" });
MyTelegramBot.getUserProfilePhotos("myUserID", { foo: "bar" });
MyTelegramBot.sendLocation(1234, 100, 200, { foo: "bar" });
MyTelegramBot.sendVenue(1234, 100, 200, "Venue Title", "123 Fake St.", { foo: "bar" });
MyTelegramBot.sendContact(1234, "345-555-0192", "John", { foo: "bar" });
MyTelegramBot.getFile("My/File/ID");
MyTelegramBot.getFileLink("My/File/ID");
MyTelegramBot.downloadFile("My/File/ID", "mydownloaddir/");
MyTelegramBot.onText(/regex/, (msg, match) => { });
MyTelegramBot.onReplyToMessage(1234, "mymessageID", (msg) => { });
MyTelegramBot.removeReplyListener(5466);
MyTelegramBot.getChat(1234);
MyTelegramBot.getChatAdministrators(1234);
MyTelegramBot.getChatMembersCount(1234);
MyTelegramBot.getChatMember(1234, "myUserID");
MyTelegramBot.leaveChat(1234);
MyTelegramBot.sendGame(1234, "MygameName", { foo: "bar" });
MyTelegramBot.setGameScore("myUserID", 99, { foo: "bar" });
MyTelegramBot.getGameHighScores("myUserID", { foo: "bar" });
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"node-telegram-bot-api-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}