36b3cfb96fd72c925dac044e537b70dae69e4856
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) var _fs = require("fs");
22) 
23) 	
24) /**
25)  * @author fenris
26)  */
27) class klaso_kromajxo_ekstera extends klaso_kromajxo
28) {
29) 	
30) 	/**
31) 	 * @author fenris
32) 	 */
33) 	protected vojo : string;
34) 	
35) 	
36) 	/**
37) 	 * @author fenris
38) 	 */
39) 	protected memoro : Object;
40) 	
41) 	
42) 	/**
43) 	 * @author fenris
44) 	 */
45) 	protected reagi_ : (enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void, memoro ?: Object)=>void;
46) 	
47) 	
48) 	/**
49) 	 * @author fenris
50) 	 */
51) 	public constructor
52) 	(
53) 		identigilo : string = null,
54) 		nomo : string = null,
55) 		priskribo : string = null,
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

56) 		uzo : string = null,
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

57) 		auxtoro : string = null,
58) 		reagi_ : (enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void)=>void
59) 	)
60) 	{
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

61) 		super(identigilo, nomo, priskribo, uzo, auxtoro);
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

62) 		this.reagi_ = reagi_;
63) 		this.vojo = null;
64) 		this.memoro = {};
65) 	}
66) 	
67) 	
68) 	/**
69) 	 * @author fenris
70) 	 */
71) 	public resxargi(fino : (eraro : Error)=>void = function (eraro : Error) : void {}) : void
72) 	{
73) 		let that : klaso_kromajxo_ekstera = this;
74) 		klaso_kromajxo_ekstera.sxargi
75) 		(
76) 			this.vojo,
77) 			function (eraro : Error, datumoj : Object) : void
78) 			{
79) 				if (eraro != null)
80) 				{
81) 					fino(eraro);
82) 				}
83) 				else
84) 				{
85) 					that.nomo = datumoj["nomo"];
86) 					that.priskribo = datumoj["priskribo"];
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

87) 					that.uzo = datumoj["uzo"];
Fenris Wolf unua enmetajxo

Fenris Wolf authored 7 years ago

88) 					that.auxtoro = datumoj["auxtoro"];
89) 					that.reagi_ = datumoj["reagi"];
90) 					fino(null);
91) 				}
92) 			}
93) 		);
94) 	}
95) 	
96) 	
97) 	/**
98) 	 * @author fenris
99) 	 */
100) 	protected reagi(enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void) : void
101) 	{
102) 		this.reagi_(enigo_kruda, eligi, this.memoro);
103) 	}
104) 	
105) 
106) 	/**
107) 	 * @author fenris
108) 	 */
109) 	protected static sxargi(vojo : string, uzado : (eraro : Error, datumoj : Object)=>void) : void
110) 	{
111) 		_fs.readFile
112) 		(
113) 			vojo,
114) 			{"encoding": "utf8", "flag": "r"},
115) 			function (eraro : Error, enhavo : string) : void
116) 			{
117) 				if (eraro != null)
118) 				{
119) 					uzado(eraro, null);
120) 				}
121) 				else
122) 				{
123) 					try
124) 					{
125) 						let datumoj : Object = eval("(function () {return (" + enhavo + ");})()");
126) 						uzado(null, datumoj);
127) 					}
128) 					catch (escepto)
129) 					{
130) 						uzado(new Error(String(escepto)), null);
131) 					}
132) 				}
133) 			}
134) 		);
135) 	}
136) 	
137) 	
138) 	/**
139) 	 * @author fenris
140) 	 */
141) 	public static krei(vojo : string, uzado : (eraro : Error, kromajxo : klaso_kromajxo_ekstera)=>void) : void
142) 	{
143) 		klaso_kromajxo_ekstera.sxargi
144) 		(
145) 			vojo,
146) 			function (eraro : Error, datumoj : Object) : void
147) 			{
148) 				if (eraro != null)
149) 				{
150) 					uzado(eraro, null);
151) 				}
152) 				else
153) 				{
154) 					let kromajxo : klaso_kromajxo_ekstera = new klaso_kromajxo_ekstera
155) 					(
156) 						datumoj["identigilo"],
157) 						datumoj["nomo"],
158) 						datumoj["priskribo"],
Fenris Wolf malgranda gxisdatigajxo

Fenris Wolf authored 7 years ago

159) 						datumoj["uzo"],