unua enmetajxo
Fenris Wolf

Fenris Wolf commited on 2016-05-13 11:03:38
Zeige 21 geänderte Dateien mit 1729 Einfügungen und 0 Löschungen.

... ...
@@ -0,0 +1,2 @@
1
+kreajxo
2
+
... ...
@@ -0,0 +1,19 @@
1
+{
2
+	"servilo": "irc.freenode.net",
3
+	"uzantnomo": "UZANTNOMO",
4
+	"kromnomo": "KROMNOMO",
5
+	"pasvorto": "PASVORTO",
6
+	"administrantoj": [],
7
+	"prokrasto": 500,
8
+	"kanaloj":
9
+	[
10
+	],
11
+	"kromajxoj":
12
+	[
13
+		{"vojo": "fontoj/kromajxoj/kromajxo_ehxado.js", "aktiva": true}
14
+	],
15
+	"auxtolancxo":
16
+	[
17
+	]
18
+}
19
+
... ...
@@ -0,0 +1,35 @@
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
+
22
+/**
23
+ * @author fenris
24
+ */
25
+var cxeno_numero : int = 0;
26
+
27
+
28
+/**
29
+ * @author fenris
30
+ */
31
+function cxeno_generi(prefikso : string = "") : string
32
+{
33
+	return (prefikso + (cxeno_numero++).toString());
34
+}
35
+
... ...
@@ -0,0 +1,24 @@
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 int = number;
22
+
23
+declare var require;
24
+
... ...
@@ -0,0 +1,97 @@
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
+
22
+/**
23
+ * @author fenris
24
+ */
25
+class klaso_vico<tipo_elemento>
26
+{
27
+	
28
+	/**
29
+	 * @author fenris
30
+	 */
31
+	protected elementoj : Array<tipo_elemento>;
32
+	
33
+	
34
+	/**
35
+	 * @author fenris
36
+	 */
37
+	public constructor(elementoj : Array<tipo_elemento> = [])
38
+	{
39
+		this.elementoj = new Array<tipo_elemento>();
40
+		this.elementoj = this.elementoj.concat(elementoj);
41
+	}
42
+	
43
+	
44
+	/**
45
+	 * @author fenris
46
+	 */
47
+	public doni(elemento : tipo_elemento) : void
48
+	{
49
+		this.elementoj.push(elemento);
50
+	}
51
+	
52
+	
53
+	/**
54
+	 * @author fenris
55
+	 */
56
+	public grando() : int
57
+	{
58
+		return this.elementoj.length;
59
+	}
60
+	
61
+	
62
+	/**
63
+	 * @author fenris
64
+	 */
65
+	public malplena() : boolean
66
+	{
67
+		return (this.grando() == 0);
68
+	}
69
+	
70
+	
71
+	/**
72
+	 * @author fenris
73
+	 */
74
+	public legi() : tipo_elemento
75
+	{
76
+		return (this.malplena() ? null : this.elementoj[0]);
77
+	}
78
+	
79
+	
80
+	/**
81
+	 * @author fenris
82
+	 */
83
+	public preni() : tipo_elemento
84
+	{
85
+		if (this.malplena())
86
+		{
87
+			return null;
88
+		}
89
+		else
90
+		{
91
+			let areo : Array<tipo_elemento> = this.elementoj.splice(0, 1);
92
+			return areo[0];
93
+		}
94
+	}
95
+	
96
+}
97
+
... ...
@@ -0,0 +1,50 @@
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
+
22
+/**
23
+ * @author fenris
24
+ */
25
+function vokado_nenio() : void
26
+{
27
+}
28
+
29
+
30
+/**
31
+ * @author fenris
32
+ */
33
+function vokado_atendi(dependajxoj : Array<(preta : ()=>void)=>void>, ago : ()=>void) : void
34
+{
35
+	if (dependajxoj.length > 0)
36
+	{
37
+		dependajxoj[0]
38
+		(
39
+			function () : void
40
+			{
41
+				vokado_atendi(dependajxoj.slice(1), ago);
42
+			}
43
+		);
44
+	}
45
+	else
46
+	{
47
+		ago();
48
+	}
49
+}
50
+
... ...
@@ -0,0 +1,139 @@
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
+declare var process;
22
+
23
+
24
+/**
25
+ * @author fenris
26
+ */
27
+function cxefajxo() : void
28
+{
29
+	function malkonfesado() : void {
30
+		console.info("Kvasir  Copyright (C) 2016  Fenris Wolf");
31
+		console.info("This program comes with ABSOLUTELY NO WARRANTY.");
32
+		console.info("This is free software, and you are welcome to redistribute it");
33
+		console.info("under certain conditions.");
34
+	}
35
+	
36
+	function sekurigi() : void
37
+	{
38
+		process.on
39
+		(
40
+			"uncaughtException",
41
+			function (event : Event) : void
42
+			{
43
+				console.warn("malloka escepto: ", event);
44
+			}
45
+		);
46
+	}
47
+	
48
+	function lancxi(agordoj : Object, fino : ()=>void = function () {}) : void
49
+	{
50
+		let kliento : klaso_kliento = new klaso_kliento_irc(agordoj, agordoj["prokrasto"]);
51
+		kliento.stirado_arangxi(agordoj["administrantoj"]);
52
+		vokado_atendi
53
+		(
54
+			agordoj["kromajxoj"].map
55
+			(
56
+				function (ero : Object) : (preta : ()=>void)=>void
57
+				{
58
+					return (
59
+						function (preta : ()=>void) : void
60
+						{
61
+							console.log("-- sxarganta na '" + ero["vojo"] + "' ...");
62
+							klaso_kromajxo_ekstera.krei
63
+							(
64
+								ero["vojo"],
65
+								function (eraro : Error, kromajxo : klaso_kromajxo_ekstera) : void
66
+								{
67
+									if (eraro != null)
68
+									{
69
+										console.warn(eraro);
70
+									}
71
+									else
72
+									{
73
+										kliento.kromajxo_aldoni(kromajxo, ero["aktiva"]);
74
+									}
75
+									console.log("-- ... preta");
76
+									preta();
77
+								}
78
+							);
79
+						}
80
+					);
81
+				}
82
+			),
83
+			function () : void
84
+			{
85
+				console.log("-- konektanta ...");
86
+				kliento.konekti
87
+				(
88
+					{},
89
+					function () : void
90
+					{
91
+						console.log("-- konektita");
92
+						agordoj["auxtolancxo"].forEach(x => kliento.enigi(new klaso_evento_eniga_mesagxo(null, null, x)));
93
+						fino();
94
+					}
95
+				);
96
+			}
97
+		);
98
+	}
99
+	
100
+	function agordoj_legi(vojo : string, uzado : (agordoj : Object)=>void) : void
101
+	{
102
+		_fs.readFile
103
+		(
104
+			vojo,
105
+			{"encoding": "utf8", "flag": "r"},
106
+			function (eraro : any, enhavo : string) : void
107
+			{
108
+				if (eraro != undefined)
109
+				{
110
+					throw (new Error("agordoj ne enlegeblas: " + eraro.toString()));
111
+				}
112
+				else
113
+				{
114
+					let agordoj : Object;
115
+					try
116
+					{
117
+						agordoj = JSON.parse(enhavo);
118
+					}
119
+					catch (escpto)
120
+					{
121
+						throw (new Error("agordoj ne enlegeblas: " + escpto.toString()));
122
+						agordoj = null;
123
+					}
124
+					if (agordoj != null)
125
+					{
126
+						uzado(agordoj);
127
+					}
128
+				}
129
+			}
130
+		);
131
+	}
132
+	
133
+	malkonfesado();
134
+	sekurigi();
135
+	agordoj_legi("./agordoj.json", agordoj => lancxi(agordoj));
136
+}
137
+
138
+cxefajxo();
139
+
... ...
@@ -0,0 +1,28 @@
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
+
22
+/**
23
+ * @author fenris
24
+ */
25
+abstract class klaso_evento
26
+{
27
+}
28
+
... ...
@@ -0,0 +1,43 @@
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
+
22
+/**
23
+ * @author fenris
24
+ */
25
+abstract class klaso_evento_eliga extends klaso_evento
26
+{
27
+	
28
+	/**
29
+	 * @author fenris
30
+	 */
31
+	public constructor()
32
+	{
33
+		super();
34
+	}
35
+	
36
+	
37
+	/**
38
+	 * @author fenris
39
+	 */
40
+	public static /*abstract*/ kruda_de(evento_kruda : Object) : klaso_evento_eliga {throw (new Error("not implemented"));}
41
+	
42
+}
43
+
... ...
@@ -0,0 +1,101 @@
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
+
22
+/**
23
+ * @author fenris
24
+ */
25
+class klaso_evento_eliga_mesagxo extends klaso_evento_eliga
26
+{
27
+	
28
+	/**
29
+	 * @author fenris
30
+	 */
31
+	protected celo : string;
32
+	
33
+	
34
+	/**
35
+	 * @author fenris
36
+	 */
37
+	protected enhavo : string;
38
+	
39
+	
40
+	/**
41
+	 * @author fenris
42
+	 */
43
+	protected alparolato : string;
44
+	
45
+	
46
+	/**
47
+	 * @author fenris
48
+	 */
49
+	public constructor(celo : string, alparolato : string, enhavo : string)
50
+	{
51
+		super();
52
+		this.celo = celo;
53
+		this.enhavo = enhavo;
54
+		this.alparolato = alparolato;
55
+	}
56
+	
57
+	
58
+	/**
59
+	 * @author fenris
60
+	 */
61
+	public static kruda_de(eligo_kruda : Object) : klaso_evento_eliga_mesagxo
62
+	{
63
+		return (
64
+			new klaso_evento_eliga_mesagxo
65
+			(
66
+				eligo_kruda["parametroj"]["celo"],
67
+				eligo_kruda["parametroj"]["alparolato"],
68
+				eligo_kruda["parametroj"]["enhavo"]
69
+			)
70
+		);
71
+	}
72
+	
73
+	
74
+	/**
75
+	 * @author fenris
76
+	 */
77
+	public celo_legi() : string
78
+	{
79
+		return this.celo;
80
+	}
81
+	
82
+	
83
+	/**
84
+	 * @author fenris
85
+	 */
86
+	public enhavo_legi() : string
87
+	{
88
+		return this.enhavo;
89
+	}
90
+	
91
+	
92
+	/**
93
+	 * @author fenris
94
+	 */
95
+	public alparolato_legi() : string
96
+	{
97
+		return this.alparolato;
98
+	}
99
+	
100
+}
101
+
... ...
@@ -0,0 +1,43 @@
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
+
22
+/**
23
+ * @author fenris
24
+ */
25
+abstract class klaso_evento_eniga extends klaso_evento
26
+{
27
+	
28
+	/**
29
+	 * @author fenris
30
+	 */
31
+	public constructor()
32
+	{
33
+		super();
34
+	}
35
+	
36
+	
37
+	/**
38
+	 * @author fenris
39
+	 */
40
+	public abstract kruda_al() : Object;
41
+	
42
+}
43
+
... ...
@@ -0,0 +1,67 @@
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
+
22
+/**
23
+ * @author fenris
24
+ */
25
+class klaso_evento_eniga_mesagxo extends klaso_evento_eniga
26
+{
27
+	
28
+	/**
29
+	 * @author fenris
30
+	 */
31
+	protected fonto : string;
32
+	
33
+	
34
+	/**
35
+	 * @author fenris
36
+	 */
37
+	protected sendinto : string;
38
+	
39
+	
40
+	/**
41
+	 * @author fenris
42
+	 */
43
+	protected enhavo : string;
44
+	
45
+	
46
+	/**
47
+	 * @author fenris
48
+	 */
49
+	public constructor(fonto : string, sendinto : string, enhavo : string)
50
+	{
51
+		super();
52
+		this.fonto = fonto;
53
+		this.sendinto = sendinto;
54
+		this.enhavo = enhavo;
55
+	}
56
+	
57
+	
58
+	/**
59
+	 * @author fenris
60
+	 */
61
+	public kruda_al() : Object
62
+	{
63
+		return {"tipo": "mesagxo", "parametroj": {"fonto": this.fonto, "sendinto": this.sendinto, "enhavo": this.enhavo}};
64
+	}
65
+	
66
+}
67
+
... ...
@@ -0,0 +1,293 @@
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_ero = {kromajxo : klaso_kromajxo; aktiva : boolean;};
22
+
23
+
24
+/**
25
+ * @author fenris
26
+ */
27
+abstract class klaso_kliento
28
+{
29
+	
30
+	/**
31
+	 * @author fenris
32
+	 */
33
+	protected kromajxoj : {[identigilo : string] : tipo_ero};
34
+	
35
+	
36
+	/**
37
+	 * @author fenris
38
+	 */
39
+	protected vico_eliga : klaso_vico<klaso_evento_eliga>;
40
+	
41
+	
42
+	/**
43
+	 * @author fenris
44
+	 */
45
+	protected prokrasto : int;
46
+	
47
+	
48
+	/**
49
+	 * @author fenris
50
+	 */
51
+	protected foo : any;
52
+	
53
+	
54
+	/**
55
+	 * @author fenris
56
+	 */
57
+	public constructor(prokrasto : int = null)
58
+	{
59
+		this.kromajxoj = {};
60
+		this.vico_eliga = new klaso_vico<klaso_evento_eliga>();
61
+		this.foo = null;
62
+		this.prokrasto = prokrasto;
63
+	}
64
+	
65
+	
66
+	/**
67
+	 * @author fenris
68
+	 */
69
+	public stirado_arangxi
70
+	(
71
+		permesuloj : Array<string> = []
72
+	)
73
+	{
74
+		let that : klaso_kliento = this;
75
+		this.kromajxo_aldoni
76
+		(
77
+			new klaso_kromajxo_stirado
78
+			(
79
+				permesuloj,
80
+				{
81
+					"anigxi": function (kanalo : string, modo : boolean = true) : void
82
+					{
83
+						that.anigxi_rekte(kanalo, modo);
84
+					},
85
+					"listigi": function (celo : string) : void
86
+					{
87
+						let enhavo : string = Object.keys(that.kromajxoj).map(identigilo => (that.kromajxoj[identigilo].aktiva ? "+" : "-") + identigilo).join(", ");
88
+						that.eligi(new klaso_evento_eliga_mesagxo(celo, null, enhavo));
89
+					},
90
+					"detaloj": function (identigilo : string, celo : string) : void
91
+					{
92
+						if (identigilo in that.kromajxoj)
93
+						{
94
+							let ero : tipo_ero = that.kromajxoj[identigilo];
95
+							let enhavoj : Array<string> =
96
+							[
97
+								"-- nomo: " + ero.kromajxo.nomo_legi(),
98
+								"-- auxtoro: " + ero.kromajxo.auxtoro_legi(),
99
+								"-- priskribo: " + ero.kromajxo.priskribo_legi(),
100
+								"-- aktiva: " + (ero.aktiva ? "jes" : "ne"),
101
+							];
102
+							enhavoj.forEach(enhavo => that.eligi(new klaso_evento_eliga_mesagxo(celo, null, enhavo)));
103
+						}
104
+					},
105
+					"sxalti": function (identigilo : string, aktiva : boolean = null, celo : string = null) : void
106
+					{
107
+						if (identigilo in that.kromajxoj)
108
+						{
109
+							if (identigilo != "stirado")
110
+							{
111
+								let aktiva_ : boolean = (aktiva != null) ? aktiva : (! that.kromajxoj[identigilo].aktiva);
112
+								that.kromajxoj[identigilo].aktiva = aktiva_;
113
+								if (celo != null) that.eligi(new klaso_evento_eliga_mesagxo(celo, null, "kromajxo '" + identigilo + "' " + (aktiva_ ? "aktivigita" : "malaktivigita") + ""));
114
+							}
115
+							else
116
+							{
117
+								if (celo != null) that.eligi(new klaso_evento_eliga_mesagxo(celo, null, "vi ne vere volas sxalti la stirad-kromajxon ..."));
118
+							}
119
+						}
120
+					},
121
+					"resxargi": function (identigilo : string, celo : string = null) : void
122
+					{
123
+						let ero : tipo_ero = that.kromajxoj[identigilo];
124
+						if (ero.kromajxo instanceof klaso_kromajxo_ekstera)
125
+						{
126
+							let kromajxo : klaso_kromajxo_ekstera = <klaso_kromajxo_ekstera>(ero.kromajxo);
127
+							kromajxo.resxargi
128
+							(
129
+								function (eraro : Error) : void
130
+								{
131
+									if (eraro != null)
132
+									{
133
+										console.warn(eraro);
134
+										if (celo != null) that.eligi(new klaso_evento_eliga_mesagxo(celo, null, "resxargado fiaskis; detaloj trovigxas je la konzolo"));
135
+									}
136
+									else
137
+									{
138
+										if (celo != null) that.eligi(new klaso_evento_eliga_mesagxo(celo, null, "kromajxo '" + identigilo + "' resxargita"));
139
+									}
140
+								}
141
+							);
142
+						}
143
+					},
144
+					"aldoni": function (nomo : string, celo : string= null) : void
145
+					{
146
+						if ((new RegExp("\\w")).test(nomo))
147
+						{
148
+							let vojo : string = "fontoj/kromajxoj/kromajxo_" + nomo + ".js";
149
+							klaso_kromajxo_ekstera.krei
150
+							(
151
+								vojo,
152
+								function (eraro : Error, kromajxo : klaso_kromajxo_ekstera) : void
153
+								{
154
+									if (eraro != null)
155
+									{
156
+										console.warn(eraro);
157
+										if (celo != null) that.eligi(new klaso_evento_eliga_mesagxo(celo, null, "aldoni kromajxon fiaskis"));
158
+									}
159
+									else
160
+									{
161
+										that.kromajxo_aldoni(kromajxo);
162
+										if (celo != null) that.eligi(new klaso_evento_eliga_mesagxo(celo, null, "kromajxo sukcese aldonita"));
163
+									}
164
+								}
165
+							);
166
+						}
167
+					},
168
+				}
169
+			)
170
+		);
171
+	}
172
+	
173
+	
174
+	/**
175
+	 * @author fenris
176
+	 */
177
+	public kromajxo_aldoni(kromajxo : klaso_kromajxo, aktiva : boolean = true, anstatauxigi : boolean = false) : void
178
+	{
179
+		let identigilo : string = kromajxo.identigilo_legi();
180
+		if (identigilo in this.kromajxoj)
181
+		{
182
+			if (anstatauxigi && (identigilo != "stirado"))
183
+			{
184
+				console.warn("kromajxo '" + identigilo + "' jam registrita; gxi anstatauxigatos");
185
+				this.kromajxoj[identigilo] = {"kromajxo": kromajxo, "aktiva": aktiva};
186
+			}
187
+			else
188
+			{
189
+				console.warn("kromajxo '" + identigilo + "' jam registrita; gxi NE anstatauxigatos");
190
+			}
191
+		}
192
+		else
193
+		{
194
+			this.kromajxoj[identigilo] = {"kromajxo": kromajxo, "aktiva": aktiva};
195
+		}
196
+	}
197
+	
198
+	
199
+	/**
200
+	 * @author fenris
201
+	 */
202
+	public abstract konekti(parametroj : Object, fino : ()=>void) : void;
203
+	
204
+	
205
+	/**
206
+	 * @author fenris
207
+	 */
208
+	public enigi(enigo : klaso_evento_eniga) : void
209
+	{
210
+		let that : klaso_kliento = this;
211
+		Object.keys(this.kromajxoj).forEach
212
+		(
213
+			function (identigilo : string) : void
214
+			{
215
+				let ero : tipo_ero = that.kromajxoj[identigilo];
216
+				{
217
+					if (ero.aktiva)
218
+					{
219
+						ero.kromajxo.enigi
220
+						(
221
+							enigo,
222
+							function (eligo : klaso_evento_eliga) : void
223
+							{
224
+								try
225
+								{
226
+									if (enigo["fonto"].indexOf("#") < 0)
227
+									{
228
+										eligo["celo"] = enigo["sendinto"];
229
+									}
230
+								}
231
+								catch (escepto)
232
+								{
233
+									console.warn(escepto);
234
+								}
235
+								that.eligi(eligo);
236
+							}
237
+						)
238
+					}
239
+				}
240
+			}
241
+		);
242
+	}
243
+	
244
+	
245
+	/**
246
+	 * @author fenris
247
+	 */
248
+	protected abstract eligi_rekte(eligo : klaso_evento_eliga) : void;
249
+	
250
+	
251
+	/**
252
+	 * @author fenris
253
+	 */
254
+	protected abstract anigxi_rekte(kanalo : string, modo : boolean) : void;
255
+	
256
+	
257
+	/**
258
+	 * @author fenris
259
+	 */
260
+	protected eligi(eligo : klaso_evento_eliga) : void
261
+	{
262
+		let that : klaso_kliento = this;
263
+		
264
+		function fari() : void
265
+		{
266
+			if (that.vico_eliga.malplena())
267
+			{
268
+				clearInterval(that.foo);
269
+				that.foo = null;
270
+			}
271
+			else
272
+			{
273
+				that.eligi_rekte(that.vico_eliga.preni());
274
+			}
275
+		}
276
+		
277
+		if (this.prokrasto == null)
278
+		{
279
+			that.eligi_rekte(eligo);
280
+		}
281
+		else
282
+		{
283
+			this.vico_eliga.doni(eligo);
284
+			if (this.foo == null)
285
+			{
286
+				fari();
287
+				this.foo = setInterval(fari, this.prokrasto);
288
+			}
289
+		}
290
+	}
291
+	
292
+}
293
+
... ...
@@ -0,0 +1,119 @@
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 _irc = require("./node_modules/irc");
22
+
23
+	
24
+/**
25
+ * @author fenris
26
+ */
27
+class klaso_kliento_irc extends klaso_kliento
28
+{
29
+	
30
+	/**
31
+	 * @author fenris
32
+	 */
33
+	protected irc : /*_irc.Client*/any;
34
+	
35
+	
36
+	/**
37
+	 * @author fenris
38
+	 */
39
+	public constructor(agordoj : Object, prokrasto : int)
40
+	{ 
41
+		super(prokrasto);
42
+		this.irc = new _irc.Client(agordoj["servilo"], agordoj["kromnomo"], {"channels": agordoj["kanaloj"], "userName": agordoj["uzantnomo"], "password": agordoj["pasvorto"], "autoConnect": false});
43
+	}
44
+	
45
+	
46
+	/**
47
+	 * @author fenris
48
+	 */
49
+	public konekti(parametroj : Object, fino : ()=>void) : void
50
+	{
51
+		let that : klaso_kliento_irc = this;
52
+		this.irc["addListener"]
53
+		(
54
+			"message",
55
+			function (sendinto : string, fonto : string, enhavo : string) : void
56
+			{
57
+				that.enigi(new klaso_evento_eniga_mesagxo(fonto, sendinto, enhavo));
58
+			}
59
+		);
60
+		this.irc.connect
61
+		(
62
+			3,
63
+			function () : void
64
+			{
65
+				fino();
66
+			}
67
+		);
68
+	}
69
+	
70
+	
71
+	/**
72
+	 * @author fenris
73
+	 */
74
+	protected eligi_rekte(eligo : klaso_evento_eliga) : void
75
+	{
76
+		     if (eligo instanceof klaso_evento_eliga_mesagxo)
77
+		{
78
+			let eligo_mesagxo : klaso_evento_eliga_mesagxo = <klaso_evento_eliga_mesagxo>(eligo);
79
+			try
80
+			{
81
+				let cxeno : string = "";
82
+				{
83
+					let alparolato : string = eligo_mesagxo.alparolato_legi();
84
+					if (alparolato != null) cxeno += alparolato + ": ";
85
+				}
86
+				{
87
+					let enhavo : string = eligo_mesagxo.enhavo_legi();
88
+					if (enhavo != null) cxeno += enhavo;
89
+				}
90
+				this.irc["say"](eligo_mesagxo.celo_legi(), cxeno);
91
+			}
92
+			catch (escepto)
93
+			{
94
+				console.warn(escepto);
95
+			}
96
+		}
97
+		else
98
+		{
99
+		}
100
+	}
101
+	
102
+	
103
+	/**
104
+	 * @author fenris
105
+	 */
106
+	protected anigxi_rekte(kanalo : string, modo : boolean = true) : void
107
+	{
108
+		if (modo)
109
+		{
110
+			this.irc["join"](kanalo);
111
+		}
112
+		else
113
+		{
114
+			this.irc["part"](kanalo, "vi kan maka en ander verld");
115
+		}
116
+	}
117
+	
118
+}
119
+
... ...
@@ -0,0 +1,81 @@
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
+	
22
+/**
23
+ * @author fenris
24
+ */
25
+class klaso_kliento_pseuxda extends klaso_kliento
26
+{
27
+	
28
+	/**
29
+	 * @author fenris
30
+	 */
31
+	public constructor(prokrasto : int)
32
+	{
33
+		super(prokrasto);
34
+	}
35
+	
36
+	
37
+	/**
38
+	 * @author fenris
39
+	 */
40
+	public konekti(parametroj : Object, fino : ()=>void) : void
41
+	{
42
+		fino();
43
+	}
44
+	
45
+	
46
+	/**
47
+	 * @author fenris
48
+	 */
49
+	protected eligi_rekte(eligo : klaso_evento_eliga) : void
50
+	{
51
+		     if (eligo instanceof klaso_evento_eliga_mesagxo)
52
+		{
53
+			let eligo_mesagxo : klaso_evento_eliga_mesagxo = <klaso_evento_eliga_mesagxo>(eligo);
54
+			let cxeno : string = "";
55
+			{
56
+				let alparolato : string = eligo_mesagxo.alparolato_legi();
57
+				if (alparolato != null) cxeno += alparolato + ": ";
58
+			}
59
+			{
60
+				let enhavo : string = eligo_mesagxo.enhavo_legi();
61
+				if (enhavo != null) cxeno += enhavo;
62
+			}
63
+			console.info(cxeno);
64
+		}
65
+		else
66
+		{
67
+			console.info(eligo);
68
+		}
69
+	}
70
+	
71
+	
72
+	/**
73
+	 * @author fenris
74
+	 */
75
+	protected anigxi_rekte(kanalo : string, modo : boolean) : void
76
+	{
77
+		console.warn("neebla");
78
+	}
79
+	
80
+}
81
+
... ...
@@ -0,0 +1,125 @@
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
+
22
+/**
23
+ * @author fenris
24
+ */
25
+abstract class klaso_kromajxo
26
+{
27
+	
28
+	/**
29
+	 * @author fenris
30
+	 */
31
+	protected identigilo : string;
32
+	
33
+	
34
+	/**
35
+	 * @author fenris
36
+	 */
37
+	protected nomo : string;
38
+	
39
+	
40
+	/**
41
+	 * @author fenris
42
+	 */
43
+	protected priskribo : string;
44
+	
45
+	
46
+	/**
47
+	 * @author fenris
48
+	 */
49
+	protected auxtoro : string;
50
+	
51
+	
52
+	/**
53
+	 * @author fenris
54
+	 */
55
+	public constructor(identigilo : string = null, nomo : string = null, priskribo : string = null, auxtoro : string = null)
56
+	{
57
+		if (identigilo == null)
58
+		{
59
+			identigilo = cxeno_generi("kromajxo_");
60
+			console.warn("nenia identigilo donita; la jena estis generita: " + identigilo);
61
+		}
62
+		this.identigilo = identigilo;
63
+		this.nomo = nomo;
64
+		this.priskribo = priskribo;
65
+		this.auxtoro = auxtoro;
66
+	}
67
+	
68
+	
69
+	/**
70
+	 * @author fenris
71
+	 */
72
+	public identigilo_legi() : string
73
+	{
74
+		return this.identigilo;
75
+	}
76
+	
77
+	
78
+	/**
79
+	 * @author fenris
80
+	 */
81
+	public nomo_legi() : string
82
+	{
83
+		return this.nomo;
84
+	}
85
+	
86
+	
87
+	/**
88
+	 * @author fenris
89
+	 */
90
+	public priskribo_legi() : string
91
+	{
92
+		return this.priskribo;
93
+	}
94
+	
95
+	
96
+	/**
97
+	 * @author fenris
98
+	 */
99
+	public auxtoro_legi() : string
100
+	{
101
+		return this.auxtoro;
102
+	}
103
+	
104
+	
105
+	/**
106
+	 * @author fenris
107
+	 */
108
+	public enigi(enigo : klaso_evento_eniga, eligi : (eligo : klaso_evento_eliga)=>void) : void
109
+	{
110
+		let that : klaso_kromajxo = this;
111
+		this.reagi
112
+		(
113
+			enigo.kruda_al(),
114
+			eligo_kruda => eligi(klaso_evento_eliga_mesagxo.kruda_de(eligo_kruda))
115
+		)
116
+	}
117
+		
118
+	
119
+	/**
120
+	 * @author fenris
121
+	 */
122
+	protected abstract reagi(enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void) : void;
123
+	
124
+}
125
+
... ...
@@ -0,0 +1,54 @@
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
+{
22
+	"identigilo": "ehxado",
23
+	"nomo": "Mesagx-Ehxado",
24
+	"auxtoro": "fenris",
25
+	"priskribo": "ripetas skribitajn mesagxojn",
26
+	"reagi": function (enigo_kruda, respondi)
27
+	{
28
+		switch (enigo_kruda["tipo"])
29
+		{
30
+			case "mesagxo":
31
+			{
32
+				respondi
33
+				(
34
+					{
35
+						"tipo": "mesagxo",
36
+						"parametroj":
37
+						{
38
+							"celo": enigo_kruda["parametroj"]["fonto"],
39
+							"alparolato": enigo_kruda["parametroj"]["sendinto"],
40
+							"enhavo": "vi estas skribinta la jenan mesagxon: „" + enigo_kruda["parametroj"]["enhavo"] + "“",
41
+						}
42
+					}
43
+				);
44
+				break;
45
+			}
46
+			default:
47
+			{
48
+				// console.warn("netraktata enigo '" + enigo_kruda["tipo"] + "'");
49
+				break;
50
+			}
51
+		}
52
+	}
53
+}
54
+
... ...
@@ -0,0 +1,168 @@
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,
56
+		auxtoro : string = null,
57
+		reagi_ : (enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void)=>void
58
+	)
59
+	{
60
+		super(identigilo, nomo, priskribo, auxtoro);
61
+		this.reagi_ = reagi_;
62
+		this.vojo = null;
63
+		this.memoro = {};
64
+	}
65
+	
66
+	
67
+	/**
68
+	 * @author fenris
69
+	 */
70
+	public resxargi(fino : (eraro : Error)=>void = function (eraro : Error) : void {}) : void
71
+	{
72
+		let that : klaso_kromajxo_ekstera = this;
73
+		klaso_kromajxo_ekstera.sxargi
74
+		(
75
+			this.vojo,
76
+			function (eraro : Error, datumoj : Object) : void
77
+			{
78
+				if (eraro != null)
79
+				{
80
+					fino(eraro);
81
+				}
82
+				else
83
+				{
84
+					that.nomo = datumoj["nomo"];
85
+					that.priskribo = datumoj["priskribo"];
86
+					that.auxtoro = datumoj["auxtoro"];
87
+					that.reagi_ = datumoj["reagi"];
88
+					fino(null);
89
+				}
90
+			}
91
+		);
92
+	}
93
+	
94
+	
95
+	/**
96
+	 * @author fenris
97
+	 */
98
+	protected reagi(enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void) : void
99
+	{
100
+		this.reagi_(enigo_kruda, eligi, this.memoro);
101
+	}
102
+	
103
+
104
+	/**
105
+	 * @author fenris
106
+	 */
107
+	protected static sxargi(vojo : string, uzado : (eraro : Error, datumoj : Object)=>void) : void
108
+	{
109
+		_fs.readFile
110
+		(
111
+			vojo,
112
+			{"encoding": "utf8", "flag": "r"},
113
+			function (eraro : Error, enhavo : string) : void
114
+			{
115
+				if (eraro != null)
116
+				{
117
+					uzado(eraro, null);
118
+				}
119
+				else
120
+				{
121
+					try
122
+					{
123
+						let datumoj : Object = eval("(function () {return (" + enhavo + ");})()");
124
+						uzado(null, datumoj);
125
+					}
126
+					catch (escepto)
127
+					{
128
+						uzado(new Error(String(escepto)), null);
129
+					}
130
+				}
131
+			}
132
+		);
133
+	}
134
+	
135
+	
136
+	/**
137
+	 * @author fenris
138
+	 */
139
+	public static krei(vojo : string, uzado : (eraro : Error, kromajxo : klaso_kromajxo_ekstera)=>void) : void
140
+	{
141
+		klaso_kromajxo_ekstera.sxargi
142
+		(
143
+			vojo,
144
+			function (eraro : Error, datumoj : Object) : void
145
+			{
146
+				if (eraro != null)
147
+				{
148
+					uzado(eraro, null);
149
+				}
150
+				else
151
+				{
152
+					let kromajxo : klaso_kromajxo_ekstera = new klaso_kromajxo_ekstera
153
+					(
154
+						datumoj["identigilo"],
155
+						datumoj["nomo"],
156
+						datumoj["priskribo"],
157
+						datumoj["auxtoro"],
158
+						datumoj["reagi"]
159
+					);
160
+					kromajxo.vojo = vojo;
161
+					uzado(null, kromajxo);
162
+				}
163
+			}
164
+		);
165
+	}
166
+	
167
+}
168
+
... ...
@@ -0,0 +1,165 @@
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;
29
+};
30
+
31
+
32
+/**
33
+ * @author fenris
34
+ */
35
+class klaso_kromajxo_stirado extends klaso_kromajxo
36
+{
37
+	
38
+	/**
39
+	 * @author fenris
40
+	 */
41
+	protected permesuloj : Array<string>;
42
+	
43
+	
44
+	/**
45
+	 * @author fenris
46
+	 */
47
+	protected agoj : tipo_agoj;
48
+	
49
+	
50
+	/**
51
+	 * @author fenris
52
+	 */
53
+	public constructor(
54
+		permesuloj : Array<string> = new Array<string>(),
55
+		agoj : tipo_agoj
56
+	)
57
+	{
58
+		super("stirado", "Stirado", "stiras aliajn kromajxojn kaj elmontras informojn pri ili", "fenris");
59
+		this.permesuloj = permesuloj;
60
+		this.agoj = agoj;
61
+	}
62
+	
63
+	
64
+	/**
65
+	 * @author fenris
66
+	 */
67
+	public reagi(enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void) : void
68
+	{
69
+		let that : klaso_kromajxo_stirado = this;
70
+		
71
+		function ujumi(foo : ()=>void) : void
72
+		{
73
+			if (that.permesuloj.indexOf(enigo_kruda["parametroj"]["sendinto"]) >= 0)
74
+			{
75
+				foo();
76
+			}
77
+			else
78
+			{
79
+				eligi
80
+				(
81
+					{
82
+						"tipo": "mesagxo",
83
+						"parametroj":
84
+						{
85
+							"celo": enigo_kruda["parametroj"]["fonto"],
86
+							"enhavo": "vi ne rajtas fari tion",
87
+						}
88
+					}
89
+				);
90
+			}
91
+		}
92
+		switch (enigo_kruda["tipo"])
93
+		{
94
+			case "mesagxo":
95
+			{
96
+				let resto : string = enigo_kruda["parametroj"]["enhavo"];
97
+				[
98
+					{
99
+						"skemoj": [new RegExp("^!\\W*(?:kanalo|k) (?:anigxi|a) ((?:#|\\w)+)$")],
100
+						"ago": x => ujumi(() => this.agoj.anigxi(x[0], true)),
101
+					},
102
+					{
103
+						"skemoj": [new RegExp("^!\\W*(?:kanalo|k) (?:malanigxi|m) ((?:#|\\w)+)$")],
104
+						"ago": x => ujumi(() => this.agoj.anigxi(x[0], false)),
105
+					},
106
+					{
107
+						"skemoj": [new RegExp("^!\\W*(?:kromajxo|x) (?:listigi|l)$")/*, new RegExp("$\|")*/],
108
+						"ago": x => this.agoj.listigi(enigo_kruda["parametroj"]["fonto"]),
109
+					},
110
+					{
111
+						"skemoj": [new RegExp("^!\\W*(?:kromajxo|x) (?:detaloj|d) (\\w+)$")/*, new RegExp("$#(\\w+)")*/],
112
+						"ago": x => ujumi(() => this.agoj.detaloj(x[0], enigo_kruda["parametroj"]["fonto"])),
113
+					},
114
+					{
115
+						"skemoj": [new RegExp("^!\\W*(?:kromajxo|x) (?:sxalti|s) (\\w+)$")/*, new RegExp("$~(\\w+)")*/],
116
+						"ago": x => ujumi(() => this.agoj.sxalti(x[0], undefined, enigo_kruda["parametroj"]["fonto"])),
117
+					},
118
+					{
119
+						"skemoj": [new RegExp("^!\\W*(?:kromajxo|x) (?:aktivigi|a) (\\w+)$")/*, new RegExp("$\+(\\w+)")*/],
120
+						"ago": x => ujumi(() => this.agoj.sxalti(x[0], true, enigo_kruda["parametroj"]["fonto"])),
121
+					},
122
+					{
123
+						"skemoj": [new RegExp("^!\\W*(?:kromajxo|x) (?:malaktivigi|m) (\\w+)$")/*, new RegExp("$-(\\w+)")*/],
124
+						"ago": x => ujumi(() => this.agoj.sxalti(x[0], false, enigo_kruda["parametroj"]["fonto"])),
125
+					},
126
+					{
127
+						"skemoj": [new RegExp("^!\\W*(?:kromajxo|x) (?:resxargi|r) (\\w+)$")/*, new RegExp("$#(\\w+)")*/],
128
+						"ago": x => ujumi(() => this.agoj.resxargi(x[0], enigo_kruda["parametroj"]["fonto"])),
129
+					},
130
+					{
131
+						"skemoj": [new RegExp("^!\\W*(?:kromajxo|x) (?:aldoni|p) (\\w+)$")/*, new RegExp("$\*(\\w+)")*/],
132
+						"ago": x => ujumi(() => that.agoj.aldoni(x[0], enigo_kruda["parametroj"]["fonto"])),
133
+					},
134
+				].forEach
135
+				(
136
+					function (ero : Object) : void
137
+					{
138
+						ero["skemoj"].some
139
+						(
140
+							function (skemo : RegExp) : boolean
141
+							{
142
+								let sercxo : any = resto.match(skemo);
143
+								if (sercxo != null)
144
+								{
145
+									ero["ago"](sercxo.slice(1));
146
+									return true;
147
+								}
148
+								else
149
+								{
150
+									return false;
151
+								}
152
+							}
153
+						);
154
+					}
155
+				);
156
+			}
157
+			default:
158
+			{
159
+				break;
160
+			}
161
+		}
162
+	}
163
+	
164
+}
165
+
... ...
@@ -0,0 +1,37 @@
1
+IRC-Bot "Kvasir"
2
+Copyright (C) 2016	Fenris Wolf (fenris@folksprak.org)
3
+
4
+This program is free software: you can redistribute it and/or modify
5
+it under the terms of the GNU General Public License as published by
6
+the Free Software Foundation, either version 3 of the License, or
7
+(at your option) any later version.
8
+
9
+This program is distributed in the hope that it will be useful,
10
+but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+GNU General Public License for more details.
13
+
14
+You should have received a copy of the GNU General Public License
15
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
+
17
+
18
+== Kio estas bezonata? ==
19
+
20
+Vi bezonas la jenajn programojn:
21
+ - npm
22
+ - TypeScript-kompililo (ekz. per "npm install -g tsc")
23
+ - nodejs-pakajxo "irc": "mkdir --parents kreajxo && cd kreajxo && npm install irc ; cd -"
24
+ - GNU-Make
25
+
26
+
27
+== Kiel kompili la fontojn? ==
28
+
29
+Efektivigu la jenan komandon:
30
+	"make kompili"
31
+	
32
+
33
+== Kiel lancxi la roboton? ==
34
+
35
+Post kompilado oni povas uzi la jenan komandon por lancxi la roboton:
36
+	"make lancxi"
37
+
... ...
@@ -0,0 +1,39 @@
1
+var_fontoj := 
2
+var_fontoj := ${var_fontoj} fontoj/bazo/tipoj.ts
3
+var_fontoj := ${var_fontoj} fontoj/bazo/vokado.ts
4
+var_fontoj := ${var_fontoj} fontoj/bazo/cxeno.ts
5
+var_fontoj := ${var_fontoj} fontoj/bazo/vico.ts
6
+var_fontoj := ${var_fontoj} fontoj/eventoj/evento.ts
7
+var_fontoj := ${var_fontoj} fontoj/eventoj/eventoj_enigaj/evento_eniga.ts
8
+var_fontoj := ${var_fontoj} fontoj/eventoj/eventoj_enigaj/evento_eniga_mesagxo.ts
9
+var_fontoj := ${var_fontoj} fontoj/eventoj/eventoj_eligaj/evento_eliga.ts
10
+var_fontoj := ${var_fontoj} fontoj/eventoj/eventoj_eligaj/evento_eliga_mesagxo.ts
11
+var_fontoj := ${var_fontoj} fontoj/kromajxoj/kromajxo.ts
12
+var_fontoj := ${var_fontoj} fontoj/kromajxoj/kromajxo_stirado.ts
13
+var_fontoj := ${var_fontoj} fontoj/kromajxoj/kromajxo_ekstera.ts
14
+var_fontoj := ${var_fontoj} fontoj/klientoj/kliento.ts
15
+var_fontoj := ${var_fontoj} fontoj/klientoj/kliento_pseuxda.ts
16
+var_fontoj := ${var_fontoj} fontoj/klientoj/kliento_irc.ts
17
+var_fontoj := ${var_fontoj} fontoj/cxefajxo.ts
18
+
19
+defauxlto: kompili
20
+.PHONY: defauxlto
21
+
22
+lancxi: kreajxo/kvasir.js
23
+	@ echo ">> lancxado ..."
24
+	@ nodejs kreajxo/kvasir.js
25
+.PHONY: lancxi
26
+
27
+kompili: kreajxo/kvasir.js
28
+.PHONY: kompili
29
+
30
+kreajxo/kvasir.js: ${var_fontoj}
31
+	@ echo ">> kompilado ..."
32
+	@ mkdir --parents kreajxo
33
+	@ tsc --target ES5 ${var_fontoj} --outFile kreajxo/kvasir.js
34
+
35
+nuligi:
36
+	@ echo ">> nuligado ..."
37
+	rm --recursive kreajxo
38
+.PHONY: nuligi
39
+
0 40