Переглянути джерело

Use new formatter for mode discovery.

pull/568/head
Chris Smith 9 роки тому
джерело
коміт
bcbf7dc346

+ 6
- 2
res/com/dmdirc/ui/messages/format.yml Переглянути файл

@@ -123,6 +123,12 @@ ChannelModeChangeEvent:
123 123
 ChannelSelfModeChangeEvent:
124 124
   format: "* You set mode: {{modes}}."
125 125
   colour: 3
126
+ChannelModesDiscoveredEvent:
127
+  format: "* Channel modes for {{channel.name}} are: {{modes}}."
128
+  colour: 3
129
+ChannelNoModesDiscoveredEvent:
130
+  format: "* There are no channel modes for {{channel.name}}."
131
+  colour: 3
126 132
 
127 133
 ################## Channel user events #############################################################
128 134
 
@@ -172,8 +178,6 @@ CommandOutputEvent:
172 178
   format: "{{message}}"
173 179
 
174 180
 ################## TODO ############################################################################
175
-#  channelNoModes=3* There are no channel modes for %2$s.
176
-#  channelModeDiscovered=3* Channel modes for %2$s are: %1$s.
177 181
 #  userModeChanged=3* %1$s sets user mode: %4$s.
178 182
 #  userNoModes=3* No user modes.
179 183
 #  userModeDiscovered=3* User modes are: %4$s.

+ 7
- 6
src/com/dmdirc/ChannelEventHandler.java Переглянути файл

@@ -34,6 +34,7 @@ import com.dmdirc.events.ChannelModeChangeEvent;
34 34
 import com.dmdirc.events.ChannelModeNoticeEvent;
35 35
 import com.dmdirc.events.ChannelModesDiscoveredEvent;
36 36
 import com.dmdirc.events.ChannelNickChangeEvent;
37
+import com.dmdirc.events.ChannelNoModesDiscoveredEvent;
37 38
 import com.dmdirc.events.ChannelNoTopicEvent;
38 39
 import com.dmdirc.events.ChannelNoticeEvent;
39 40
 import com.dmdirc.events.ChannelPartEvent;
@@ -55,7 +56,6 @@ import com.dmdirc.parser.events.OtherAwayStateEvent;
55 56
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
56 57
 import com.dmdirc.parser.interfaces.ChannelInfo;
57 58
 import com.dmdirc.parser.interfaces.Parser;
58
-import com.dmdirc.util.EventUtils;
59 59
 
60 60
 import com.google.common.base.Strings;
61 61
 
@@ -280,11 +280,12 @@ public class ChannelEventHandler extends EventHandler {
280 280
         final Date date = event.getDate();
281 281
 
282 282
         if (host.isEmpty()) {
283
-            final ChannelModesDiscoveredEvent coreEvent = new ChannelModesDiscoveredEvent(
284
-                    date.getTime(), owner, modes.length() <= 1 ? "" : modes);
285
-            final String format = EventUtils.postDisplayable(eventBus, coreEvent,
286
-                    modes.length() <= 1 ? "channelNoModes" : "channelModeDiscovered");
287
-            owner.doNotification(date, format, modes.length() <= 1 ? "" : modes);
283
+            if (modes.length() <= 1) {
284
+                eventBus.publishAsync(new ChannelNoModesDiscoveredEvent(date.getTime(), owner));
285
+            } else {
286
+                eventBus.publishAsync(
287
+                        new ChannelModesDiscoveredEvent(date.getTime(), owner,modes));
288
+            }
288 289
         } else if (isMyself(client)) {
289 290
             eventBus.publishAsync(new ChannelSelfModeChangeEvent(date.getTime(), owner,
290 291
                     groupChatUserManager.getUserFromClient(client, owner), modes));

+ 34
- 0
src/com/dmdirc/ParserFilteringListener.java Переглянути файл

@@ -0,0 +1,34 @@
1
+/*
2
+ * Copyright (c) 2006-2015 DMDirc Developers
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 com.dmdirc;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Created by chris on 31/01/15.
29
+ */
30
+public interface ParserFilteringListener {
31
+
32
+    Parser getParser();
33
+
34
+}

+ 40
- 0
src/com/dmdirc/events/ChannelNoModesDiscoveredEvent.java Переглянути файл

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2015 DMDirc Developers
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 com.dmdirc.events;
24
+
25
+import com.dmdirc.interfaces.GroupChat;
26
+
27
+/**
28
+ * Fired when channel mode discovery is complete and there are no modes on the channel.
29
+ */
30
+public class ChannelNoModesDiscoveredEvent extends ChannelDisplayableEvent {
31
+
32
+    public ChannelNoModesDiscoveredEvent(final long timestamp, final GroupChat channel) {
33
+        super(timestamp, channel);
34
+    }
35
+
36
+    public ChannelNoModesDiscoveredEvent(final GroupChat channel) {
37
+        super(channel);
38
+    }
39
+
40
+}

Завантаження…
Відмінити
Зберегти