diff --git a/types/node-cleanup/index.d.ts b/types/node-cleanup/index.d.ts new file mode 100644 index 0000000000..103f0bc813 --- /dev/null +++ b/types/node-cleanup/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for node-cleanup 2.1 +// Project: https://github.com/jtlapp/node-cleanup +// Definitions by: Agadar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Note that ES6 modules cannot directly export callable functions. +// This file should be imported using the CommonJS-style: +// import nodeCleanup = require('node-cleanup'); + +export = install; + +declare function install(cleanupHandler?: ((exitCode: number | null, signal: string | null) => boolean | undefined), + stderrMessages?: { ctrl_C: string; uncaughtException: string }): void; + +declare namespace install { + function uninstall(): void; +} diff --git a/types/node-cleanup/node-cleanup-tests.ts b/types/node-cleanup/node-cleanup-tests.ts new file mode 100644 index 0000000000..ec42821dff --- /dev/null +++ b/types/node-cleanup/node-cleanup-tests.ts @@ -0,0 +1,13 @@ +import nodeCleanup = require('node-cleanup'); + +function cleanupHandler(exitCode: number | null, signal: string | null): boolean | undefined { + return true; +} +const stderrMessages = { ctrl_C: 'ctrl_c', uncaughtException: 'UncaughtException' }; + +nodeCleanup(); +nodeCleanup(cleanupHandler); +nodeCleanup(cleanupHandler, undefined); +nodeCleanup(cleanupHandler, stderrMessages); +nodeCleanup(undefined, stderrMessages); +nodeCleanup.uninstall(); diff --git a/types/node-cleanup/tsconfig.json b/types/node-cleanup/tsconfig.json new file mode 100644 index 0000000000..c05b3b90bf --- /dev/null +++ b/types/node-cleanup/tsconfig.json @@ -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-cleanup-tests.ts" + ] +} diff --git a/types/node-cleanup/tslint.json b/types/node-cleanup/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/node-cleanup/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/node-telegram-bot-api/index.d.ts b/types/node-telegram-bot-api/index.d.ts index 1a7d15ec34..60b46b137c 100644 --- a/types/node-telegram-bot-api/index.d.ts +++ b/types/node-telegram-bot-api/index.d.ts @@ -1,10 +1,15 @@ -// Type definitions for node-telegram-bot-api 0.27 +// Type definitions for node-telegram-bot-api 0.28 // Project: https://github.com/yagop/node-telegram-bot-api // Definitions by: Alex Muench +// Agadar // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 +/// -declare class TelegramBot { +import { EventEmitter } from 'events'; +import { Stream } from "stream"; + +declare class TelegramBot extends EventEmitter { constructor(token: string, opts?: any); startPolling(options?: any): Promise; @@ -23,27 +28,38 @@ declare class TelegramBot { sendMessage(chatId: number | string, text: string, options?: any): Promise; answerInlineQuery(inlineQueryId: string, results: any[], options?: any): Promise; forwardMessage(chatId: number | string, fromChatId: number | string, messageId: number | string, options?: any): Promise; - sendPhoto(chatId: number | string, photo: any, options?: any): Promise; - sendAudio(chatId: number | string, audio: any, options?: any): Promise; - sendDocument(chatId: number | string, doc: any, options?: any, fileOpts?: any): Promise; - sendSticker(chatId: number | string, sticker: any, options?: any): Promise; - sendVideo(chatId: number | string, video: any, options?: any): Promise; - sendVoice(chatId: number | string, voice: any, options?: any): Promise; + sendPhoto(chatId: number | string, photo: string | Stream | Buffer, options?: any): Promise; + sendAudio(chatId: number | string, audio: string | Stream | Buffer, options?: any): Promise; + sendDocument(chatId: number | string, doc: string | Stream | Buffer, options?: any, fileOpts?: any): Promise; + sendSticker(chatId: number | string, sticker: string | Stream | Buffer, options?: any): Promise; + sendVideo(chatId: number | string, video: string | Stream | Buffer, options?: any): Promise; + sendVideoNote(chatId: number | string, videoNote: string | Stream | Buffer, options?: any): Promise; + sendVoice(chatId: number | string, voice: string | Stream | Buffer, options?: any): Promise; sendChatAction(chatId: number | string, action: string): Promise; kickChatMember(chatId: number | string, userId: string): Promise; unbanChatMember(chatId: number | string, userId: string): Promise; - answerCallbackQuery(callbackQueryId: number | string, text: string, showAlert: boolean, options?: any): Promise; + restrictChatMember(chatId: number | string, userId: string, options?: any): Promise; + promoteChatMember(chatId: number | string, userId: string, options?: any): Promise; + exportChatInviteLink(chatId: number | string): Promise; + sendChatPhoto(chatId: number | string, photo: string | Stream | Buffer): Promise; + deleteChatPhoto(chatId: number | string): Promise; + setChatTitle(chatId: number | string, title: string): Promise; + setChatDescription(chatId: number | string, description: string): Promise; + pinChatMessage(chatId: number | string, messageId: string): Promise; + unpinChatMessage(chatId: number | string): Promise; + answerCallbackQuery(options?: any): Promise; editMessageText(text: string, options?: any): Promise; editMessageCaption(caption: string, options?: any): Promise; editMessageReplyMarkup(replyMarkup: any, options?: any): Promise; - getUserProfilePhotos(userId: string, options?: any): Promise; + getUserProfilePhotos(userId: number | string, options?: any): Promise; sendLocation(chatId: number | string, latitude: number, longitude: number, options?: any): Promise; sendVenue(chatId: number | string, latitude: number, longitude: number, title: string, address: string, options?: any): Promise; sendContact(chatId: number | string, phoneNumber: string, firstName: string, options?: any): Promise; getFile(fileId: string): Promise; getFileLink(fileId: string): Promise; downloadFile(fileId: string, downloadDir: string): Promise; - onText(regexp: any, callback: ((msg: any, match: any[]) => void)): void; + onText(regexp: RegExp, callback: ((msg: any, match: any[]) => void)): void; + removeTextListener(regexp: RegExp): any; onReplyToMessage(chatId: number | string, messageId: number | string, callback: ((msg: any) => void)): number; removeReplyListener(replyListenerId: number): any; getChat(chatId: number | string): Promise; @@ -54,6 +70,11 @@ declare class TelegramBot { sendGame(chatId: number | string, gameShortName: string, options?: any): Promise; setGameScore(userId: string, score: number, options?: any): Promise; getGameHighScores(userId: string, options?: any): Promise; + deleteMessage(chatId: number | string, messageId: string, options?: any): Promise; + sendInvoice(chatId: number | string, title: string, description: string, payload: string, providerToken: string, startParameter: string, + currency: string, prices: any[], options?: any): Promise; + answerShippingQuery(shippingQueryId: string, ok: boolean, options?: any): Promise; + answerPreCheckoutQuery(preCheckoutQueryId: string, ok: boolean, options?: any): Promise; } export = TelegramBot; diff --git a/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts b/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts index 80b44216fb..70482a7b38 100644 --- a/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts +++ b/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts @@ -23,11 +23,21 @@ 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.sendVideoNote(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.restrictChatMember(1234, 'myUserID', { foo: "bar" }); +MyTelegramBot.promoteChatMember(1234, 'myUserID', { foo: "bar" }); +MyTelegramBot.exportChatInviteLink(1234); +MyTelegramBot.sendChatPhoto(1234, "My/File/ID"); +MyTelegramBot.deleteChatPhoto(1234); +MyTelegramBot.setChatTitle(1234, 'Chat Title'); +MyTelegramBot.setChatDescription(1234, 'Chat Description'); +MyTelegramBot.pinChatMessage(1234, 'Pinned Message'); +MyTelegramBot.unpinChatMessage(1234); +MyTelegramBot.answerCallbackQuery({ foo: "bar" }); MyTelegramBot.editMessageText("test-text", { foo: "bar" }); MyTelegramBot.editMessageCaption("My Witty Caption", { foo: "bar" }); MyTelegramBot.editMessageReplyMarkup({ replyMarkup: "something" }, { foo: "bar" }); @@ -39,6 +49,7 @@ MyTelegramBot.getFile("My/File/ID"); MyTelegramBot.getFileLink("My/File/ID"); MyTelegramBot.downloadFile("My/File/ID", "mydownloaddir/"); MyTelegramBot.onText(/regex/, (msg, match) => { }); +MyTelegramBot.removeTextListener(/regex/); MyTelegramBot.onReplyToMessage(1234, "mymessageID", (msg) => { }); MyTelegramBot.removeReplyListener(5466); MyTelegramBot.getChat(1234); @@ -49,3 +60,7 @@ MyTelegramBot.leaveChat(1234); MyTelegramBot.sendGame(1234, "MygameName", { foo: "bar" }); MyTelegramBot.setGameScore("myUserID", 99, { foo: "bar" }); MyTelegramBot.getGameHighScores("myUserID", { foo: "bar" }); +MyTelegramBot.deleteMessage(1234, 'mymessageID', { foo: "bar" }); +MyTelegramBot.sendInvoice(1234, 'Invoice Title', 'Invoice Description', 'Invoice Payload', 'Providertoken', 'Startparameter', 'Currency', [1, 2, 4], { foo: "bar" }); +MyTelegramBot.answerShippingQuery('shippingQueryId', true, { foo: "bar" }); +MyTelegramBot.answerPreCheckoutQuery('preCheckoutQueryId', true, { foo: "bar" });