de807ff96936a13cb5357986367fab7055b88802
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

1) /*
2) 	
3) 	IRC-Bot "Kvasir"
4)     Copyright (C) 2016	Fenris Wolf (fenris@folksprak.org)
5) 	
6)     This program is free software: you can redistribute it and/or modify
7)     it under the terms of the GNU General Public License as published by
8)     the Free Software Foundation, either version 3 of the License, or
9)     (at your option) any later version.
10) 	
11)     This program is distributed in the hope that it will be useful,
12)     but WITHOUT ANY WARRANTY; without even the implied warranty of
13)     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)     GNU General Public License for more details.
15) 	
16)     You should have received a copy of the GNU General Public License
17)     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18)        
19) */
20) 
21) type tipo_agoj = {
22) 	anigxi ?: (kanalo : string, modo ?: boolean)=>void;
23) 	malanigxi ?: (kanalo : string)=>void;
24) 	listigi ?: (celo : string)=>void;
25) 	detaloj ?: (identigilo : string, celo : string)=>void;
26) 	sxalti ?: (identigilo : string, aktiva ?: boolean, celo ?: string)=>void;
27) 	resxargi ?: (identigilo : string, celo ?: string)=>void;
28) 	aldoni ?: (nomo : string, celo ?: string)=>void;
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

29) 	elmontri_helpon ?: (celo ?: string)=>void;
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

30) };
31) 
32) 
33) /**
34)  * @author fenris
35)  */
36) class klaso_kromajxo_stirado extends klaso_kromajxo
37) {
38) 	
39) 	/**
40) 	 * @author fenris
41) 	 */
42) 	protected permesuloj : Array<string>;
43) 	
44) 	
45) 	/**
46) 	 * @author fenris
47) 	 */
48) 	protected agoj : tipo_agoj;
49) 	
50) 	
51) 	/**
52) 	 * @author fenris
53) 	 */
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

54) 	public constructor
55) 	(
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

56) 		permesuloj : Array<string> = new Array<string>(),
57) 		agoj : tipo_agoj
58) 	)
59) 	{
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

60) 		super("stirado", "Stirado", "stiras aliajn kromajxojn kaj elmontras informojn pri ili", null, "fenris");
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

61) 		this.permesuloj = permesuloj;
62) 		this.agoj = agoj;
63) 	}
64) 	
65) 	
66) 	/**
67) 	 * @author fenris
68) 	 */
69) 	public reagi(enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void) : void
70) 	{
71) 		let that : klaso_kromajxo_stirado = this;
72) 		
73) 		function ujumi(foo : ()=>void) : void
74) 		{
75) 			if (that.permesuloj.indexOf(enigo_kruda["parametroj"]["sendinto"]) >= 0)
76) 			{
77) 				foo();
78) 			}
79) 			else
80) 			{
81) 				eligi
82) 				(
83) 					{
84) 						"tipo": "mesagxo",
85) 						"parametroj":
86) 						{
87) 							"celo": enigo_kruda["parametroj"]["fonto"],
88) 							"enhavo": "vi ne rajtas fari tion",
89) 						}
90) 					}
91) 				);
92) 			}
93) 		}
94) 		switch (enigo_kruda["tipo"])
95) 		{
96) 			case "mesagxo":
97) 			{
98) 				let resto : string = enigo_kruda["parametroj"]["enhavo"];
99) 				[
100) 					{
Fenris Wolf fandajxo

Fenris Wolf authored 7 years ago

101) 						"skemoj": [new RegExp("^!\\s*(?:kanalo|k)\\s*(?:anigxi|a|>)\\s*(#\\S+)$")],
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

102) 						"ago": x => ujumi(() => this.agoj.anigxi(x[0], true)),
103) 					},
104) 					{
Fenris Wolf fandajxo

Fenris Wolf authored 7 years ago

105) 						"skemoj": [new RegExp("^!\\s*(?:kanalo|k)\\s*(?:malanigxi|m|<)\\s*(#\\S+)$")],
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

