/// import { EventEmitter } from "events"; import { Express } from "express"; import { Server } from "http"; import { Options as HttpOptions, ScopedClient } from "scoped-http-client"; export class Adapter extends EventEmitter { robot: Robot; constructor(robot: Robot); send(envelope: Envelope, ...strings: string[]): void; emote(envelope: Envelope, ...strings: string[]): void; reply(envelope: Envelope, ...strings: string[]): void; topic(envelope: Envelope, ...strings: string[]): void; play(envelope: Envelope, ...strings: string[]): void; run(): void; close(): void; receive(message: Message): void; http(url: string): ScopedClient; /** * @deprecated * @returns an object containing all the users with property names * that are the user id and with the value set as the `User`. * You can iterate over them all with `for (const id in users())` */ users(): any; userForId(id: string, options?: {}): User; userForName(name: string): User | null; usersForRawFuzzyName(fuzzyName: string): User[]; usersForFuzzyName(fuzzyName: string): User[]; } export class DataStore { constructor(robot: Robot); set(key: string, value: any): Promise; setObject(key: string, objectKey: string, value: any): Promise; setArray(key: string, value: any): Promise; get(key: string): Promise; getObject(key: string, objectKey: string): Promise; } export class DataStoreUnavailable extends Error {} export class Middleware { stack: Array>; constructor(robot: Robot); execute(context: MiddlewareContext, next: NextFunction, done: DoneFunction): void; register(middleware: MiddlewareHandler): void; } export class Brain extends EventEmitter { constructor(robot: Robot); set(key: string, value: any): this; get(key: string): any; remove(key: string): this; save(): void; close(): void; setAutoSave(enabled: boolean): void; resetSaveInterval(seconds: number): void; mergeData(data: {}): void; /** * @returns an object containing all the users with property names * that are the user id and with the value set as the `User`. * You can iterate over them all with `for (const id in users())` */ users(): any; userForId(id: string, options?: {}): User; userForName(name: string): User | null; usersForRawFuzzyName(fuzzyName: string): User[]; usersForFuzzyName(fuzzyName: string): User[]; } export class User { constructor(id: string, options?: {}); id: string; name: string; set(key: string, value: any): this; get(key: string): any; [property: string]: unknown; } export class Message { constructor(user: User, done?: boolean); id: string; user: User; text: string | null; room: string; finish(): void; } export class TextMessage extends Message { text: string; constructor(user: User, text: string, id: string); match(regex: RegExp): RegExpMatchArray; toString(): string; } export class EnterMessage extends Message { text: null; } export class LeaveMessage extends Message { text: null; } export class TopicMessage extends TextMessage { text: string; } export class CatchAllMessage extends Message { message: Message; constructor(message: Message); } export interface Envelope { room: string; user: User; message: Message; } export class Response< A extends Adapter = Adapter, M extends Message = Message, R extends RegExpMatchArray | { [key: string]: string } = RegExpMatchArray, > { robot: Robot; match: R; message: M; envelope: Envelope; constructor(robot: Robot, message: M, match: R); send(...strings: string[]): void; emote(...strings: string[]): void; reply(...strings: string[]): void; topic(...strings: string[]): void; play(...strings: string[]): void; locked(...strings: string[]): void; random(items: T[]): T; finish(): void; http(url: string, options?: HttpOptions): ScopedClient; } export type ListenerCallback = ( response: Response, ) => void; export type DoneFunction = () => void; export type NextFunction = (done: DoneFunction) => void; export interface MiddlewareContext { response?: Response | undefined; [key: string]: unknown; } export type MiddlewareHandler = ( context: MiddlewareContext, next: NextFunction, done: DoneFunction, ) => void; export interface LogLevel { (...messages: any[]): void; disable(): void; enable(): void; } export interface Log { (...messages: any[]): void; get(namespace: string): Log; debug: LogLevel; info: LogLevel; notice: LogLevel; warning: LogLevel; error: LogLevel; } export class Robot { readonly name: string; readonly events: EventEmitter; readonly brain: Brain; readonly alias: string; readonly adapterPath: string; readonly adapterName: string; readonly adapter: A; readonly errorHandlers: []; readonly onUncaughtException: (err: Error) => void; readonly datastore: null | DataStore; readonly commands: []; readonly middleware: { listener: Middleware; response: Middleware; receive: Middleware; }; readonly logger: Log; readonly pingIntervalId: null | NodeJS.Timeout; readonly globalHttpOptions: HttpOptions; readonly version: string; readonly server?: Server | undefined; readonly router: Express; constructor(adapterPath: string, adapter: string, httpd: boolean, name: string, alias?: string); catchAll(callback: ListenerCallback): void; catchAll(options: {}, callback: ListenerCallback): void; emit(event: string | symbol, ...args: unknown[]): void; enter(callback: ListenerCallback): void; enter(options: {}, callback: ListenerCallback): void; error(cb: (error: Error) => void): void; hear(regex: RegExp, callback: ListenerCallback): void; hear(regex: RegExp, options: {}, callback: ListenerCallback): void; helpCommands(): string[]; http(url: string, options?: HttpOptions): ScopedClient; leave(callback: ListenerCallback): void; leave(options: {}, callback: ListenerCallback): void; listen(matcher: (message: Message) => boolean, callback: ListenerCallback): void; listen(matcher: (message: Message) => boolean, options: {}, callback: ListenerCallback): void; listenerMiddleware(middleware: MiddlewareHandler): void; loadExternalScripts(packages: string[]): void; loadFile(directory: string, fileName: string): void; loadHubotScripts(path: string, scripts: string[]): void; messageRoom(room: string, ...strings: string[]): void; on(event: string | symbol, listener: (...args: unknown[]) => void): this; receive(message: Message, cb?: () => void): void; receiveMiddleware(middleware: MiddlewareHandler): void; reply(envelope: Envelope, ...strings: string[]): void; respond(regex: RegExp, callback: ListenerCallback): void; respond(regex: RegExp, options: {}, callback: ListenerCallback): void; respondPattern(regex: RegExp): RegExp; responseMiddleware(middleware: MiddlewareHandler): void; run(): void; send(envelope: Envelope, ...strings: string[]): void; shutdown(): void; topic(callback: ListenerCallback): void; topic(options: {}, callback: ListenerCallback): void; }