add a type for CTCP-encoded strings, and NOTICEs for error cases

This commit is contained in:
Edmund Huber
2014-03-23 06:47:21 +01:00
parent 6267b6a40c
commit 34b01b115e
5 changed files with 38 additions and 14 deletions

View File

@@ -51,9 +51,12 @@ func (m *TheaterIdentifyCommand) HandleServer(s *Server) {
return
}
if !channel.members.AnyHasMode(Theater) {
channel.members[client][Theater] = true
if channel.members.AnyHasMode(Theater) {
client.Reply(RplNotice(s, client, "someone else is +T in this channel"))
return
}
channel.members[client][Theater] = true
}
type TheaterPrivMsgCommand struct {
@@ -69,6 +72,7 @@ func (cmd *TheaterPrivMsgCommand) String() string {
}
func (m *TheaterPrivMsgCommand) HandleServer(s *Server) {
client := m.Client()
if !m.channel.IsChannel() {
client.ErrNoSuchChannel(m.channel)
return
@@ -80,10 +84,13 @@ func (m *TheaterPrivMsgCommand) HandleServer(s *Server) {
return
}
if channel.members.HasMode(client, Theater) {
for member := range channel.members {
member.Reply(RplPrivMsg(TheaterClient(m.asNick), channel, m.message))
}
if !channel.members.HasMode(client, Theater) {
client.Reply(RplNotice(s, client, "you are not +T"))
return
}
for member := range channel.members {
member.Reply(RplPrivMsg(TheaterClient(m.asNick), channel, m.message))
}
}
@@ -91,7 +98,7 @@ type TheaterActionCommand struct {
BaseCommand
channel Name
asNick Name
action Text
action CTCPText
}
func (cmd *TheaterActionCommand) String() string {
@@ -100,7 +107,8 @@ func (cmd *TheaterActionCommand) String() string {
func (m *TheaterActionCommand) HandleServer(s *Server) {
client := m.Client()
if m.channel.IsChannel() {
if !m.channel.IsChannel() {
client.ErrNoSuchChannel(m.channel)
return
}
@@ -111,9 +119,12 @@ func (m *TheaterActionCommand) HandleServer(s *Server) {
return
}
if channel.members.HasMode(client, Theater) {
for member := range channel.members {
member.Reply(RplPrivMsg(TheaterClient(m.asNick), channel, NewText(fmt.Sprintf("\001ACTION %s\001", m.action))))
}
if !channel.members.HasMode(client, Theater) {
client.Reply(RplNotice(s, client, "you are not +T"))
return
}
for member := range channel.members {
member.Reply(RplCTCPAction(TheaterClient(m.asNick), channel, m.action))
}
}