Kaynağa Gözat

Added part command

git-svn-id: http://svn.dmdirc.com/trunk@222 00569f92-eb28-0410-84fd-f71c24880f
tags/0.1
Chris Smith 17 yıl önce
ebeveyn
işleme
2f9c8e5915

+ 22
- 0
src/uk/org/ownage/dmdirc/commandparser/CommandManager.java Dosyayı Görüntüle

@@ -53,6 +53,8 @@ public class CommandManager {
53 53
             
54 54
             channelCommands.add(new Me());
55 55
             channelCommands.add(new MeEmpty());
56
+            channelCommands.add(new Part());
57
+            channelCommands.add(new PartDefault());
56 58
         }
57 59
         
58 60
         for (Command com : channelCommands) {
@@ -100,6 +102,26 @@ public class CommandManager {
100 102
         return null;
101 103
     }
102 104
     
105
+    /**
106
+     * Retrieves the channel command identified by the specified signature
107
+     * @param signature The signature to look for
108
+     * @return A channel command with a matching signature, or null if none
109
+     * were found.
110
+     */
111
+    public static ChannelCommand getChannelCommand(String signature) {
112
+        if (channelCommands == null) {
113
+            return null;
114
+        }
115
+        
116
+        for (Command com : channelCommands) {
117
+            if (com.getSignature().equals(signature)) {
118
+                return (ChannelCommand) com;
119
+            }
120
+        }
121
+        
122
+        return null;
123
+    }    
124
+    
103 125
     public static Vector<Command> getServerCommands() {
104 126
         if (serverCommands == null) {
105 127
             return null;

+ 53
- 0
src/uk/org/ownage/dmdirc/commandparser/commands/channel/Part.java Dosyayı Görüntüle

@@ -0,0 +1,53 @@
1
+/*
2
+ * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.org.ownage.dmdirc.commandparser.commands.channel;
24
+
25
+import uk.org.ownage.dmdirc.Channel;
26
+import uk.org.ownage.dmdirc.Config;
27
+import uk.org.ownage.dmdirc.Server;
28
+import uk.org.ownage.dmdirc.commandparser.ChannelCommand;
29
+import uk.org.ownage.dmdirc.commandparser.CommandManager;
30
+import uk.org.ownage.dmdirc.commandparser.CommandWindow;
31
+
32
+/**
33
+ *
34
+ * @author chris
35
+ */
36
+public class Part extends ChannelCommand {
37
+    
38
+    /** Creates a new instance of Part */
39
+    public Part() {
40
+        description = "parts the channel with the specified reason";
41
+        arguments = "<reason>";
42
+        polyadic = true;
43
+        arity = 0;
44
+        name = "part";
45
+        show = true;
46
+    }
47
+
48
+    public void execute(CommandWindow origin, Server server, Channel channel, String... args) {
49
+        channel.part(implodeArgs(args));
50
+        channel.close();
51
+    }
52
+    
53
+}

+ 54
- 0
src/uk/org/ownage/dmdirc/commandparser/commands/channel/PartDefault.java Dosyayı Görüntüle

@@ -0,0 +1,54 @@
1
+/*
2
+ * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.org.ownage.dmdirc.commandparser.commands.channel;
24
+
25
+import uk.org.ownage.dmdirc.Channel;
26
+import uk.org.ownage.dmdirc.Config;
27
+import uk.org.ownage.dmdirc.Server;
28
+import uk.org.ownage.dmdirc.commandparser.ChannelCommand;
29
+import uk.org.ownage.dmdirc.commandparser.CommandManager;
30
+import uk.org.ownage.dmdirc.commandparser.CommandWindow;
31
+
32
+/**
33
+ *
34
+ * @author chris
35
+ */
36
+public class PartDefault extends ChannelCommand {
37
+    
38
+    /** Creates a new instance of PartDefault */
39
+    public PartDefault() {
40
+        description = "parts the channel with the default reason";
41
+        arguments = "";
42
+        polyadic = false;
43
+        arity = 0;
44
+        name = "part";
45
+        show = true;
46
+    }
47
+    
48
+    public void execute(CommandWindow origin, Server server, Channel channel, String... args) {
49
+        ChannelCommand com = (ChannelCommand) CommandManager.getChannelCommand("part");
50
+        com.execute(origin, server, channel, Config.getOption("general","partmessage"));
51
+    }
52
+    
53
+}
54
+

Loading…
İptal
Kaydet