Changeset 139 in code for trunk/downstream.go
- Timestamp:
- Mar 25, 2020, 8:40:08 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r137 r139 852 852 } 853 853 854 uc, upstreamName, err := dc.unmarshalEntity(name) 855 if err != nil { 856 return err 857 } 858 859 if uc.isChannel(upstreamName) { 860 // TODO: handle MODE channel mode arguments 861 if modeStr != "" { 862 uc.SendMessage(&irc.Message{ 863 Command: "MODE", 864 Params: []string{upstreamName, modeStr}, 865 }) 866 } else { 867 ch, ok := uc.channels[upstreamName] 868 if !ok { 869 return ircError{&irc.Message{ 870 Command: irc.ERR_NOSUCHCHANNEL, 871 Params: []string{dc.nick, name, "No such channel"}, 872 }} 873 } 874 875 dc.SendMessage(&irc.Message{ 876 Prefix: dc.srv.prefix(), 877 Command: irc.RPL_CHANNELMODEIS, 878 Params: []string{dc.nick, name, string(ch.modes)}, 879 }) 880 } 881 } else { 882 if name != dc.nick { 883 return ircError{&irc.Message{ 884 Command: irc.ERR_USERSDONTMATCH, 885 Params: []string{dc.nick, "Cannot change mode for other users"}, 886 }} 887 } 888 854 if name == dc.nick { 889 855 if modeStr != "" { 890 856 dc.forEachUpstream(func(uc *upstreamConn) { … … 901 867 }) 902 868 } 869 return nil 870 } 871 872 uc, upstreamName, err := dc.unmarshalEntity(name) 873 if err != nil { 874 return err 875 } 876 877 if !uc.isChannel(upstreamName) { 878 return ircError{&irc.Message{ 879 Command: irc.ERR_USERSDONTMATCH, 880 Params: []string{dc.nick, "Cannot change mode for other users"}, 881 }} 882 } 883 884 if modeStr != "" { 885 params := []string{upstreamName, modeStr} 886 params = append(params, msg.Params[2:]...) 887 uc.SendMessage(&irc.Message{ 888 Command: "MODE", 889 Params: params, 890 }) 891 } else { 892 ch, ok := uc.channels[upstreamName] 893 if !ok { 894 return ircError{&irc.Message{ 895 Command: irc.ERR_NOSUCHCHANNEL, 896 Params: []string{dc.nick, name, "No such channel"}, 897 }} 898 } 899 900 if ch.modes == nil { 901 // we haven't received the initial RPL_CHANNELMODEIS yet 902 // ignore the request, we will broadcast the modes later when we receive RPL_CHANNELMODEIS 903 return nil 904 } 905 906 modeStr, modeParams := ch.modes.Format() 907 params := []string{dc.nick, name, modeStr} 908 params = append(params, modeParams...) 909 910 dc.SendMessage(&irc.Message{ 911 Prefix: dc.srv.prefix(), 912 Command: irc.RPL_CHANNELMODEIS, 913 Params: params, 914 }) 903 915 } 904 916 case "WHO":
Note:
See TracChangeset
for help on using the changeset viewer.