koishi-plugin-adapter-telegram-ex
Version:
Telegram Adapter for Koishi
61 lines (60 loc) • 2.41 kB
TypeScript
/// <reference types="koishi/lib" />
/// <reference types="node" />
import { Adapter, Bot, Dict, Quester, Schema } from 'koishi';
import * as Telegram from './types';
import { AdapterConfig } from './utils';
export declare class SenderError extends Error {
constructor(args: Dict<any>, url: string, retcode: number, selfId: string);
}
export interface TelegramResponse {
ok: boolean;
result: any;
}
export interface BotConfig extends Bot.BaseConfig {
token?: string;
request?: Quester.Config;
pollingTimeout?: number;
}
export declare const BotConfig: Schema<BotConfig>;
export declare class TelegramBot extends Bot<BotConfig> {
static adaptUser(data: Partial<Telegram.User & Bot.User>): Bot.User;
static schema: Schema<AdapterConfig, AdapterConfig>;
http: Quester & {
file?: Quester;
};
constructor(adapter: Adapter, config: BotConfig);
/**
* Request telegram API
* @param action method of telegram API. Starts with a '/'
* @param params params in camelCase
* @returns Respond form telegram
*/
get<T = any, P = any>(action: string, params?: P): Promise<T>;
/**
* Request telegram API
* @param action method of telegram API. Starts with a '/'
* @param params params in camelCase
* @param field file field key in fromData
* @param content file stream
* @returns Respond form telegram
*/
post<T = any, P = any>(action: string, params?: P, field?: string, content?: Buffer, filename?: string): Promise<T>;
sendMessage(channelId: string, content: string): Promise<string[]>;
sendPrivateMessage(userId: string, content: string): Promise<string[]>;
getMessage(): Promise<any>;
deleteMessage(chatId: string, messageId: string): Promise<void>;
static adaptGroup(data: Telegram.Chat): Bot.Guild;
getGuild(chatId: string): Promise<Bot.Guild>;
getGuildList(): Promise<any[]>;
getGuildMember(chatId: string, userId: string): Promise<Bot.GuildMember>;
getGuildMemberList(chatId: string): Promise<Bot.GuildMember[]>;
setGroupLeave(chatId: string): Promise<any>;
handleGuildMemberRequest(messageId: string, approve: boolean, comment?: string): Promise<void>;
getLoginInfo(): Promise<Bot.User>;
$getFileData(fileId: string): Promise<{
url: string;
}>;
$getFileContent(filePath: string): Promise<{
url: string;
}>;
}