Browse Source

Added notice command

git-svn-id: http://svn.dmdirc.com/trunk@983 00569f92-eb28-0410-84fd-f71c24880f
tags/0.4
Chris Smith 17 years ago
parent
commit
1b0ab7a7c2

+ 1
- 0
src/uk/org/ownage/dmdirc/commandparser/CommandManager.java View File

@@ -155,6 +155,7 @@ public final class CommandManager {
155 155
         new LoadPlugin();
156 156
         new Motd();
157 157
         new Nick();
158
+        new Notice();
158 159
         new Quit();
159 160
         new QuitDefault();
160 161
         new Raw();

+ 91
- 0
src/uk/org/ownage/dmdirc/commandparser/commands/server/Notice.java View File

@@ -0,0 +1,91 @@
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.server;
24
+
25
+import uk.org.ownage.dmdirc.Config;
26
+import uk.org.ownage.dmdirc.Server;
27
+import uk.org.ownage.dmdirc.commandparser.CommandManager;
28
+import uk.org.ownage.dmdirc.commandparser.CommandWindow;
29
+import uk.org.ownage.dmdirc.commandparser.ServerCommand;
30
+
31
+/**
32
+ * Allows the user to send notices.
33
+ * @author chris
34
+ */
35
+public final class Notice extends ServerCommand {
36
+    
37
+    /**
38
+     * Creates a new instance of Notice.
39
+     */
40
+    public Notice() {
41
+        super();
42
+        
43
+        CommandManager.registerCommand(this);
44
+    }
45
+    
46
+    /**
47
+     * Executes this command.
48
+     * @param origin The frame in which this command was issued
49
+     * @param server The server object that this command is associated with
50
+     * @param args The user supplied arguments
51
+     */
52
+    public void execute(final CommandWindow origin, final Server server,
53
+            final String... args) {
54
+        if (args.length < 2) {
55
+            origin.addLine("Usage: "
56
+                    + Config.getOption("general", "commandchar")
57
+                    + "notice <target> <message>");
58
+        } else {
59
+            server.getParser().sendLine("NOTICE " + args[0] + " :"
60
+                    + implodeArgs(1, args));
61
+            origin.addLine("selfNotice", args[0], implodeArgs(1, args));
62
+        }
63
+    }
64
+    
65
+    
66
+    /** {@inheritDoc}. */
67
+    public String getName() {
68
+        return "notice";
69
+    }
70
+    
71
+    /** {@inheritDoc}. */
72
+    public boolean showInHelp() {
73
+        return true;
74
+    }
75
+    
76
+    /** {@inheritDoc}. */
77
+    public boolean isPolyadic() {
78
+        return true;
79
+    }
80
+    
81
+    /** {@inheritDoc}. */
82
+    public int getArity() {
83
+        return 0;
84
+    }
85
+    
86
+    /** {@inheritDoc}. */
87
+    public String getHelp() {
88
+        return "notice <target> <message> - sends a notice";
89
+    }
90
+    
91
+}

+ 1
- 0
src/uk/org/ownage/dmdirc/ui/messages/Formatter.java View File

@@ -214,6 +214,7 @@ public final class Formatter {
214 214
         //    1: Target
215 215
         //    2: Message
216 216
         defaultProperties.setProperty("selfCTCP", colour + "4->- [%1$s] %2$s");
217
+        defaultProperties.setProperty("selfNotice", colour + "5>%1$s> %2$s");
217 218
         
218 219
         // Type: Miscellaneous
219 220
         //    1: Miscellaneous data

Loading…
Cancel
Save