]> git.somenet.org - irc/pjirc-ng.git/blob - src/main/java/irc/dcc/DCCChatInterpretor.java
Pjirc 2.2.1 as available on the net, reformatted and made it compile.
[irc/pjirc-ng.git] / src / main / java / irc / dcc / DCCChatInterpretor.java
1 /*****************************************************/\r
2 /*          This java file is a part of the          */\r
3 /*                                                   */\r
4 /*           -  Plouf's Java IRC Client  -           */\r
5 /*                                                   */\r
6 /*   Copyright (C)  2002 - 2004 Philippe Detournay   */\r
7 /*                                                   */\r
8 /*         All contacts : theplouf@yahoo.com         */\r
9 /*                                                   */\r
10 /*  PJIRC is free software; you can redistribute     */\r
11 /*  it and/or modify it under the terms of the GNU   */\r
12 /*  General Public License as published by the       */\r
13 /*  Free Software Foundation; version 2 or later of  */\r
14 /*  the License.                                     */\r
15 /*                                                   */\r
16 /*  PJIRC is distributed in the hope that it will    */\r
17 /*  be useful, but WITHOUT ANY WARRANTY; without     */\r
18 /*  even the implied warranty of MERCHANTABILITY or  */\r
19 /*  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   */\r
20 /*  General Public License for more details.         */\r
21 /*                                                   */\r
22 /*  You should have received a copy of the GNU       */\r
23 /*  General Public License along with PJIRC; if      */\r
24 /*  not, write to the Free Software Foundation,      */\r
25 /*  Inc., 59 Temple Place, Suite 330, Boston,        */\r
26 /*  MA  02111-1307  USA                              */\r
27 /*                                                   */\r
28 /*****************************************************/\r
29 \r
30 package irc.dcc;\r
31 \r
32 import irc.BasicInterpretor;\r
33 import irc.IRCConfiguration;\r
34 import irc.IRCTextProvider;\r
35 import irc.Server;\r
36 import irc.Source;\r
37 \r
38 /**\r
39  * The DCCChatInterpretor.\r
40  */\r
41 public class DCCChatInterpretor extends BasicInterpretor {\r
42         /**\r
43          * Create a new DCCChatInterpretor.\r
44          * \r
45          * @param config\r
46          *          global irc configuration.\r
47          */\r
48         public DCCChatInterpretor(IRCConfiguration config) {\r
49                 super(config);\r
50         }\r
51 \r
52         @Override\r
53         protected void handleCommand(Source source, String cmd, String[] parts, String[] cumul) {\r
54                 if (cmd.equals("query")) {\r
55                         source.report(getText(IRCTextProvider.INTERPRETOR_BAD_CONTEXT, "/query"));\r
56                 } else if (cmd.equals("ctcp")) {\r
57                         source.report(getText(IRCTextProvider.INTERPRETOR_CANNOT_CTCP_IN_DCCCHAT));\r
58                 } else {\r
59                         super.handleCommand(source, cmd, parts, cumul);\r
60                 }\r
61         }\r
62 \r
63         @Override\r
64         protected void say(Source source, String str) {\r
65                 Server server = source.getServer();\r
66                 if (source.talkable()) {\r
67                         source.messageReceived(server.getNick(), str);\r
68                         server.say(source.getName(), str);\r
69                 } else {\r
70                         source.report(getText(IRCTextProvider.INTERPRETOR_NOT_ON_CHANNEL));\r
71                 }\r
72         }\r
73 }\r