Kaynağa Gözat

Make channel part/quit events use the new formatter.

pull/364/head
Chris Smith 9 yıl önce
ebeveyn
işleme
1aac5499df

+ 14
- 6
res/com/dmdirc/ui/messages/format.yml Dosyayı Görüntüle

@@ -19,6 +19,20 @@ ChannelJoinEvent:
19 19
 ChannelSelfJoinEvent:
20 20
   format: "* You are now talking in {{channel.name}}."
21 21
   colour: 3
22
+ChannelPartEvent:
23
+  format: >
24
+             * {{client.modePrefixedNickname}} ({{client.username}}@{{client.hostname}})
25
+             has left {{channel.name}}{{message|bracketed}}.
26
+  colour: 3
27
+ChannelSelfPartEvent:
28
+  format: >
29
+             * You have left {{channel.name}}{{message|bracketed}}.
30
+  colour: 3
31
+ChannelQuitEvent:
32
+  format: >
33
+             * {{client.modePrefixedNickname}} ({{client.username}}@{{client.hostname}})
34
+             has quit IRC{{message|bracketed}}.
35
+  colour: 2
22 36
 
23 37
 ################## Channel message events ##########################################################
24 38
 
@@ -66,12 +80,6 @@ ChannelSelfModeChangeEvent:
66 80
   colour: 3
67 81
 
68 82
 # TODO:
69
-#  channelPart=3* %1$s%2$s (%3$s@%4$s) has left %6$s.
70
-#  channelPartReason=3* %1$s%2$s (%3$s@%4$s) has left %6$s (%5$s).
71
-#  channelQuit=2* %1$s%2$s (%3$s@%4$s) has quit IRC.
72
-#  channelQuitReason=2* %1$s%2$s (%3$s@%4$s) has quit IRC (%5$s).
73
-#  channelSelfPart=3* You have left the channel.
74
-#  channelSelfPartReason=3* You have left the channel.
75 83
 #  channelNickChange=3* %1$s%5$s is now known as %2$s.
76 84
 #  channelSelfNickChange=3* You are now known as %2$s.
77 85
 #  channelUserAway=14-- %1$s%2$s is now away.

+ 12
- 14
src/com/dmdirc/ChannelEventHandler.java Dosyayı Görüntüle

@@ -30,15 +30,16 @@ import com.dmdirc.events.ChannelJoinEvent;
30 30
 import com.dmdirc.events.ChannelKickEvent;
31 31
 import com.dmdirc.events.ChannelListModesRetrievedEvent;
32 32
 import com.dmdirc.events.ChannelMessageEvent;
33
-import com.dmdirc.events.ChannelModeNoticeEvent;
34 33
 import com.dmdirc.events.ChannelModeChangeEvent;
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.ChannelNoticeEvent;
38 37
 import com.dmdirc.events.ChannelNoTopicEvent;
38
+import com.dmdirc.events.ChannelNoticeEvent;
39 39
 import com.dmdirc.events.ChannelPartEvent;
40 40
 import com.dmdirc.events.ChannelQuitEvent;
41 41
 import com.dmdirc.events.ChannelSelfModeChangeEvent;
42
+import com.dmdirc.events.ChannelSelfPartEvent;
42 43
 import com.dmdirc.events.ChannelTopicChangeEvent;
43 44
 import com.dmdirc.events.ChannelTopicUnsetEvent;
44 45
 import com.dmdirc.events.ChannelUserAwayEvent;
@@ -213,13 +214,13 @@ public class ChannelEventHandler extends EventHandler implements
213 214
             final ChannelClientInfo client, final String reason) {
214 215
         checkParser(parser);
215 216
 
216
-        final ChannelPartEvent event = new ChannelPartEvent(date.getTime(), owner,
217
-                groupChatUserManager.getUserFromClient(client, owner), reason);
218
-        final String format = EventUtils.postDisplayable(eventBus, event,
219
-                "channel"
220
-                + (isMyself(client) ? "Self" : "") + "Part"
221
-                + (reason.isEmpty() ? "" : "Reason"));
222
-        owner.doNotification(date, format, groupChatUserManager.getUserFromClient(client, owner), reason);
217
+        if (isMyself(client)) {
218
+            eventBus.publishAsync(new ChannelSelfPartEvent(date.getTime(), owner,
219
+                    groupChatUserManager.getUserFromClient(client, owner), reason));
220
+        } else {
221
+            eventBus.publishAsync(new ChannelPartEvent(date.getTime(), owner,
222
+                    groupChatUserManager.getUserFromClient(client, owner), reason));
223
+        }
223 224
         owner.removeClient(groupChatUserManager.getUserFromClient(client, owner));
224 225
     }
225 226
 
@@ -243,11 +244,8 @@ public class ChannelEventHandler extends EventHandler implements
243 244
             final ChannelClientInfo client, final String reason) {
244 245
         checkParser(parser);
245 246
 
246
-        final ChannelQuitEvent event = new ChannelQuitEvent(date.getTime(), owner,
247
-                groupChatUserManager.getUserFromClient(client, owner), reason);
248
-        final String format = EventUtils.postDisplayable(eventBus, event,
249
-                "channelQuit" + (reason.isEmpty() ? "" : "Reason"));
250
-        owner.doNotification(date, format, groupChatUserManager.getUserFromClient(client, owner), reason);
247
+        eventBus.publishAsync(new ChannelQuitEvent(date.getTime(), owner,
248
+                groupChatUserManager.getUserFromClient(client, owner), reason));
251 249
         owner.removeClient(groupChatUserManager.getUserFromClient(client, owner));
252 250
     }
253 251
 

+ 58
- 0
src/com/dmdirc/events/ChannelSelfPartEvent.java Dosyayı Görüntüle

@@ -0,0 +1,58 @@
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.Channel;
26
+import com.dmdirc.interfaces.GroupChatUser;
27
+
28
+/**
29
+ * Fired when the local user parts a channel.
30
+ */
31
+public class ChannelSelfPartEvent extends ChannelDisplayableEvent {
32
+
33
+    private final GroupChatUser client;
34
+    private final String message;
35
+
36
+    public ChannelSelfPartEvent(final long timestamp, final Channel channel,
37
+            final GroupChatUser client, final String message) {
38
+        super(timestamp, channel);
39
+        this.client = client;
40
+        this.message = message;
41
+    }
42
+
43
+    public ChannelSelfPartEvent(final Channel channel, final GroupChatUser client,
44
+            final String message) {
45
+        super(channel);
46
+        this.client = client;
47
+        this.message = message;
48
+    }
49
+
50
+    public GroupChatUser getClient() {
51
+        return client;
52
+    }
53
+
54
+    public String getMessage() {
55
+        return message;
56
+    }
57
+
58
+}

Loading…
İptal
Kaydet