summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.go6
-rw-r--r--irc/events.go20
-rw-r--r--irc/states.go16
3 files changed, 38 insertions, 4 deletions
diff --git a/app.go b/app.go
index 17a131a..90ba980 100644
--- a/app.go
+++ b/app.go
@@ -91,6 +91,12 @@ func (app *App) handleIRCEvent(ev irc.Event) {
if app.cfg.Highlights == nil {
app.highlights[0] = app.s.LNick()
}
+ case irc.SelfNickEvent:
+ line := fmt.Sprintf("\x0314%s\x03\u2192\x0314%s\x03", ev.FormerNick, ev.NewNick)
+ app.win.AddLine(ui.Home, ui.NewLine(ev.Time, "--", line, true), true)
+ case irc.UserNickEvent:
+ line := fmt.Sprintf("\x0314%s\x03\u2192\x0314%s\x03", ev.FormerNick, ev.NewNick)
+ app.win.AddLine(ui.Home, ui.NewLine(ev.Time, "--", line, true), false)
case irc.SelfJoinEvent:
app.win.AddBuffer(ev.Channel)
case irc.UserJoinEvent:
diff --git a/irc/events.go b/irc/events.go
index 72a5880..b585915 100644
--- a/irc/events.go
+++ b/irc/events.go
@@ -34,6 +34,22 @@ func (c ChannelEvent) ChannelMapped() (channel string) {
return
}
+type SelfNickEvent struct {
+ FormerNick string
+ NewNick string
+ Time time.Time
+}
+
+type UserNickEvent struct {
+ FormerNick string
+ NewNick string
+ Time time.Time
+}
+
+type SelfJoinEvent struct {
+ ChannelEvent
+}
+
type UserJoinEvent struct {
UserEvent
ChannelEvent
@@ -50,10 +66,6 @@ type UserPartEvent struct {
Time time.Time
}
-type SelfJoinEvent struct {
- ChannelEvent
-}
-
type QueryMessageEvent struct {
UserEvent
Command string
diff --git a/irc/states.go b/irc/states.go
index 727dfa3..2e0edf9 100644
--- a/irc/states.go
+++ b/irc/states.go
@@ -736,10 +736,26 @@ func (s *Session) handleInner(msg Message) (err error) {
newNick := msg.Params[0]
lNewNick := strings.ToLower(newNick)
+ t, ok := msg.Time()
+ if !ok {
+ t = time.Now()
+ }
+
if lNick == s.lNick {
+ s.evts <- SelfNickEvent{
+ FormerNick: s.nick,
+ NewNick: newNick,
+ Time: t,
+ }
s.nick = newNick
s.lNick = lNewNick
} else {
+ s.evts <- UserNickEvent{
+ FormerNick: nick,
+ NewNick: newNick,
+ Time: t,
+ }
+ // TODO update state
}
case "FAIL":
fmt.Println("FAIL", msg.Params)