From 69a35069efe1d7ce096a0ac58acc1c510c677c06 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 7 Feb 2020 13:36:32 +0100 Subject: [PATCH] Handle downstream PART messages --- downstream.go | 13 +++++++++++++ server.go | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/downstream.go b/downstream.go index 0283358..45c4922 100644 --- a/downstream.go +++ b/downstream.go @@ -261,6 +261,19 @@ func (c *downstreamConn) handleMessageRegistered(msg *irc.Message) error { Command: irc.ERR_NOSUCHCHANNEL, Params: []string{name, "Channel name ambiguous"}, }} + case "PART": + var name string + if err := parseMessageParams(msg, &name); err != nil { + return err + } + + ch, err := c.user.getChannel(name) + if err != nil { + return err + } + + ch.conn.messages <- msg + // TODO: remove channel from upstream config case "MODE": var name string if err := parseMessageParams(msg, &name); err != nil { diff --git a/server.go b/server.go index ef5d4e5..dae434e 100644 --- a/server.go +++ b/server.go @@ -75,7 +75,10 @@ func (u *user) getChannel(name string) (*upstreamChannel, error) { } }) if channel == nil { - return nil, fmt.Errorf("unknown channel %q", name) + return nil, ircError{&irc.Message{ + Command: irc.ERR_NOSUCHCHANNEL, + Params: []string{name, "No such channel"}, + }} } return channel, nil }