3 # BorkNet Services Core
7 # Copyright (C) 2004 Ozafy - ozafy@borknet.org - http://www.borknet.org
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.
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.
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.
27 import java
.util
.regex
.*;
28 import borknet_services
.core
.*;
31 * Class to load configuration files.
32 * @author Ozafy - ozafy@borknet.org - http://www.borknet.org
34 public class Chanflags
implements Command
38 * @param debug If we're running in debug.
44 public void parse_command(Core C
, S Bot
, String numeric
, String botnum
, String username
, String params
)
46 DBControl dbc
= Bot
.getDBC();
47 if(dbc
.getUser(username
).getOperator())
49 String
[] result
= params
.split("\\s");
52 //get some info from what the user asks
53 String channel
= result
[1];
54 String flags
= result
[2];
55 if(flags
.length() > 1)
57 C
.cmd_notice(numeric
, botnum
, username
, "You can only set one flag.");
60 //need to check they don't remove the a flag
61 Pattern pat
= Pattern
.compile("[^din]");
62 Matcher m
= pat
.matcher(flags
);
63 StringBuffer sb
= new StringBuffer();
64 boolean nok
= m
.find();
67 m
.appendReplacement(sb
, "");
71 flags
= sb
.toString();
73 if(flags
.length() < 1)
75 C
.cmd_notice(numeric
, botnum
, username
, "Invalid flag.");
78 if(dbc
.setChanFlags(channel
,flags
))
82 C
.cmd_privmsg(numeric
, botnum
, channel
, "Instagib is now enabled so please refrain from talking.");
84 else if(flags
.equals("n"))
86 C
.cmd_privmsg(numeric
, botnum
, channel
, "Scanning normally.");
88 else if(flags
.equals("d"))
90 C
.cmd_privmsg(numeric
, botnum
, channel
, "Deaf mode is now enabled, spam away!");
92 C
.cmd_notice(numeric
, botnum
, username
, "Done.");
96 C
.cmd_notice(numeric
, botnum
, username
, "Can't find that channel!");
100 //he asked to see the flags, or asked nothing
101 catch(ArrayIndexOutOfBoundsException e
)
106 String channel
= result
[1];
107 //check which channel
108 String flags
= dbc
.getChanFlags(channel
);
109 if(flags
.equals("0"))
111 C
.cmd_notice(numeric
, botnum
, username
, "Can't find that channel!");
114 //it does, return the flags set
117 C
.cmd_notice(numeric
, botnum
, username
, "Current channel flags are: +" + flags
);
122 catch(ArrayIndexOutOfBoundsException f
)
124 C
.cmd_notice(numeric
, botnum
, username
, "/msg " + Bot
.get_nick() + " chanflags <#channel> [flag]");
125 C
.cmd_notice(numeric
, botnum
, username
, "Possible flags are:");
126 C
.cmd_notice(numeric
, botnum
, username
, "d: Deaf.");
127 C
.cmd_notice(numeric
, botnum
, username
, "i: Instagib.");
128 C
.cmd_notice(numeric
, botnum
, username
, "n: Normal.");
135 C
.cmd_notice(numeric
, botnum
, username
, "This command is either unknown, or you need to be opered up to use it.");
140 public void parse_help(Core C
, S Bot
, String numeric
, String botnum
, String username
, boolean operator
)
144 C
.cmd_notice(numeric
, botnum
, username
, "/msg " + Bot
.get_nick() + " chanflags <#channel> [flag]");
145 C
.cmd_notice(numeric
, botnum
, username
, "Possible flags are:");
146 C
.cmd_notice(numeric
, botnum
, username
, "d: Deaf.");
147 C
.cmd_notice(numeric
, botnum
, username
, "i: Instagib.");
148 C
.cmd_notice(numeric
, botnum
, username
, "n: Normal.");
152 C
.cmd_notice(numeric
, botnum
, username
, "This command is either unknown, or you need to be opered up to use it.");
156 public void showcommand(Core C
, S Bot
, String numeric
, String botnum
, String username
, boolean operator
)
160 C
.cmd_notice(numeric
, botnum
, username
, "CHANFLAGS Will change/display a channel's flags.");