1 | package jounce
|
---|
2 |
|
---|
3 | import (
|
---|
4 | "gopkg.in/irc.v3"
|
---|
5 | )
|
---|
6 |
|
---|
7 | func forwardChannel(dc *downstreamConn, ch *upstreamChannel) {
|
---|
8 | if !ch.complete {
|
---|
9 | panic("Tried to forward a partial channel")
|
---|
10 | }
|
---|
11 |
|
---|
12 | dc.messages <- &irc.Message{
|
---|
13 | Prefix: dc.prefix(),
|
---|
14 | Command: "JOIN",
|
---|
15 | Params: []string{ch.Name},
|
---|
16 | }
|
---|
17 |
|
---|
18 | if ch.Topic != "" {
|
---|
19 | dc.messages <- &irc.Message{
|
---|
20 | Prefix: dc.srv.prefix(),
|
---|
21 | Command: irc.RPL_TOPIC,
|
---|
22 | Params: []string{dc.nick, ch.Name, ch.Topic},
|
---|
23 | }
|
---|
24 | } else {
|
---|
25 | dc.messages <- &irc.Message{
|
---|
26 | Prefix: dc.srv.prefix(),
|
---|
27 | Command: irc.RPL_NOTOPIC,
|
---|
28 | Params: []string{dc.nick, ch.Name, "No topic is set"},
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | // TODO: rpl_topicwhotime
|
---|
33 |
|
---|
34 | // TODO: send multiple members in each message
|
---|
35 | for nick, membership := range ch.Members {
|
---|
36 | s := nick
|
---|
37 | if membership != 0 {
|
---|
38 | s = string(membership) + nick
|
---|
39 | }
|
---|
40 |
|
---|
41 | dc.messages <- &irc.Message{
|
---|
42 | Prefix: dc.srv.prefix(),
|
---|
43 | Command: irc.RPL_NAMREPLY,
|
---|
44 | Params: []string{dc.nick, string(ch.Status), ch.Name, s},
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | dc.messages <- &irc.Message{
|
---|
49 | Prefix: dc.srv.prefix(),
|
---|
50 | Command: irc.RPL_ENDOFNAMES,
|
---|
51 | Params: []string{dc.nick, ch.Name, "End of /NAMES list"},
|
---|
52 | }
|
---|
53 | }
|
---|