Changeset 160 in code for trunk


Ignore:
Timestamp:
Mar 26, 2020, 9:27:46 PM (5 years ago)
Author:
delthas
Message:

Add downstream TOPIC support

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bridge.go

    r140 r160  
    1010        }
    1111
     12        sendTopic(dc, ch)
     13
     14        // TODO: rpl_topicwhotime
     15        sendNames(dc, ch)
     16}
     17
     18func sendTopic(dc *downstreamConn, ch *upstreamChannel) {
    1219        downstreamName := dc.marshalChannel(ch.conn, ch.Name)
    1320
     
    2532                })
    2633        }
    27 
    28         // TODO: rpl_topicwhotime
    29         sendNames(dc, ch)
    3034}
    3135
  • trunk/downstream.go

    r159 r160  
    10331033                        })
    10341034                }
     1035        case "TOPIC":
     1036                var channel string
     1037                if err := parseMessageParams(msg, &channel); err != nil {
     1038                        return err
     1039                }
     1040
     1041                uc, upstreamChannel, err := dc.unmarshalEntity(channel)
     1042                if err != nil {
     1043                        return err
     1044                }
     1045
     1046                if len(msg.Params) > 1 { // setting topic
     1047                        topic := msg.Params[1]
     1048                        uc.SendMessage(&irc.Message{
     1049                                Command: "TOPIC",
     1050                                Params:  []string{upstreamChannel, topic},
     1051                        })
     1052                } else { // getting topic
     1053                        ch, ok := uc.channels[upstreamChannel]
     1054                        if !ok {
     1055                                return ircError{&irc.Message{
     1056                                        Command: irc.ERR_NOSUCHCHANNEL,
     1057                                        Params:  []string{dc.nick, upstreamChannel, "No such channel"},
     1058                                }}
     1059                        }
     1060                        sendTopic(dc, ch)
     1061                }
    10351062        case "NAMES":
    10361063                if len(msg.Params) == 0 {
Note: See TracChangeset for help on using the changeset viewer.