mirror of
https://github.com/ergochat/ergo.git
synced 2025-01-03 16:42:38 +01:00
add error responses for mode command
This commit is contained in:
parent
1283bd35c7
commit
21337cda7f
@ -224,7 +224,7 @@ func (channel *Channel) Mode(client *Client, changes ChannelModeChanges) {
|
|||||||
switch change.op {
|
switch change.op {
|
||||||
case Add:
|
case Add:
|
||||||
if change.arg == "" {
|
if change.arg == "" {
|
||||||
// TODO err reply
|
client.ErrNeedMoreParams("MODE")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,18 +243,18 @@ func (channel *Channel) Mode(client *Client, changes ChannelModeChanges) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if change.arg == "" {
|
if change.arg == "" {
|
||||||
// TODO err reply
|
client.ErrNeedMoreParams("MODE")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
target := channel.server.clients.Get(change.arg)
|
target := channel.server.clients.Get(change.arg)
|
||||||
if target == nil {
|
if target == nil {
|
||||||
// TODO err reply
|
client.ErrNoSuchNick(change.arg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if channel.members[target] == nil {
|
if !channel.members.Has(target) {
|
||||||
// TODO err reply
|
client.ErrUserNotInChannel(channel, target)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,6 +267,9 @@ func (channel *Channel) Mode(client *Client, changes ChannelModeChanges) {
|
|||||||
channel.members[target][change.mode] = false
|
channel.members[target][change.mode] = false
|
||||||
applied = append(applied, change)
|
applied = append(applied, change)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
client.ErrUnknownMode(change.mode, channel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
irc/reply.go
21
irc/reply.go
@ -10,18 +10,28 @@ func NewStringReply(source Identifier, code StringCode,
|
|||||||
format string, args ...interface{}) string {
|
format string, args ...interface{}) string {
|
||||||
var header string
|
var header string
|
||||||
if source == nil {
|
if source == nil {
|
||||||
header = fmt.Sprintf("%s ", code)
|
header = code.String() + " "
|
||||||
} else {
|
} else {
|
||||||
header = fmt.Sprintf(":%s %s ", source, code)
|
header = fmt.Sprintf(":%s %s ", source, code)
|
||||||
}
|
}
|
||||||
message := fmt.Sprintf(format, args...)
|
var message string
|
||||||
|
if len(args) > 0 {
|
||||||
|
message = fmt.Sprintf(format, args...)
|
||||||
|
} else {
|
||||||
|
message = format
|
||||||
|
}
|
||||||
return header + message
|
return header + message
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNumericReply(target *Client, code NumericCode,
|
func NewNumericReply(target *Client, code NumericCode,
|
||||||
format string, args ...interface{}) string {
|
format string, args ...interface{}) string {
|
||||||
header := fmt.Sprintf(":%s %s %s ", target.server.Id(), code, target.Nick())
|
header := fmt.Sprintf(":%s %s %s ", target.server.Id(), code, target.Nick())
|
||||||
message := fmt.Sprintf(format, args...)
|
var message string
|
||||||
|
if len(args) > 0 {
|
||||||
|
message = fmt.Sprintf(format, args...)
|
||||||
|
} else {
|
||||||
|
message = format
|
||||||
|
}
|
||||||
return header + message
|
return header + message
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,3 +416,8 @@ func (target *Client) ErrErroneusNickname(nick string) {
|
|||||||
target.NumericReply(ERR_ERRONEUSNICKNAME,
|
target.NumericReply(ERR_ERRONEUSNICKNAME,
|
||||||
"%s :Erroneous nickname", nick)
|
"%s :Erroneous nickname", nick)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (target *Client) ErrUnknownMode(mode ChannelMode, channel *Channel) {
|
||||||
|
target.NumericReply(ERR_UNKNOWNMODE,
|
||||||
|
"%s :is unknown mode char to me for %s", mode, channel)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user