Explorar el Código

Add new formatter entries for channel mode changes.

pull/344/head
Chris Smith hace 9 años
padre
commit
2b31be1c90

+ 6
- 2
res/com/dmdirc/ui/messages/format.yml Ver fichero

@@ -27,10 +27,14 @@ ChannelNotopicEvent:
27 27
 ChannelTopicUnsetEvent:
28 28
   format: "* {{client.modePrefixedNickname}} has removed the topic on {{channel.name}}."
29 29
   colour: 3
30
+ChannelModechangeEvent:
31
+  format: "* {{client.modePrefixedNickname}} sets mode: {{modes}}."
32
+  colour: 3
33
+ChannelSelfModeChangeEvent:
34
+  format: "* You set mode: {{modes}}."
35
+  colour: 3
30 36
 
31 37
 # TODO:
32
-#  channelModeChanged=3* %1$s%2$s sets mode: %5$s.
33
-#  channelSelfModeChanged=3* You set mode: %5$s.
34 38
 #  channelCTCP=4-!- CTCP %5$S from %1$s%2$s
35 39
 #  channelPart=3* %1$s%2$s (%3$s@%4$s) has left %6$s.
36 40
 #  channelPartReason=3* %1$s%2$s (%3$s@%4$s) has left %6$s (%5$s).

+ 11
- 12
src/com/dmdirc/ChannelEventHandler.java Ver fichero

@@ -38,6 +38,7 @@ import com.dmdirc.events.ChannelNoticeEvent;
38 38
 import com.dmdirc.events.ChannelNotopicEvent;
39 39
 import com.dmdirc.events.ChannelPartEvent;
40 40
 import com.dmdirc.events.ChannelQuitEvent;
41
+import com.dmdirc.events.ChannelSelfModeChangeEvent;
41 42
 import com.dmdirc.events.ChannelTopicChangeEvent;
42 43
 import com.dmdirc.events.ChannelTopicUnsetEvent;
43 44
 import com.dmdirc.events.ChannelUserAwayEvent;
@@ -289,13 +290,12 @@ public class ChannelEventHandler extends EventHandler implements
289 290
                 final String format = EventUtils.postDisplayable(eventBus, event,
290 291
                         modes.length() <= 1 ? "channelNoModes" : "channelModeDiscovered");
291 292
                 owner.doNotification(date, format, modes.length() <= 1 ? "" : modes);
293
+            } else if (isMyself(client)) {
294
+                eventBus.publishAsync(new ChannelSelfModeChangeEvent(date.getTime(), owner,
295
+                        groupChatUserManager.getUserFromClient(client, owner), modes));
292 296
             } else {
293
-                final ChannelModechangeEvent event = new ChannelModechangeEvent(date.getTime(),
294
-                        owner, groupChatUserManager.getUserFromClient(client, owner), modes);
295
-                final String format = EventUtils.postDisplayable(eventBus, event,
296
-                        isMyself(client) ? "channelSelfModeChanged" : "channelModeChanged");
297
-                owner.doNotification(date, format,
298
-                        groupChatUserManager.getUserFromClient(client, owner), modes);
297
+                eventBus.publishAsync(new ChannelModechangeEvent(date.getTime(), owner,
298
+                        groupChatUserManager.getUserFromClient(client, owner), modes));
299 299
             }
300 300
         }
301 301
 
@@ -386,13 +386,12 @@ public class ChannelEventHandler extends EventHandler implements
386 386
                 final String format = EventUtils.postDisplayable(eventBus, event,
387 387
                         modes.length() <= 1 ? "channelNoModes" : "channelModeDiscovered");
388 388
                 owner.doNotification(date, format, modes.length() <= 1 ? "" : modes);
389
+            } else if (isMyself(client)) {
390
+                eventBus.publishAsync(new ChannelSelfModeChangeEvent(date.getTime(), owner,
391
+                        groupChatUserManager.getUserFromClient(client, owner), modes));
389 392
             } else {
390
-                final ChannelModechangeEvent event = new ChannelModechangeEvent(date.getTime(),
391
-                        owner, groupChatUserManager.getUserFromClient(client, owner), modes);
392
-                final String format = EventUtils.postDisplayable(eventBus, event,
393
-                        isMyself(client) ? "channelSelfModeChanged" : "channelModeChanged");
394
-                owner.doNotification(date, format,
395
-                        groupChatUserManager.getUserFromClient(client, owner), modes);
393
+                eventBus.publishAsync(new ChannelModechangeEvent(date.getTime(), owner,
394
+                        groupChatUserManager.getUserFromClient(client, owner), modes));
396 395
             }
397 396
         }
398 397
 

+ 43
- 0
src/com/dmdirc/events/ChannelSelfModeChangeEvent.java Ver fichero

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright (c) 2006-2014 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.Channel;
26
+import com.dmdirc.interfaces.GroupChatUser;
27
+
28
+/**
29
+ * Event raised when the local client changes a channel mode.
30
+ */
31
+public class ChannelSelfModeChangeEvent extends ChannelModechangeEvent {
32
+
33
+    public ChannelSelfModeChangeEvent(final long timestamp, final Channel channel,
34
+            final GroupChatUser client, final String modes) {
35
+        super(timestamp, channel, client, modes);
36
+    }
37
+
38
+    public ChannelSelfModeChangeEvent(final Channel channel, final GroupChatUser client,
39
+            final String modes) {
40
+        super(channel, client, modes);
41
+    }
42
+
43
+}

Loading…
Cancelar
Guardar