]> jfr.im git - irc/Ozafy/borknet_p10_irc_services.git/blob - core/modules/v/V.java
First commit
[irc/Ozafy/borknet_p10_irc_services.git] / core / modules / v / V.java
1 /**
2 #
3 # BorkNet Services Core
4 #
5
6 #
7 # Copyright (C) 2004 Ozafy - ozafy@borknet.org - http://www.borknet.org
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABotILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Botoston, MA 02111-1307, USA.
22 #
23 */
24
25 /*
26 The actual module core.
27 It loads the config.
28 Creates all needed classes.
29
30 It can be used to create both servers & clients.
31 */
32
33 import java.io.*;
34 import java.util.*;
35 import java.sql.*;
36 import borknet_services.core.*;
37
38 public class V implements Modules
39 {
40 private Core C;
41 private Server ser;
42 private String description = "";
43 private String nick = "";
44 private String ident = "";
45 private String host = "";
46 private String numeric = "";
47 private String num = "AAA";
48 private String reportchan = "";
49 private String vhost = "";
50 private boolean automatic = true;
51 private boolean qwebirc = false;
52 private String qhost = "webchat@borknet.org";
53 private String qident = "webchat";
54 private ArrayList<Object> cmds = new ArrayList<Object>();
55 private ArrayList<String> cmdn = new ArrayList<String>();
56
57 public V()
58 {
59 }
60
61 public void start(Core C)
62 {
63 this.C = C;
64 load_conf();
65 numeric = C.get_numeric();
66 ser = new Server(C,this);
67 C.cmd_create_service(num, nick, ident, host, "+oXwkgsr", description);
68 reportchan = C.get_reportchan();
69 C.cmd_join(numeric, num, reportchan);
70 }
71
72 public void setCmnds(ArrayList<Object> cmds,ArrayList<String> cmdn)
73 {
74 this.cmds = cmds;
75 this.cmdn = cmdn;
76 }
77
78 public ArrayList<Object> getCmds()
79 {
80 return cmds;
81 }
82
83 public ArrayList<String> getCmdn()
84 {
85 return cmdn;
86 }
87
88 public void stop()
89 {
90 C.cmd_kill_service(numeric+num, "Quit: Soon will I rest, yes, forever sleep. Earned it I have. Twilight is upon me, soon night must fall.");
91 }
92
93 public void hstop()
94 {
95 C.cmd_kill_service(numeric+num, "Quit: Happens to every guy sometimes this does.");
96 }
97
98 private void load_conf()
99 {
100 try
101 {
102 ConfLoader loader = new ConfLoader(C,"core/modules/"+this.getClass().getName().toLowerCase()+"/"+this.getClass().getName().toLowerCase()+".conf");
103 loader.load();
104 Properties dataSrc = loader.getVars();
105 //set all the config file vars
106 description = dataSrc.getProperty("description");
107 nick = dataSrc.getProperty("nick");
108 ident = dataSrc.getProperty("ident");
109 host = dataSrc.getProperty("host");
110 /* remove the next line if you build a client only */
111 num = dataSrc.getProperty("numeric");
112 automatic = Boolean.parseBoolean(dataSrc.getProperty("automatic"));
113 qwebirc = Boolean.parseBoolean(dataSrc.getProperty("qwebirc"));
114 qhost = dataSrc.getProperty("qhost");
115 qident = dataSrc.getProperty("qident");
116 }
117 catch(Exception e)
118 {
119 C.printDebug("Error loading configfile.");
120 C.debug(e);
121 C.die("SQL error, trying to die gracefully.");
122 }
123 }
124
125 public void parse(ArrayList<String> params)
126 {
127 try
128 {
129 ser.parse(params);
130 }
131 catch(Exception e)
132 {
133 C.debug(e);
134 }
135 }
136
137 public String get_num()
138 {
139 return numeric;
140 }
141 public String get_corenum()
142 {
143 return num;
144 }
145 public String get_nick()
146 {
147 return nick;
148 }
149 public String get_host()
150 {
151 return host;
152 }
153 public boolean get_automatic()
154 {
155 return automatic;
156 }
157 public String get_vhost()
158 {
159 return vhost;
160 }
161 public boolean get_qwebirc()
162 {
163 return qwebirc;
164 }
165 public String get_qhost()
166 {
167 return qhost;
168 }
169 public String get_qident()
170 {
171 return qident;
172 }
173
174 public void clean()
175 {
176 //no need
177 }
178 }