diff options
-rw-r--r-- | app.go | 24 | ||||
-rw-r--r-- | irc/events.go | 6 | ||||
-rw-r--r-- | irc/session.go | 26 |
3 files changed, 56 insertions, 0 deletions
@@ -686,6 +686,30 @@ func (app *App) handleIRCEvent(ev interface{}) { HeadColor: tcell.ColorGray, Body: body.StyledString(), }) + case irc.InviteEvent: + var buffer string + var notify ui.NotifyType + var body string + if app.s.IsMe(ev.Invitee) { + buffer = Home + notify = ui.NotifyHighlight + body = fmt.Sprintf("%s invited you to join %s", ev.Inviter, ev.Channel) + } else if app.s.IsMe(ev.Inviter) { + buffer = ev.Channel + notify = ui.NotifyNone + body = fmt.Sprintf("You invited %s to join this channel", ev.Invitee) + } else { + buffer = ev.Channel + notify = ui.NotifyUnread + body = fmt.Sprintf("%s invited %s to join this channel", ev.Inviter, ev.Invitee) + } + app.win.AddLine(buffer, notify, ui.Line{ + At: msg.TimeOrNow(), + Head: "--", + HeadColor: tcell.ColorGray, + Body: ui.Styled(body, tcell.StyleDefault.Foreground(tcell.ColorGray)), + Highlight: notify == ui.NotifyHighlight, + }) case irc.MessageEvent: buffer, line, hlNotification := app.formatMessage(ev) var notify ui.NotifyType diff --git a/irc/events.go b/irc/events.go index ba6e38d..4898c26 100644 --- a/irc/events.go +++ b/irc/events.go @@ -56,6 +56,12 @@ type ModeChangeEvent struct { Mode string } +type InviteEvent struct { + Inviter string + Invitee string + Channel string +} + type MessageEvent struct { User string Target string diff --git a/irc/session.go b/irc/session.go index 3b6a813..8a3c86b 100644 --- a/irc/session.go +++ b/irc/session.go @@ -863,6 +863,32 @@ func (s *Session) handleRegistered(msg Message) (Event, error) { Mode: strings.Join(msg.Params[1:], " "), }, nil } + case "INVITE": + if msg.Prefix == nil { + return nil, errMissingPrefix + } + + var nick, channel string + if err := msg.ParseParams(&nick, &channel); err != nil { + return nil, err + } + + return InviteEvent{ + Inviter: msg.Prefix.Name, + Invitee: nick, + Channel: channel, + }, nil + case rplInviting: + var nick, channel string + if err := msg.ParseParams(nil, &nick, &channel); err != nil { + return nil, err + } + + return InviteEvent{ + Inviter: s.nick, + Invitee: nick, + Channel: channel, + }, nil case "PRIVMSG", "NOTICE": if msg.Prefix == nil { return nil, errMissingPrefix |