-
Notifications
You must be signed in to change notification settings - Fork 2
/
rivescript.d.ts
84 lines (50 loc) · 2.25 KB
/
rivescript.d.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
declare module "rivescript" {
interface RivescriptOptions {
utf8?: boolean;
debug?: boolean;
onDebug?: (message: string) => void;
concat?: "none" | "newline" | "space";
errors?: { [key: string]: string};
}
interface MacroObjectHandler {
load(name: string, code: string[]): void;
call(rs: RiveScript, name: string, fields: any, scope: any): string;
}
interface Trigger {
trigger: string,
reply: string[],
condition: string[],
redirect: string,
previous: string
}
class RiveScript {
constructor(options?: RivescriptOptions);
version(): string;
Promise(callback: (resolve: (any) => void, reject: (any) => void) => void): void;
loadDirectory(brain: string, loadingDone?: (batchNumber: number) => void, loadingError?: (error: Error, batchNumber: number) => void): Promise<any>;
loadFile(path: string, loadingDone?: (batchNumber: number) => void, loadingError?: (error: Error, batchNumber: number) => void): Promise<any>;
loadFile(paths: string[], loadingDone?: (batchNumber: number) => void, loadingError?: (error: Error, batchNumber: number) => void): Promise<any>;
stream(code: string, onError: (error: string) => void): boolean;
sortReplies();
reply(user: string, message: string, scope?: any): Promise<string>;
replyAsync(user: string, message: string, scope?: any): Promise<string>;
replyAsync(user: string, message: string, scope: any, callback: (error: Error, reply: string) => void);
setHandler(lang: string, handler: MacroObjectHandler): void;
setSubroutine(name: string, handler: (rs: RiveScript, args: string[]) => string | Promise<string>): void;
setGlobal(name: string, value: string): void;
setVariable(name: string, value: string): void;
setSubstitution(name: string, value: string): void;
setPerson(name: string, value: string): void;
setUservar(user: string, name: string, value: any): void;
setUservars(user: string, data: Object): void;
getVariable(user: string, name: string): string;
getUservar(user: string, name: string): string;
getUservars(user: string): Object;
clearUservars(user: string): void;
lastMatch(user: string): string;
initialMatch(user: string): string;
lastTriggers(user: string): Trigger[];
currentUser(): string;
}
export = RiveScript;
}