mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-29 17:07:07 +08:00
Add typings for tgfancy
This commit is contained in:
76
types/tgfancy/index.d.ts
vendored
Normal file
76
types/tgfancy/index.d.ts
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
// Type definitions for tgfancy 0.13
|
||||
// Project: https://github.com/GochoMugo/tgfancy
|
||||
// Definitions by: Giorgio Garasto <https://github.com/Dabolus>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import * as TelegramBot from 'node-telegram-bot-api';
|
||||
|
||||
declare namespace Tgfancy {
|
||||
interface ChatIdResolutionOptions {
|
||||
resolve(token: string, chatId: number | string, callback: ((error: Error | null, target: any) => void)): void;
|
||||
}
|
||||
|
||||
interface EmojificationOptions {
|
||||
emojify(text: string): string;
|
||||
}
|
||||
|
||||
interface RatelimitingOptions {
|
||||
maxRetries?: number;
|
||||
timeout?: number;
|
||||
notify?(methodName: string, ...args: any[]): void;
|
||||
maxBackoff?: number;
|
||||
}
|
||||
|
||||
interface WebSocketOptions {
|
||||
url: string;
|
||||
autoOpen?: boolean;
|
||||
}
|
||||
|
||||
interface TgfancyOptions {
|
||||
chatIdResolution?: boolean | ChatIdResolutionOptions;
|
||||
emojification?: boolean | EmojificationOptions;
|
||||
kickWithoutBan?: boolean;
|
||||
openshiftWebHook?: boolean;
|
||||
orderedSending?: boolean;
|
||||
ratelimiting?: boolean | RatelimitingOptions;
|
||||
textPaging?: boolean;
|
||||
webSocket?: boolean | WebSocketOptions;
|
||||
}
|
||||
|
||||
interface ConstructorOptions extends TelegramBot.ConstructorOptions {
|
||||
tgfancy?: TgfancyOptions;
|
||||
}
|
||||
|
||||
interface ResolvedChat {
|
||||
id: number | string;
|
||||
username: string;
|
||||
type: string;
|
||||
when: string;
|
||||
}
|
||||
|
||||
interface ResolvedGroupOrChannel extends ResolvedChat {
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface ResolvedUser extends ResolvedChat {
|
||||
first_name: string;
|
||||
last_name?: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare class Tgfancy extends TelegramBot {
|
||||
constructor(token: string, options?: Tgfancy.ConstructorOptions);
|
||||
|
||||
resolveChatId(chatId: string): Promise<Tgfancy.ResolvedChat | Error>;
|
||||
|
||||
openWebSocket(): Promise<undefined | Error>;
|
||||
|
||||
closeWebSocket(): Promise<undefined | Error>;
|
||||
|
||||
hasOpenWebSocket(): boolean;
|
||||
|
||||
kickChatMember(chatId: number | string, userId: number | string, ban?: boolean): Promise<boolean | Error>;
|
||||
}
|
||||
|
||||
export = Tgfancy;
|
||||
24
types/tgfancy/tgfancy-tests.ts
Normal file
24
types/tgfancy/tgfancy-tests.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import tgfancy = require('tgfancy');
|
||||
|
||||
const MyTgFancyBot = new tgfancy('token', {
|
||||
tgfancy: {
|
||||
chatIdResolution: true,
|
||||
emojification: true,
|
||||
kickWithoutBan: true,
|
||||
ratelimiting: {
|
||||
maxRetries: 132,
|
||||
timeout: 40000
|
||||
},
|
||||
webSocket: {
|
||||
url: 'ws://example.ws',
|
||||
autoOpen: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
MyTgFancyBot.resolveChatId('chat id');
|
||||
MyTgFancyBot.openWebSocket();
|
||||
MyTgFancyBot.closeWebSocket();
|
||||
MyTgFancyBot.hasOpenWebSocket();
|
||||
MyTgFancyBot.kickChatMember('chat id', 'user id');
|
||||
MyTgFancyBot.kickChatMember(13128219, 3181422, true);
|
||||
23
types/tgfancy/tsconfig.json
Normal file
23
types/tgfancy/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"tgfancy-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/tgfancy/tslint.json
Normal file
3
types/tgfancy/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user