]>
Commit | Line | Data |
---|---|---|
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 | # MERCHANTABILITY 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, Boston, MA 02111-1307, USA. | |
22 | # | |
23 | */ | |
24 | ||
25 | ||
26 | /* | |
27 | ||
28 | A very basic command, replies to /msg moo with /notice Moo! | |
29 | ||
30 | */ | |
31 | ||
32 | ||
33 | import java.io.*; | |
34 | import java.util.*; | |
35 | import borknet_services.core.*; | |
36 | ||
37 | /** | |
38 | * Class to load configuration files. | |
39 | * @author Ozafy - ozafy@borknet.org - http://www.borknet.org | |
40 | */ | |
41 | public class Sethost implements Command | |
42 | { | |
43 | /** | |
44 | * Constructs a Loader | |
45 | * @param debug If we're running in debug. | |
46 | */ | |
47 | public Sethost() | |
48 | { | |
49 | } | |
50 | ||
51 | public void parse_command(Core C, V Bot, String numeric, String botnum, String username, String params) | |
52 | { | |
53 | User user = C.get_dbc().getUser(username); | |
54 | if(user.getOperator()) | |
55 | { | |
56 | String[] result = params.split("\\s"); | |
57 | try | |
58 | { | |
59 | String forcenick = user.getNick(); | |
60 | String ident = result[1]; | |
61 | String host = result[2]; | |
62 | if(result.length>3) | |
63 | { | |
64 | forcenick = result[1]; | |
65 | ident = result[2]; | |
66 | host = result[3]; | |
67 | } | |
68 | User forceuser = C.get_dbc().getUserViaNick(forcenick); | |
69 | if(forceuser instanceof User) | |
70 | { | |
71 | if(ident.matches("[\\w]*") && host.matches("[\\w.]*")) | |
72 | { | |
73 | C.cmd_sethost(forceuser.getNumeric(), ident, host); | |
74 | C.cmd_notice(numeric, botnum, username, "Done."); | |
75 | } | |
76 | else | |
77 | { | |
78 | C.cmd_notice(numeric, botnum, username, "Please only use word characters."); | |
79 | } | |
80 | } | |
81 | else | |
82 | { | |
83 | C.cmd_notice(numeric, botnum, username, "Who on earth is that?"); | |
84 | } | |
85 | } | |
86 | //he didn't, Yoda time! | |
87 | catch(Exception e) | |
88 | { | |
89 | C.cmd_notice(numeric, botnum, username, "/msg "+Bot.get_nick()+" sethost [nickname] <ident> <host>"); | |
90 | return; | |
91 | } | |
92 | } | |
93 | //user doesn't have access, that bastard! | |
94 | else | |
95 | { | |
96 | C.cmd_notice(numeric, botnum, username, "This command is either unknown, or you need to be opered up to use it."); | |
97 | return; | |
98 | } | |
99 | } | |
100 | ||
101 | public void parse_help(Core C, V Bot, String numeric, String botnum, String username, boolean operator) | |
102 | { | |
103 | if(operator) | |
104 | { | |
105 | C.cmd_notice(numeric, botnum, username, "/msg "+Bot.get_nick()+" sethost [nickname] <ident> <host>"); | |
106 | } | |
107 | else | |
108 | { | |
109 | C.cmd_notice(numeric, botnum, username, "This command is either unknown, or you need to be opered up to use it."); | |
110 | } | |
111 | } | |
112 | public void showcommand(Core C, V Bot, String numeric, String botnum, String username, boolean operator) | |
113 | { | |
114 | if(operator) | |
115 | { | |
116 | C.cmd_notice(numeric, botnum, username, "SETHOST Makes the bot set an ident and host on a user or yourself if nu user is supplied."); | |
117 | } | |
118 | } | |
119 | } |