106) 						"ago": x => ujumi(() => this.agoj.anigxi(x[0], false)),
107) 					},
108) 					{
Fenris Wolf fandajxo

Fenris Wolf authored 7 years ago

109) 						"skemoj": [new RegExp("^!\\s*(?:kromaĵo|kromajxo|krom|x)\\s*(?:listigi|l)$")/*, new RegExp("$\|")*/],
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

110) 						"ago": x => this.agoj.listigi(enigo_kruda["parametroj"]["fonto"]),
111) 					},
112) 					{
Fenris Wolf 'starigi'-metodo por kromaj...

Fenris Wolf authored 7 years ago

113) 						"skemoj": [new RegExp("^!\\s*(?:kromaĵo|kromajxo|krom|x)\\s*(?:detaloj|d|\\?)\\s*(\\w+)$")/*, new RegExp("$#(\\w+)")*/],
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

114) 						"ago": x => this.agoj.detaloj(x[0], enigo_kruda["parametroj"]["fonto"]),
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

115) 					},
116) 					{
Fenris Wolf fandajxo

Fenris Wolf authored 7 years ago

117) 						"skemoj": [new RegExp("^!\\s*(?:kromaĵo|kromajxo|krom|x)\\s*(?:sxalti|s|toggle|t|%)\\s*(\\w+)$")/*, new RegExp("$~(\\w+)")*/],
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

118) 						"ago": x => ujumi(() => this.agoj.sxalti(x[0], undefined, enigo_kruda["parametroj"]["fonto"])),
119) 					},
120) 					{
Fenris Wolf fandajxo

Fenris Wolf authored 7 years ago

121) 						"skemoj": [new RegExp("^!\\s*(?:kromaĵo|kromajxo|krom|x)\\s*(?:aktivigi|a|\\+)\\s*(\\w+)$")/*, new RegExp("$\+(\\w+)")*/],
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

122) 						"ago": x => ujumi(() => this.agoj.sxalti(x[0], true, enigo_kruda["parametroj"]["fonto"])),
123) 					},
124) 					{
Fenris Wolf fandajxo

Fenris Wolf authored 7 years ago

125) 						"skemoj": [new RegExp("^!\\s*(?:kromaĵo|kromajxo|krom|x)\\s*(?:malaktivigi|m|-)\\s*(\\w+)$")/*, new RegExp("$-(\\w+)")*/],
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

126) 						"ago": x => ujumi(() => this.agoj.sxalti(x[0], false, enigo_kruda["parametroj"]["fonto"])),
127) 					},
128) 					{
Fenris Wolf fandajxo

Fenris Wolf authored 7 years ago

129) 						"skemoj": [new RegExp("^!\\s*(?:kromaĵo|kromajxo|krom|x)\\s*(?:resxargi|r|\\$)\\s*(\\w+)$")/*, new RegExp("$#(\\w+)")*/],
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

130) 						"ago": x => ujumi(() => this.agoj.resxargi(x[0], enigo_kruda["parametroj"]["fonto"])),
131) 					},
132) 					{
Fenris Wolf fandajxo

Fenris Wolf authored 7 years ago

133) 						"skemoj": [new RegExp("^!\\s*(?:kromaĵo|kromajxo|krom|x)\\s*(?:aldoni|\\*)\\s*(\\w+)$")/*, new RegExp("$\*(\\w+)")*/],
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

134) 						"ago": x => ujumi(() => that.agoj.aldoni(x[0], enigo_kruda["parametroj"]["fonto"])),
135) 					},
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

136) 					{
Fenris Wolf fandajxo

Fenris Wolf authored 7 years ago

137) 						"skemoj": [new RegExp("^!\\s*(?:helpo|help|h)$")],
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

138) 						"ago": x => this.agoj.elmontri_helpon(enigo_kruda["parametroj"]["fonto"]),
139) 					},