|
@@ -2794,30 +2794,32 @@ func webircHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
2794
|
2794
|
return true
|
2795
|
2795
|
}
|
2796
|
2796
|
|
2797
|
|
-const WhoFieldMinimum = int('a') // lowest rune value
|
2798
|
|
-const WhoFieldMaximum = int('z')
|
|
2797
|
+type whoxFields uint32 // bitset to hold the WHOX field values, 'a' through 'z'
|
2799
|
2798
|
|
2800
|
|
-type WhoFields [WhoFieldMaximum - WhoFieldMinimum + 1]bool
|
|
2799
|
+func (fields whoxFields) Add(field rune) (result whoxFields) {
|
|
2800
|
+ index := int(field) - int('a')
|
|
2801
|
+ if 0 <= index && index < 26 {
|
|
2802
|
+ return fields | (1 << index)
|
|
2803
|
+ } else {
|
|
2804
|
+ return fields
|
|
2805
|
+ }
|
|
2806
|
+}
|
2801
|
2807
|
|
2802
|
|
-func (fields *WhoFields) Set(field rune) bool {
|
2803
|
|
- index := int(field)
|
2804
|
|
- if WhoFieldMinimum <= index && index <= WhoFieldMaximum {
|
2805
|
|
- fields[int(field)-WhoFieldMinimum] = true
|
2806
|
|
- return true
|
|
2808
|
+func (fields whoxFields) Has(field rune) bool {
|
|
2809
|
+ index := int(field) - int('a')
|
|
2810
|
+ if 0 <= index && index < 26 {
|
|
2811
|
+ return (fields & (1 << index)) != 0
|
2807
|
2812
|
} else {
|
2808
|
2813
|
return false
|
2809
|
2814
|
}
|
2810
|
2815
|
}
|
2811
|
|
-func (fields *WhoFields) Has(field rune) bool {
|
2812
|
|
- return fields[int(field)-WhoFieldMinimum]
|
2813
|
|
-}
|
2814
|
2816
|
|
2815
|
2817
|
// rplWhoReply returns the WHO(X) reply between one user and another channel/user.
|
2816
|
2818
|
// who format:
|
2817
|
2819
|
// <channel> <user> <host> <server> <nick> <H|G>[*][~|&|@|%|+][B] :<hopcount> <real name>
|
2818
|
2820
|
// whox format:
|
2819
|
2821
|
// <type> <channel> <user> <ip> <host> <server> <nick> <H|G>[*][~|&|@|%|+][B] <hops> <idle> <account> <rank> :<real name>
|
2820
|
|
-func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *ResponseBuffer, isWhox bool, fields WhoFields, whoType string) {
|
|
2822
|
+func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *ResponseBuffer, isWhox bool, fields whoxFields, whoType string) {
|
2821
|
2823
|
params := []string{client.Nick()}
|
2822
|
2824
|
|
2823
|
2825
|
details := target.Details()
|
|
@@ -2940,9 +2942,9 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
|
2940
|
2942
|
sFields = strings.ToLower(sFields[:typeIndex])
|
2941
|
2943
|
}
|
2942
|
2944
|
}
|
2943
|
|
- var fields WhoFields
|
|
2945
|
+ var fields whoxFields
|
2944
|
2946
|
for _, field := range sFields {
|
2945
|
|
- fields.Set(field)
|
|
2947
|
+ fields = fields.Add(field)
|
2946
|
2948
|
}
|
2947
|
2949
|
|
2948
|
2950
|
//TODO(dan): is this used and would I put this param in the Modern doc?
|