Selaa lähdekoodia

Use new formatter for channel nick changes.

pull/386/head
Chris Smith 9 vuotta sitten
vanhempi
commit
b4551bf883

+ 9
- 2
res/com/dmdirc/ui/messages/format.yml Näytä tiedosto

@@ -79,6 +79,15 @@ ChannelSelfModeChangeEvent:
79 79
   format: "* You set mode: {{modes}}."
80 80
   colour: 3
81 81
 
82
+################## Channel user events #############################################################
83
+
84
+ChannelNickChangeEvent:
85
+  format: "* {{client.importantMode}}{{oldNick}} is now known as {{client.nickname}}."
86
+  colour: 3
87
+ChannelSelfNickChangeEvent:
88
+  format: "* You are now known as {{client.nickname}}."
89
+  colour: 3
90
+
82 91
 ################## Query events ####################################################################
83 92
 
84 93
 QueryActionEvent:
@@ -93,8 +102,6 @@ QuerySelfMessageEvent:
93 102
   format: "<{{user.nickname}}> {{message}}"
94 103
 
95 104
 ################## TODO ############################################################################
96
-#  channelNickChange=3* %1$s%5$s is now known as %2$s.
97
-#  channelSelfNickChange=3* You are now known as %2$s.
98 105
 #  channelUserAway=14-- %1$s%2$s is now away.
99 106
 #  channelUserBack=14-- %1$s%2$s is now back.
100 107
 #  channelUserAwayDiscovered=14-- %1$s%2$s is away.

+ 11
- 5
src/com/dmdirc/ChannelEventHandler.java Näytä tiedosto

@@ -39,6 +39,7 @@ 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.ChannelSelfNickChangeEvent;
42 43
 import com.dmdirc.events.ChannelSelfPartEvent;
43 44
 import com.dmdirc.events.ChannelTopicChangeEvent;
44 45
 import com.dmdirc.events.ChannelTopicUnsetEvent;
@@ -264,12 +265,17 @@ public class ChannelEventHandler extends EventHandler implements
264 265
             final ChannelInfo channel, final ChannelClientInfo client, final String oldNick) {
265 266
         checkParser(parser);
266 267
 
267
-        final ChannelNickChangeEvent event = new ChannelNickChangeEvent(date.getTime(), owner,
268
-                groupChatUserManager.getUserFromClient(client, owner), oldNick);
269
-        final String format = EventUtils.postDisplayable(eventBus, event,
270
-                isMyself(client) ? "channelSelfNickChange" : "channelNickChange");
271
-        owner.doNotification(date, format, groupChatUserManager.getUserFromClient(client, owner), oldNick);
272 268
         owner.renameClient(oldNick, client.getClient().getNickname());
269
+
270
+        if (isMyself(client)) {
271
+            eventBus.publishAsync(
272
+                    new ChannelSelfNickChangeEvent(date.getTime(), owner,
273
+                            groupChatUserManager.getUserFromClient(client, owner), oldNick));
274
+        } else {
275
+            eventBus.publishAsync(
276
+                    new ChannelNickChangeEvent(date.getTime(), owner,
277
+                            groupChatUserManager.getUserFromClient(client, owner), oldNick));
278
+        }
273 279
     }
274 280
 
275 281
     @Override

+ 58
- 0
src/com/dmdirc/events/ChannelSelfNickChangeEvent.java Näytä tiedosto

@@ -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 changes nickname in a channel.
30
+ */
31
+public class ChannelSelfNickChangeEvent extends ChannelDisplayableEvent {
32
+
33
+    private final GroupChatUser client;
34
+    private final String oldNick;
35
+
36
+    public ChannelSelfNickChangeEvent(final long timestamp, final Channel channel,
37
+            final GroupChatUser client, final String oldNick) {
38
+        super(timestamp, channel);
39
+        this.client = client;
40
+        this.oldNick = oldNick;
41
+    }
42
+
43
+    public ChannelSelfNickChangeEvent(final Channel channel, final GroupChatUser client,
44
+            final String oldNick) {
45
+        super(channel);
46
+        this.client = client;
47
+        this.oldNick = oldNick;
48
+    }
49
+
50
+    public GroupChatUser getClient() {
51
+        return client;
52
+    }
53
+
54
+    public String getOldNick() {
55
+        return oldNick;
56
+    }
57
+
58
+}

Loading…
Peruuta
Tallenna