mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
fix up MODE behavior to allow /mode <not-your-nick> and show per-channel modes, fixes #29
This commit is contained in:
parent
37e15d7f62
commit
e1c235a9ea
@ -145,10 +145,12 @@ func (m *ModeCommand) HandleServer(s *Server) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Who should get these replies?
|
|
||||||
if len(changes) > 0 {
|
if len(changes) > 0 {
|
||||||
client.Reply(RplMode(client, target, changes))
|
client.Reply(RplModeChanges(client, target, changes))
|
||||||
|
} else if client == target {
|
||||||
|
client.RplUModeIs(client)
|
||||||
}
|
}
|
||||||
|
client.Reply(RplCurrentMode(client, target))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msg *ChannelModeCommand) HandleServer(server *Server) {
|
func (msg *ChannelModeCommand) HandleServer(server *Server) {
|
||||||
|
17
irc/reply.go
17
irc/reply.go
@ -119,10 +119,25 @@ func RplPart(client *Client, channel *Channel, message Text) string {
|
|||||||
return NewStringReply(client, PART, "%s :%s", channel, message)
|
return NewStringReply(client, PART, "%s :%s", channel, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RplMode(client *Client, target *Client, changes ModeChanges) string {
|
func RplModeChanges(client *Client, target *Client, changes ModeChanges) string {
|
||||||
return NewStringReply(client, MODE, "%s :%s", target.Nick(), changes)
|
return NewStringReply(client, MODE, "%s :%s", target.Nick(), changes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RplCurrentMode(client *Client, target *Client) string {
|
||||||
|
globalFlags := ""
|
||||||
|
for mode, _ := range target.flags {
|
||||||
|
globalFlags += mode.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
perChannelFlags := ""
|
||||||
|
for channel, _ := range target.channels {
|
||||||
|
perChannelFlags += fmt.Sprintf(" %s:%s", channel.name, channel.members[target])
|
||||||
|
}
|
||||||
|
|
||||||
|
response := fmt.Sprintf("All user modes: %s%s", globalFlags, perChannelFlags)
|
||||||
|
return NewStringReply(client, NOTICE, "%s :%s", target.Nick(), response)
|
||||||
|
}
|
||||||
|
|
||||||
func RplChannelMode(client *Client, channel *Channel,
|
func RplChannelMode(client *Client, channel *Channel,
|
||||||
changes ChannelModeChanges) string {
|
changes ChannelModeChanges) string {
|
||||||
return NewStringReply(client, MODE, "%s %s", channel, changes)
|
return NewStringReply(client, MODE, "%s %s", channel, changes)
|
||||||
|
Loading…
Reference in New Issue
Block a user