source: code/trunk/bridge.go@ 62

Last change on this file since 62 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
RevLine 
[32]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
[54]12 dc.SendMessage(&irc.Message{
[32]13 Prefix: dc.prefix(),
14 Command: "JOIN",
15 Params: []string{ch.Name},
[54]16 })
[32]17
18 if ch.Topic != "" {
[54]19 dc.SendMessage(&irc.Message{
[32]20 Prefix: dc.srv.prefix(),
21 Command: irc.RPL_TOPIC,
22 Params: []string{dc.nick, ch.Name, ch.Topic},
[54]23 })
[32]24 } else {
[54]25 dc.SendMessage(&irc.Message{
[32]26 Prefix: dc.srv.prefix(),
27 Command: irc.RPL_NOTOPIC,
28 Params: []string{dc.nick, ch.Name, "No topic is set"},
[54]29 })
[32]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
[54]41 dc.SendMessage(&irc.Message{
[32]42 Prefix: dc.srv.prefix(),
43 Command: irc.RPL_NAMREPLY,
44 Params: []string{dc.nick, string(ch.Status), ch.Name, s},
[54]45 })
[32]46 }
47
[54]48 dc.SendMessage(&irc.Message{
[32]49 Prefix: dc.srv.prefix(),
50 Command: irc.RPL_ENDOFNAMES,
51 Params: []string{dc.nick, ch.Name, "End of /NAMES list"},
[54]52 })
[32]53}
Note: See TracBrowser for help on using the repository browser.