summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.go12
-rw-r--r--irc/events.go12
-rw-r--r--irc/states.go15
3 files changed, 23 insertions, 16 deletions
diff --git a/app.go b/app.go
index 47c6505..fb7faf6 100644
--- a/app.go
+++ b/app.go
@@ -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