]> jfr.im git - irc/borknet/trunk.git/blob - core/modules/s/S.java
Q: Removed the '!' at the end of the line directly giving the userpassword
[irc/borknet/trunk.git] / core / modules / s / S.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 import java.io.*;
25 import java.util.*;
26 import java.sql.*;
27 import borknet_services.core.*;
28
29 public class S implements Modules
30 {
31 private Core C;
32 private Server ser;
33 private DBControl dbc;
34 private DelPoints DP;
35 private String description = "";
36 private String nick = "";
37 private String ident = "";
38 private String host = "";
39 private String pass = "";
40 private String numeric = "";
41 private String num = "";
42 private String reportchan = "";
43 private String rules = "";
44 private ArrayList<Object> cmds = new ArrayList<Object>();
45 private ArrayList<String> cmdn = new ArrayList<String>();
46
47 private int spamtext=16;
48 private int spamchan=64;
49 private int spamweb=64;
50 private int spamrepeat=24;
51 private int spamwarning=80;
52 private int spamkill=100;
53
54 public S()
55 {
56 }
57
58 public void start(Core C)
59 {
60 this.C = C;
61 load_conf();
62 numeric = C.get_numeric();
63 dbc = new DBControl(C,this);
64 ser = new Server(C,dbc,this);
65 DP = new DelPoints(dbc);
66 Thread th1 = new Thread(DP);
67 th1.setDaemon(true);
68 th1.start();
69 C.cmd_create_service(num, nick, ident, host, "+oXwkgr", description);
70 reportchan = C.get_reportchan();
71 C.cmd_join(numeric, num, reportchan);
72 List<String> channels = dbc.getChanTable();
73 //join my channels and set my modes
74 for(String channel : channels)
75 {
76 C.cmd_join(numeric,num,channel);
77 }
78 }
79
80 public void setCmnds(ArrayList<Object> cmds,ArrayList<String> cmdn)
81 {
82 this.cmds = cmds;
83 this.cmdn = cmdn;
84 }
85
86 public ArrayList<Object> getCmds()
87 {
88 return cmds;
89 }
90
91 public ArrayList<String> getCmdn()
92 {
93 return cmdn;
94 }
95
96 public void stop()
97 {
98 DP.stop();
99 C.cmd_kill_service(numeric+num, "Quit: Spam away you trolls.");
100 }
101
102 public void hstop()
103 {
104 DP.stop();
105 C.cmd_kill_service(numeric+num, "Quit: My bananas! Noes!");
106 }
107
108 private void load_conf()
109 {
110 try
111 {
112 ConfLoader loader = new ConfLoader(C,"core/modules/"+this.getClass().getName().toLowerCase()+"/"+this.getClass().getName().toLowerCase()+".conf");
113 loader.load();
114 Properties dataSrc = loader.getVars();
115 //set all the config file vars
116 description = dataSrc.getProperty("description");
117 nick = dataSrc.getProperty("nick");
118 ident = dataSrc.getProperty("ident");
119 host = dataSrc.getProperty("host");
120 pass = dataSrc.getProperty("pass");
121 num = dataSrc.getProperty("numeric");
122 rules = dataSrc.getProperty("rules");
123 spamtext=Integer.parseInt(dataSrc.getProperty("spamtext"));
124 spamchan=Integer.parseInt(dataSrc.getProperty("spamchan"));
125 spamweb=Integer.parseInt(dataSrc.getProperty("spamweb"));
126 spamrepeat=Integer.parseInt(dataSrc.getProperty("spamrepeat"));
127 spamwarning=Integer.parseInt(dataSrc.getProperty("spamwarning"));
128 spamkill=Integer.parseInt(dataSrc.getProperty("spamkill"));
129 }
130 catch(Exception e)
131 {
132 C.printDebug("Error loading configfile.");
133 C.debug(e);
134 C.die("SQL error, trying to die gracefully.");
135 }
136 }
137
138 public void parse(String msg)
139 {
140 try
141 {
142 ser.parse(msg);
143 }
144 catch(Exception e)
145 {
146 C.debug(e);
147 }
148 }
149
150 public String get_num()
151 {
152 return numeric;
153 }
154 public String get_corenum()
155 {
156 return num;
157 }
158 public String get_nick()
159 {
160 return nick;
161 }
162 public String get_host()
163 {
164 return host;
165 }
166 public String getRules()
167 {
168 return rules;
169 }
170
171 public int getSpamtext()
172 {
173 return spamtext;
174 }
175 public int getSpamchan()
176 {
177 return spamchan;
178 }
179 public int getSpamweb()
180 {
181 return spamweb;
182 }
183 public int getSpamrepeat()
184 {
185 return spamrepeat;
186 }
187 public int getSpamwarning()
188 {
189 return spamwarning;
190 }
191 public int getSpamkill()
192 {
193 return spamkill;
194 }
195
196 public DBControl getDBC()
197 {
198 return dbc;
199 }
200 public void clean()
201 {
202 dbc.clean();
203 }
204
205 public void reop(String chan)
206 {
207 if(dbc.SchanExists(chan))
208 {
209 C.cmd_mode(numeric, numeric+num , chan , "+o");
210 }
211 }
212 }