<commit_before>package irc

import (
	"log"
	"strconv"
)

type Channel struct {
	flags     ChannelModeSet
	lists     map[ChannelMode]*UserMaskSet
	key       Text
	members   MemberSet
	name      Name
	server    *Server
	topic     Text
	userLimit uint64
}

// NewChannel creates a new channel from a `Server` and a `name`
// string, which must be unique on the server.
func NewChannel(s *Server, name Name) *Channel {
	channel := &Channel{
		flags: make(ChannelModeSet),
		lists: map[ChannelMode]*UserMaskSet{
			BanMask:    NewUserMaskSet(),
			ExceptMask: NewUserMaskSet(),
			InviteMask: NewUserMaskSet(),
		},
		members: make(MemberSet),
		name:    name,
		server:  s,
	}

	s.channels.Add(channel)

	return channel
}

func (channel *Channel) IsEmpty() bool {
	return len(channel.members) == 0
}

func (channel *Channel) Names(client *Client) {
	client.RplNamReply(channel)
	client.RplEndOfNames(channel)
}

func (channel *Channel) ClientIsOperator(client *Client) bool {
	return client.flags[Operator] || channel.members.HasMode(client, ChannelOperator)
}

func (channel *Channel) Nicks(target *Client) []string {
	isMultiPrefix := (target != nil) && target.capabilities[MultiPrefix]
	nicks := make([]string, len(channel.members))
	i := 0
	for client, modes := range channel.members {
		if isMultiPrefix {
			if modes[ChannelOperator] {
				nicks[i] += "@"
			}
			if modes[Voice] {
				nicks[i] += "+"
			}
		} else {
			if modes[ChannelOperator] {
				nicks[i] += "@"
			} else if modes[Voice] {
				nicks[i] += "+"
			}
		}
		nicks[i] += client.Nick().String()
		i += 1
	}
	return nicks
}

func (channel *Channel) Id() Name {
	return channel.name
}

func (channel *Channel) Nick() Name {
	return channel.name
}

func (channel *Channel) String() string {
	return channel.Id().String()
}

// <mode> <mode params>
func (channel *Channel) ModeString(client *Client) (str string) {
	isMember := client.flags[Operator] || channel.members.Has(client)
	showKey := isMember && (channel.key != "")
	showUserLimit := channel.userLimit > 0

	// flags with args
	if showKey {
		str += Key.String()
	}
	if showUserLimit {
		str += UserLimit.String()
	}

	// flags
	for mode := range channel.flags {
		str += mode.String()
	}

	if len(str) > 0 {
		str = "+" + str
	}

	// args for flags with args: The order must match above to keep
	// positional arguments in place.
	if showKey {
		str += " " + channel.key.String()
	}
	if showUserLimit {
		str += " " + strconv.FormatUint(channel.userLimit, 10)
	}

	return
}<commit_msg>this is related to https://github.com/fluffle/goirc/pull/71: common irc server behaviour is to reply with an empty +<commit_after>package irc

import (
	"log"
	"strconv"
)

type Channel struct {
	flags     ChannelModeSet
	lists     map[ChannelMode]*UserMaskSet
	key       Text
	members   MemberSet
	name      Name
	server    *Server
	topic     Text
	userLimit uint64
}

// NewChannel creates a new channel from a `Server` and a `name`
// string, which must be unique on the server.
func NewChannel(s *Server, name Name) *Channel {
	channel := &Channel{
		flags: make(ChannelModeSet),
		lists: map[ChannelMode]*UserMaskSet{
			BanMask:    NewUserMaskSet(),
			ExceptMask: NewUserMaskSet(),
			InviteMask: NewUserMaskSet(),
		},
		members: make(MemberSet),
		name:    name,
		server:  s,
	}

	s.channels.Add(channel)

	return channel
}

func (channel *Channel) IsEmpty() bool {
	return len(channel.members) == 0
}

func (channel *Channel) Names(client *Client) {
	client.RplNamReply(channel)
	client.RplEndOfNames(channel)
}

func (channel *Channel) ClientIsOperator(client *Client) bool {
	return client.flags[Operator] || channel.members.HasMode(client, ChannelOperator)
}

func (channel *Channel) Nicks(target *Client) []string {
	isMultiPrefix := (target != nil) && target.capabilities[MultiPrefix]
	nicks := make([]string, len(channel.members))
	i := 0
	for client, modes := range channel.members {
		if isMultiPrefix {
			if modes[ChannelOperator] {
				nicks[i] += "@"
			}
			if modes[Voice] {
				nicks[i] += "+"
			}
		} else {
			if modes[ChannelOperator] {
				nicks[i] += "@"
			} else if modes[Voice] {
				nicks[i] += "+"
			}
		}
		nicks[i] += client.Nick().String()
		i += 1
	}
	return nicks
}

func (channel *Channel) Id() Name {
	return channel.name
}

func (channel *Channel) Nick() Name {
	return channel.name
}

func (channel *Channel) String() string {
	return channel.Id().String()
}

// <mode> <mode params>
func (channel *Channel) ModeString(client *Client) (str string) {
	isMember := client.flags[Operator] || channel.members.Has(client)
	showKey := isMember && (channel.key != "")
	showUserLimit := channel.userLimit > 0

	// flags with args
	if showKey {
		str += Key.String()
	}
	if showUserLimit {
		str += UserLimit.String()
	}

	// flags
	for mode := range channel.flags {
		str += mode.String()
	}

	str = "+" + str

	// args for flags with args: The order must match above to keep
	// positional arguments in place.
	if showKey {
		str += " " + channel.key.String()
	}
	if showUserLimit {
		str += " " + strconv.FormatUint(channel.userLimit, 10)
	}

	return
}
{'fraction_non_alphanumeric': 0.1392479435957697, 'fraction_numerical': 0.0037211124167645907, 'mean_word_length': 3.576164874551971, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6366355', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1729, 'n_words': 464}