2016-06-15 13:50:56 +02:00
|
|
|
// Copyright (c) 2012-2014 Jeremy Latt
|
|
|
|
// Copyright (c) 2014-2015 Edmund Huber
|
|
|
|
// released under the MIT license
|
|
|
|
|
2014-03-13 09:55:46 +01:00
|
|
|
package irc
|
|
|
|
|
|
|
|
type TheaterClient Name
|
|
|
|
|
|
|
|
func (c TheaterClient) Id() Name {
|
|
|
|
return Name(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c TheaterClient) Nick() Name {
|
|
|
|
return Name(c)
|
|
|
|
}
|
|
|
|
|
2016-06-19 02:01:30 +02:00
|
|
|
/*
|
2014-03-13 09:55:46 +01:00
|
|
|
func (m *TheaterIdentifyCommand) LoadPassword(s *Server) {
|
|
|
|
m.hash = s.theaters[m.channel]
|
|
|
|
}
|
|
|
|
|
2016-06-28 08:24:28 +02:00
|
|
|
if upperSubCmd := strings.ToUpper(args[0]); upperSubCmd == "IDENTIFY" && len(args) == 3 {
|
|
|
|
return &TheaterIdentifyCommand{
|
|
|
|
channel: NewName(args[1]),
|
|
|
|
PassCommand: PassCommand{password: []byte(args[2])},
|
|
|
|
}, nil
|
|
|
|
} else if upperSubCmd == "PRIVMSG" && len(args) == 4 {
|
|
|
|
return &TheaterPrivMsgCommand{
|
|
|
|
channel: NewName(args[1]),
|
|
|
|
asNick: NewName(args[2]),
|
|
|
|
message: NewText(args[3]),
|
|
|
|
}, nil
|
|
|
|
} else if upperSubCmd == "ACTION" && len(args) == 4 {
|
|
|
|
return &TheaterActionCommand{
|
|
|
|
channel: NewName(args[1]),
|
|
|
|
asNick: NewName(args[2]),
|
|
|
|
action: NewCTCPText(args[3]),
|
|
|
|
}, nil
|
|
|
|
} else {
|
|
|
|
return nil, ErrParseCommand
|
|
|
|
}
|
2014-03-13 09:55:46 +01:00
|
|
|
func (m *TheaterIdentifyCommand) HandleServer(s *Server) {
|
|
|
|
client := m.Client()
|
|
|
|
if !m.channel.IsChannel() {
|
|
|
|
client.ErrNoSuchChannel(m.channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
channel := s.channels.Get(m.channel)
|
|
|
|
if channel == nil {
|
|
|
|
client.ErrNoSuchChannel(m.channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m.hash == nil) || (m.err != nil) {
|
|
|
|
client.ErrPasswdMismatch()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-03-23 06:47:21 +01:00
|
|
|
if channel.members.AnyHasMode(Theater) {
|
|
|
|
client.Reply(RplNotice(s, client, "someone else is +T in this channel"))
|
|
|
|
return
|
2014-03-13 09:55:46 +01:00
|
|
|
}
|
2014-03-23 06:47:21 +01:00
|
|
|
|
|
|
|
channel.members[client][Theater] = true
|
2014-03-13 09:55:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type TheaterPrivMsgCommand struct {
|
|
|
|
BaseCommand
|
|
|
|
channel Name
|
|
|
|
asNick Name
|
|
|
|
message Text
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *TheaterPrivMsgCommand) HandleServer(s *Server) {
|
|
|
|
client := m.Client()
|
2014-03-23 06:47:21 +01:00
|
|
|
|
2014-03-13 09:55:46 +01:00
|
|
|
if !m.channel.IsChannel() {
|
|
|
|
client.ErrNoSuchChannel(m.channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
channel := s.channels.Get(m.channel)
|
|
|
|
if channel == nil {
|
|
|
|
client.ErrNoSuchChannel(m.channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-03-23 06:47:21 +01:00
|
|
|
if !channel.members.HasMode(client, Theater) {
|
|
|
|
client.Reply(RplNotice(s, client, "you are not +T"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-03-28 03:04:34 +01:00
|
|
|
reply := RplPrivMsg(TheaterClient(m.asNick), channel, m.message)
|
2014-03-23 06:47:21 +01:00
|
|
|
for member := range channel.members {
|
2014-03-28 03:04:34 +01:00
|
|
|
member.Reply(reply)
|
2014-03-13 09:55:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type TheaterActionCommand struct {
|
|
|
|
BaseCommand
|
|
|
|
channel Name
|
|
|
|
asNick Name
|
2014-03-23 06:47:21 +01:00
|
|
|
action CTCPText
|
2014-03-13 09:55:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *TheaterActionCommand) HandleServer(s *Server) {
|
|
|
|
client := m.Client()
|
2014-03-23 06:47:21 +01:00
|
|
|
|
|
|
|
if !m.channel.IsChannel() {
|
2014-03-13 09:55:46 +01:00
|
|
|
client.ErrNoSuchChannel(m.channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
channel := s.channels.Get(m.channel)
|
|
|
|
if channel == nil {
|
|
|
|
client.ErrNoSuchChannel(m.channel)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-03-23 06:47:21 +01:00
|
|
|
if !channel.members.HasMode(client, Theater) {
|
|
|
|
client.Reply(RplNotice(s, client, "you are not +T"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-03-28 03:04:34 +01:00
|
|
|
reply := RplCTCPAction(TheaterClient(m.asNick), channel, m.action)
|
2014-03-23 06:47:21 +01:00
|
|
|
for member := range channel.members {
|
2014-03-28 03:04:34 +01:00
|
|
|
member.Reply(reply)
|
2014-03-13 09:55:46 +01:00
|
|
|
}
|
|
|
|
}
|
2016-06-19 02:01:30 +02:00
|
|
|
*/
|