forked from ubiquity/ubiquibot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlers.ts
More file actions
32 lines (26 loc) · 1.16 KB
/
Copy pathhandlers.ts
File metadata and controls
32 lines (26 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { LogReturn } from "ubiquibot-logger";
import { Context } from "./context";
export type HandlerReturnValuesNoVoid = null | string | LogReturn;
export type MainActionHandler = (context: Context) => Promise<HandlerReturnValuesNoVoid>;
type CommandsHandler = (context: Context, body: string) => Promise<HandlerReturnValuesNoVoid>;
export type PreActionHandler = (context: Context) => Promise<void>;
export type PostActionHandler = (context: Context) => Promise<void>;
export type WildCardHandler = (context: Context) => Promise<void>;
/**
* @dev A set of handlers to do a pre/main/post action for a given action
* @param pre - An array of pre-action handlers, it consists of a small piece of handlers.
* If pre action isn't needed, you can just leave it empty
* @param action - An array of auction handlers, it consists of a small piece of handlers
* @param post - An array of post action handlers, it consists of a small piece of handlers
*/
export type Handler = {
pre: PreActionHandler[];
action: MainActionHandler[];
post: PostActionHandler[];
};
export type UserCommands = {
id: string;
description: string;
example: string;
handler: CommandsHandler;
};