diff options
author | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-16 16:04:19 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-16 16:04:19 +0200 |
commit | 1b15bf87e804692ca07bb5b7766d1fb80b024769 (patch) | |
tree | 3386cada20a2cd6ac81bd420ee29bac521d6474c | |
parent | irc: Simplify debug logging of incoming messages (diff) |
irc: Use typing constants
-rw-r--r-- | app.go | 12 | ||||
-rw-r--r-- | irc/events.go | 12 | ||||
-rw-r--r-- | irc/states.go | 15 |
3 files changed, 23 insertions, 16 deletions
@@ -135,16 +135,16 @@ func (app *App) handleIRCEvent(ev irc.Event) { app.win.AddLine(ev.Channel, l, isHighlight) app.win.TypingStop(ev.Channel, ev.Nick) - case irc.QueryTypingEvent: - if ev.State == 1 || ev.State == 2 { + case irc.QueryTagEvent: + if ev.Typing == irc.TypingActive || ev.Typing == irc.TypingPaused { app.win.TypingStart(ui.Home, ev.Nick) - } else { + } else if ev.Typing == irc.TypingDone { app.win.TypingStop(ui.Home, ev.Nick) } - case irc.ChannelTypingEvent: - if ev.State == 1 || ev.State == 2 { + case irc.ChannelTagEvent: + if ev.Typing == irc.TypingActive || ev.Typing == irc.TypingPaused { app.win.TypingStart(ev.Channel, ev.Nick) - } else { + } else if ev.Typing == irc.TypingDone { app.win.TypingStop(ev.Channel, ev.Nick) } case irc.HistoryEvent: diff --git a/irc/events.go b/irc/events.go index 194bc1c..32eb457 100644 --- a/irc/events.go +++ b/irc/events.go @@ -60,16 +60,16 @@ type ChannelMessageEvent struct { Time time.Time } -type QueryTypingEvent struct { - Nick string - State int - Time time.Time +type QueryTagEvent struct { + Nick string + Typing int + Time time.Time } -type ChannelTypingEvent struct { +type ChannelTagEvent struct { Nick string Channel string - State int + Typing int Time time.Time } diff --git a/irc/states.go b/irc/states.go index 87f8fa2..8638483 100644 --- a/irc/states.go +++ b/irc/states.go @@ -60,6 +60,13 @@ var SupportedCapabilities = map[string]struct{}{ "userhost-in-names": {}, } +const ( + TypingUnspec = iota + TypingActive + TypingPaused + TypingDone +) + type ConnectionState int const ( @@ -681,14 +688,14 @@ func (s *Session) handle(msg Message) (err error) { break } - typing := 0 + typing := TypingUnspec if t, ok := msg.Tags["+typing"]; ok { if t == "active" { - typing = 1 + typing = TypingActive } else if t == "paused" { - typing = 2 + typing = TypingPaused } else if t == "done" { - typing = 3 + typing = TypingDone } } else { break |