source: code/trunk/bridge.go@ 64

Last change on this file since 64 was 54, checked in by contact, 5 years ago

Don't write to downstreamConn.messages directly

Use a helper function instead. This will allow us to change
downstreamConn implementation details without having to update the whole
codebase.

File size: 1.1 KB
Line 
1package jounce
2
3import (
4 "gopkg.in/irc.v3"
5)
6
7func forwardChannel(dc *downstreamConn, ch *upstreamChannel) {
8 if !ch.complete {
9 panic("Tried to forward a partial channel")
10 }
11
12 dc.SendMessage(&irc.Message{
13 Prefix: dc.prefix(),
14 Command: "JOIN",
15 Params: []string{ch.Name},
16 })
17
18 if ch.Topic != "" {
19 dc.SendMessage(&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.SendMessage(&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.SendMessage(&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.SendMessage(&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}
Note: See TracBrowser for help on using the repository browser.