2012-12-09 07:54:58 +01:00
|
|
|
package irc
|
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
import (
|
|
|
|
"strconv"
|
2014-02-26 05:17:26 +01:00
|
|
|
"strings"
|
2014-02-22 21:49:33 +01:00
|
|
|
)
|
|
|
|
|
2012-12-09 07:54:58 +01:00
|
|
|
type Channel struct {
|
2014-02-22 21:49:33 +01:00
|
|
|
flags ChannelModeSet
|
2014-02-23 00:01:11 +01:00
|
|
|
lists map[ChannelMode][]UserMask
|
2014-02-22 21:49:33 +01:00
|
|
|
key string
|
|
|
|
members MemberSet
|
|
|
|
name string
|
|
|
|
server *Server
|
|
|
|
topic string
|
|
|
|
userLimit uint64
|
2012-12-09 07:54:58 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 03:14:39 +01:00
|
|
|
func IsChannel(target string) bool {
|
2014-02-18 02:58:22 +01:00
|
|
|
return ChannelNameExpr.MatchString(target)
|
2014-02-09 03:14:39 +01:00
|
|
|
}
|
|
|
|
|
2014-02-05 04:28:24 +01:00
|
|
|
// NewChannel creates a new channel from a `Server` and a `name`
|
|
|
|
// string, which must be unique on the server.
|
2012-12-09 07:54:58 +01:00
|
|
|
func NewChannel(s *Server, name string) *Channel {
|
2012-12-15 23:34:20 +01:00
|
|
|
channel := &Channel{
|
2014-02-23 00:01:11 +01:00
|
|
|
flags: make(ChannelModeSet),
|
|
|
|
lists: map[ChannelMode][]UserMask{
|
|
|
|
BanMask: []UserMask{},
|
|
|
|
ExceptMask: []UserMask{},
|
|
|
|
InviteMask: []UserMask{},
|
|
|
|
},
|
2014-02-17 07:20:42 +01:00
|
|
|
members: make(MemberSet),
|
2014-02-26 05:17:26 +01:00
|
|
|
name: strings.ToLower(name),
|
2014-02-17 07:20:42 +01:00
|
|
|
server: s,
|
2012-12-09 21:51:50 +01:00
|
|
|
}
|
2014-02-25 20:11:34 +01:00
|
|
|
|
2014-02-26 05:17:26 +01:00
|
|
|
s.channels.Add(channel)
|
2014-02-25 20:11:34 +01:00
|
|
|
|
2012-12-15 23:34:20 +01:00
|
|
|
return channel
|
2012-12-09 07:54:58 +01:00
|
|
|
}
|
|
|
|
|
2013-05-12 20:20:55 +02:00
|
|
|
func (channel *Channel) IsEmpty() bool {
|
|
|
|
return len(channel.members) == 0
|
2012-12-10 06:46:22 +01:00
|
|
|
}
|
|
|
|
|
2014-02-18 06:02:03 +01:00
|
|
|
func (channel *Channel) Names(client *Client) {
|
2014-02-22 22:15:31 +01:00
|
|
|
client.RplNamReply(channel)
|
2014-02-20 07:20:34 +01:00
|
|
|
client.RplEndOfNames(channel)
|
2013-06-03 07:07:50 +02:00
|
|
|
}
|
|
|
|
|
2014-02-10 04:59:59 +01:00
|
|
|
func (channel *Channel) ClientIsOperator(client *Client) bool {
|
2014-02-17 22:22:35 +01:00
|
|
|
return client.flags[Operator] || channel.members.HasMode(client, ChannelOperator)
|
2014-02-10 04:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-02-05 04:28:24 +01:00
|
|
|
func (channel *Channel) Nicks() []string {
|
|
|
|
nicks := make([]string, len(channel.members))
|
|
|
|
i := 0
|
2014-02-15 06:57:08 +01:00
|
|
|
for client, modes := range channel.members {
|
|
|
|
switch {
|
|
|
|
case modes[ChannelOperator]:
|
|
|
|
nicks[i] = "@" + client.Nick()
|
|
|
|
case modes[Voice]:
|
|
|
|
nicks[i] = "+" + client.Nick()
|
|
|
|
default:
|
|
|
|
nicks[i] = client.Nick()
|
|
|
|
}
|
2014-02-05 04:28:24 +01:00
|
|
|
i += 1
|
|
|
|
}
|
|
|
|
return nicks
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (channel *Channel) Id() string {
|
2012-12-17 04:13:53 +01:00
|
|
|
return channel.name
|
|
|
|
}
|
|
|
|
|
2013-06-03 07:07:50 +02:00
|
|
|
func (channel *Channel) Nick() string {
|
|
|
|
return channel.name
|
|
|
|
}
|
|
|
|
|
2013-05-12 03:28:18 +02:00
|
|
|
func (channel *Channel) String() string {
|
|
|
|
return channel.Id()
|
|
|
|
}
|
|
|
|
|
2014-02-09 03:14:39 +01:00
|
|
|
// <mode> <mode params>
|
2014-02-22 21:49:33 +01:00
|
|
|
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 {
|
2014-02-15 06:57:08 +01:00
|
|
|
str += Key.String()
|
2014-02-09 08:33:56 +01:00
|
|
|
}
|
2014-02-22 21:49:33 +01:00
|
|
|
if showUserLimit {
|
|
|
|
str += UserLimit.String()
|
|
|
|
}
|
2014-02-15 06:57:08 +01:00
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
// flags
|
2014-02-15 06:57:08 +01:00
|
|
|
for mode := range channel.flags {
|
|
|
|
str += mode.String()
|
|
|
|
}
|
|
|
|
|
2014-02-09 17:53:06 +01:00
|
|
|
if len(str) > 0 {
|
|
|
|
str = "+" + str
|
|
|
|
}
|
2014-02-15 06:57:08 +01:00
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
// args for flags with args: The order must match above to keep
|
|
|
|
// positional arguments in place.
|
|
|
|
if showKey {
|
2014-02-15 06:57:08 +01:00
|
|
|
str += " " + channel.key
|
|
|
|
}
|
2014-02-22 21:49:33 +01:00
|
|
|
if showUserLimit {
|
|
|
|
str += " " + strconv.FormatUint(channel.userLimit, 10)
|
|
|
|
}
|
2014-02-15 06:57:08 +01:00
|
|
|
|
2014-02-09 08:33:56 +01:00
|
|
|
return
|
2014-02-09 03:14:39 +01:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
func (channel *Channel) IsFull() bool {
|
|
|
|
return (channel.userLimit > 0) &&
|
|
|
|
(uint64(len(channel.members)) >= channel.userLimit)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (channel *Channel) CheckKey(key string) bool {
|
|
|
|
return (channel.key == "") || (channel.key == key)
|
|
|
|
}
|
|
|
|
|
2014-02-17 07:20:42 +01:00
|
|
|
func (channel *Channel) Join(client *Client, key string) {
|
2014-02-22 21:49:33 +01:00
|
|
|
if channel.members.Has(client) {
|
|
|
|
// already joined, no message?
|
2012-12-09 07:54:58 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
if channel.IsFull() {
|
|
|
|
client.ErrChannelIsFull(channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !channel.CheckKey(key) {
|
|
|
|
client.ErrBadChannelKey(channel)
|
2014-02-21 03:56:13 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-02-19 04:31:59 +01:00
|
|
|
client.channels.Add(channel)
|
2014-02-17 02:23:47 +01:00
|
|
|
channel.members.Add(client)
|
|
|
|
if len(channel.members) == 1 {
|
2014-02-25 20:11:34 +01:00
|
|
|
if !channel.flags[Persistent] {
|
|
|
|
channel.members[client][ChannelCreator] = true
|
|
|
|
}
|
2014-02-17 02:23:47 +01:00
|
|
|
channel.members[client][ChannelOperator] = true
|
|
|
|
}
|
|
|
|
|
2014-02-20 07:20:34 +01:00
|
|
|
reply := RplJoin(client, channel)
|
|
|
|
for member := range channel.members {
|
2014-02-22 20:40:32 +01:00
|
|
|
member.Reply(reply)
|
2014-02-20 07:20:34 +01:00
|
|
|
}
|
2014-02-17 02:23:47 +01:00
|
|
|
channel.GetTopic(client)
|
2014-02-18 06:02:03 +01:00
|
|
|
channel.Names(client)
|
2014-02-17 02:23:47 +01:00
|
|
|
}
|
|
|
|
|
2014-02-17 07:20:42 +01:00
|
|
|
func (channel *Channel) Part(client *Client, message string) {
|
2014-02-09 08:15:05 +01:00
|
|
|
if !channel.members.Has(client) {
|
2014-02-20 07:20:34 +01:00
|
|
|
client.ErrNotOnChannel(channel)
|
2012-12-09 07:54:58 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-02-21 03:20:07 +01:00
|
|
|
reply := RplPart(client, channel, message)
|
2014-02-20 07:20:34 +01:00
|
|
|
for member := range channel.members {
|
2014-02-22 20:40:32 +01:00
|
|
|
member.Reply(reply)
|
2014-02-20 07:20:34 +01:00
|
|
|
}
|
2014-02-17 08:29:11 +01:00
|
|
|
channel.Quit(client)
|
2012-12-13 08:27:17 +01:00
|
|
|
|
2014-02-25 19:04:59 +01:00
|
|
|
if !channel.flags[Persistent] && channel.IsEmpty() {
|
2014-02-17 07:20:42 +01:00
|
|
|
channel.server.channels.Remove(channel)
|
2012-12-13 08:27:17 +01:00
|
|
|
}
|
2012-12-09 07:54:58 +01:00
|
|
|
}
|
|
|
|
|
2014-02-17 07:20:42 +01:00
|
|
|
func (channel *Channel) GetTopic(client *Client) {
|
2014-02-09 08:15:05 +01:00
|
|
|
if !channel.members.Has(client) {
|
2014-02-20 07:20:34 +01:00
|
|
|
client.ErrNotOnChannel(channel)
|
2012-12-09 07:54:58 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-02-17 07:20:42 +01:00
|
|
|
if channel.topic == "" {
|
|
|
|
// clients appear not to expect this
|
|
|
|
//replier.Reply(RplNoTopic(channel))
|
2012-12-09 07:54:58 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-02-20 07:20:34 +01:00
|
|
|
client.RplTopic(channel)
|
2014-02-17 07:20:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (channel *Channel) SetTopic(client *Client, topic string) {
|
2014-02-22 21:49:33 +01:00
|
|
|
if !(client.flags[Operator] || channel.members.Has(client)) {
|
2014-02-20 07:20:34 +01:00
|
|
|
client.ErrNotOnChannel(channel)
|
2014-02-17 07:20:42 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-02-21 05:47:05 +01:00
|
|
|
if channel.flags[OpOnlyTopic] && !channel.ClientIsOperator(client) {
|
2014-02-20 07:20:34 +01:00
|
|
|
client.ErrChanOPrivIsNeeded(channel)
|
2014-02-16 04:56:38 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-02-17 07:20:42 +01:00
|
|
|
channel.topic = topic
|
2014-02-21 05:47:05 +01:00
|
|
|
|
|
|
|
reply := RplTopicMsg(client, channel)
|
2014-02-20 07:20:34 +01:00
|
|
|
for member := range channel.members {
|
2014-02-22 20:40:32 +01:00
|
|
|
member.Reply(reply)
|
2014-02-20 07:20:34 +01:00
|
|
|
}
|
2014-02-26 00:57:35 +01:00
|
|
|
|
|
|
|
channel.Persist()
|
2012-12-15 23:34:20 +01:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
func (channel *Channel) CanSpeak(client *Client) bool {
|
|
|
|
if client.flags[Operator] {
|
|
|
|
return true
|
|
|
|
}
|
2014-02-15 06:57:08 +01:00
|
|
|
if channel.flags[NoOutside] && !channel.members.Has(client) {
|
2014-02-22 21:49:33 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
if channel.flags[Moderated] && !(channel.members.HasMode(client, Voice) ||
|
|
|
|
channel.members.HasMode(client, ChannelOperator)) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (channel *Channel) PrivMsg(client *Client, message string) {
|
|
|
|
if !channel.CanSpeak(client) {
|
2014-02-20 07:20:34 +01:00
|
|
|
client.ErrCannotSendToChan(channel)
|
2014-02-09 08:33:56 +01:00
|
|
|
return
|
|
|
|
}
|
2014-02-20 07:20:34 +01:00
|
|
|
for member := range channel.members {
|
|
|
|
if member == client {
|
|
|
|
continue
|
|
|
|
}
|
2014-02-22 20:40:32 +01:00
|
|
|
member.Reply(RplPrivMsg(client, channel, message))
|
2014-02-20 07:20:34 +01:00
|
|
|
}
|
2012-12-09 07:54:58 +01:00
|
|
|
}
|
2014-02-09 07:06:10 +01:00
|
|
|
|
2014-02-23 00:01:11 +01:00
|
|
|
func (channel *Channel) applyModeFlag(client *Client, mode ChannelMode,
|
|
|
|
op ModeOp) bool {
|
|
|
|
if !channel.ClientIsOperator(client) {
|
|
|
|
client.ErrChanOPrivIsNeeded(channel)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
switch op {
|
|
|
|
case Add:
|
|
|
|
channel.flags[mode] = true
|
|
|
|
return true
|
|
|
|
|
|
|
|
case Remove:
|
|
|
|
delete(channel.flags, mode)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (channel *Channel) applyModeMember(client *Client, mode ChannelMode,
|
|
|
|
op ModeOp, nick string) bool {
|
|
|
|
if !channel.ClientIsOperator(client) {
|
|
|
|
client.ErrChanOPrivIsNeeded(channel)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if nick == "" {
|
|
|
|
client.ErrNeedMoreParams("MODE")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
target := channel.server.clients.Get(nick)
|
|
|
|
if target == nil {
|
|
|
|
client.ErrNoSuchNick(nick)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if !channel.members.Has(target) {
|
|
|
|
client.ErrUserNotInChannel(channel, target)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
switch op {
|
|
|
|
case Add:
|
|
|
|
channel.members[target][mode] = true
|
|
|
|
return true
|
|
|
|
|
|
|
|
case Remove:
|
|
|
|
channel.members[target][mode] = false
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2014-02-24 03:05:06 +01:00
|
|
|
func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) bool {
|
2014-02-22 21:49:33 +01:00
|
|
|
switch change.mode {
|
2014-02-23 00:01:11 +01:00
|
|
|
case BanMask, ExceptMask, InviteMask:
|
2014-02-22 21:49:33 +01:00
|
|
|
// TODO add/remove
|
2014-02-16 04:49:20 +01:00
|
|
|
|
2014-02-23 00:01:11 +01:00
|
|
|
for _, mask := range channel.lists[change.mode] {
|
|
|
|
client.RplMaskList(change.mode, channel, mask)
|
2014-02-22 21:49:33 +01:00
|
|
|
}
|
2014-02-23 00:01:11 +01:00
|
|
|
client.RplEndOfMaskList(change.mode, channel)
|
2014-02-16 04:49:20 +01:00
|
|
|
|
2014-02-25 19:04:59 +01:00
|
|
|
case Moderated, NoOutside, OpOnlyTopic, Persistent, Private:
|
2014-02-23 00:01:11 +01:00
|
|
|
return channel.applyModeFlag(client, change.mode, change.op)
|
2014-02-15 06:57:08 +01:00
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
case Key:
|
|
|
|
if !channel.ClientIsOperator(client) {
|
|
|
|
client.ErrChanOPrivIsNeeded(channel)
|
|
|
|
return false
|
|
|
|
}
|
2014-02-15 06:57:08 +01:00
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
switch change.op {
|
|
|
|
case Add:
|
|
|
|
if change.arg == "" {
|
|
|
|
client.ErrNeedMoreParams("MODE")
|
|
|
|
return false
|
2014-02-15 06:57:08 +01:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
channel.key = change.arg
|
|
|
|
return true
|
2014-02-15 06:57:08 +01:00
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
case Remove:
|
|
|
|
channel.key = ""
|
|
|
|
return true
|
|
|
|
}
|
2014-02-15 06:57:08 +01:00
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
case UserLimit:
|
|
|
|
limit, err := strconv.ParseUint(change.arg, 10, 64)
|
|
|
|
if err != nil {
|
|
|
|
client.ErrNeedMoreParams("MODE")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if limit == 0 {
|
|
|
|
return false
|
|
|
|
}
|
2014-02-15 06:57:08 +01:00
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
channel.userLimit = limit
|
|
|
|
return true
|
2014-02-15 06:57:08 +01:00
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
case ChannelOperator, Voice:
|
2014-02-23 00:01:11 +01:00
|
|
|
return channel.applyModeMember(client, change.mode, change.op, change.arg)
|
2014-02-22 21:15:34 +01:00
|
|
|
|
2014-02-22 21:49:33 +01:00
|
|
|
default:
|
|
|
|
client.ErrUnknownMode(change.mode, channel)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (channel *Channel) Mode(client *Client, changes ChannelModeChanges) {
|
|
|
|
if len(changes) == 0 {
|
|
|
|
client.RplChannelModeIs(channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
applied := make(ChannelModeChanges, 0)
|
|
|
|
for _, change := range changes {
|
|
|
|
if channel.applyMode(client, change) {
|
|
|
|
applied = append(applied, change)
|
2014-02-09 07:06:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-17 07:20:42 +01:00
|
|
|
if len(applied) > 0 {
|
2014-02-22 21:49:33 +01:00
|
|
|
reply := RplChannelMode(client, channel, applied)
|
2014-02-20 07:20:34 +01:00
|
|
|
for member := range channel.members {
|
2014-02-22 21:49:33 +01:00
|
|
|
member.Reply(reply)
|
2014-02-20 07:20:34 +01:00
|
|
|
}
|
2014-02-25 20:11:34 +01:00
|
|
|
|
2014-02-26 00:57:35 +01:00
|
|
|
channel.Persist()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (channel *Channel) Persist() {
|
|
|
|
if channel.flags[Persistent] {
|
2014-02-25 20:11:34 +01:00
|
|
|
channel.server.db.Exec(`
|
2014-02-26 00:57:35 +01:00
|
|
|
INSERT OR REPLACE INTO channel
|
|
|
|
(name, flags, key, topic)
|
2014-02-26 01:13:47 +01:00
|
|
|
VALUES (?, ?, ?, ?, ?)`,
|
|
|
|
channel.name, channel.flags.String(), channel.key, channel.topic,
|
|
|
|
channel.userLimit)
|
2014-02-26 00:57:35 +01:00
|
|
|
} else {
|
|
|
|
channel.server.db.Exec(`DELETE FROM channel WHERE name = ?`, channel.name)
|
2014-02-16 04:49:20 +01:00
|
|
|
}
|
2014-02-09 07:06:10 +01:00
|
|
|
}
|
2014-02-12 02:11:59 +01:00
|
|
|
|
2014-02-17 07:20:42 +01:00
|
|
|
func (channel *Channel) Notice(client *Client, message string) {
|
2014-02-22 21:49:33 +01:00
|
|
|
if !channel.CanSpeak(client) {
|
2014-02-20 07:20:34 +01:00
|
|
|
client.ErrCannotSendToChan(channel)
|
2014-02-12 02:11:59 +01:00
|
|
|
return
|
|
|
|
}
|
2014-02-20 07:20:34 +01:00
|
|
|
for member := range channel.members {
|
|
|
|
if member == client {
|
|
|
|
continue
|
|
|
|
}
|
2014-02-22 20:40:32 +01:00
|
|
|
member.Reply(RplNotice(client, channel, message))
|
2014-02-20 07:20:34 +01:00
|
|
|
}
|
2014-02-12 02:11:59 +01:00
|
|
|
}
|
2014-02-17 02:23:47 +01:00
|
|
|
|
2014-02-17 07:20:42 +01:00
|
|
|
func (channel *Channel) Quit(client *Client) {
|
|
|
|
channel.members.Remove(client)
|
2014-02-17 08:29:11 +01:00
|
|
|
client.channels.Remove(channel)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (channel *Channel) Kick(client *Client, target *Client, comment string) {
|
2014-02-22 21:49:33 +01:00
|
|
|
if !(client.flags[Operator] || channel.members.Has(client)) {
|
2014-02-20 07:20:34 +01:00
|
|
|
client.ErrNotOnChannel(channel)
|
2014-02-17 08:29:11 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if !channel.ClientIsOperator(client) {
|
2014-02-20 07:20:34 +01:00
|
|
|
client.ErrChanOPrivIsNeeded(channel)
|
2014-02-17 08:29:11 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if !channel.members.Has(target) {
|
2014-02-20 07:20:34 +01:00
|
|
|
client.ErrUserNotInChannel(channel, target)
|
2014-02-17 08:29:11 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-02-21 05:47:05 +01:00
|
|
|
reply := RplKick(channel, client, target, comment)
|
2014-02-20 07:20:34 +01:00
|
|
|
for member := range channel.members {
|
2014-02-22 20:40:32 +01:00
|
|
|
member.Reply(reply)
|
2014-02-20 07:20:34 +01:00
|
|
|
}
|
2014-02-17 08:29:11 +01:00
|
|
|
channel.Quit(target)
|
2014-02-17 02:23:47 +01:00
|
|
|
}
|
2014-02-25 16:28:09 +01:00
|
|
|
|
|
|
|
func (channel *Channel) Invite(invitee *Client, inviter *Client) {
|
|
|
|
if channel.flags[InviteOnly] && !channel.ClientIsOperator(inviter) {
|
|
|
|
inviter.ErrChanOPrivIsNeeded(channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !channel.members.Has(inviter) {
|
|
|
|
inviter.ErrNotOnChannel(channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO Modify channel masks
|
|
|
|
inviter.RplInviting(invitee, channel.name)
|
|
|
|
invitee.Reply(RplInviteMsg(inviter, channel.name))
|
|
|
|
if invitee.flags[Away] {
|
|
|
|
inviter.RplAway(invitee)
|
|
|
|
}
|
|
|
|
}
|