1
0
mirror of https://github.com/fumiama/ReiBot.git synced 2026-06-08 03:55:12 +08:00

fix cd cmdrules istome

This commit is contained in:
源文雨
2022-10-05 00:08:49 +08:00
parent 254271db0f
commit cd96452cea
3 changed files with 13 additions and 22 deletions

View File

@@ -66,25 +66,12 @@ func CommandRule(commands ...string) Rule {
cmdMessage := ""
args := ""
switch {
case msg.IsCommand():
case ctx.IsToMe && msg.IsCommand():
cmdMessage = msg.Command()
args = msg.CommandArguments()
case strings.HasPrefix(msg.Text, "/"):
a := strings.Index(msg.Text, "@")
b := strings.Index(msg.Text, " ")
if a > 0 && !strings.HasPrefix(msg.Text[a:], "@"+ctx.Caller.Self.String()) {
return false
}
switch {
case b <= 1:
return false
case a < 0 || a >= b:
cmdMessage = msg.Text[1:b]
args = msg.Text[b+1:]
default:
cmdMessage = msg.Text[1:a]
args = msg.Text[b+1:]
}
cmdMessage, args, _ = strings.Cut(msg.Text, " ")
cmdMessage, _, _ = strings.Cut(cmdMessage, "@")
default:
return false
}