lucky-tgbot/plugin/torf/main.go

43 lines
894 B
Go
Raw Permalink Normal View History

2025-01-22 17:26:32 +08:00
package torf
import (
"math/rand"
"strings"
tele "gopkg.in/telebot.v3"
)
func randResponse(saidType int, r *rand.Rand) string {
2025-01-22 17:26:32 +08:00
responsesMap := map[int][]string{
1: {"有", "没有"},
2: {"好", "不好"},
3: {"是", "不是"},
4: {"尊嘟", "假嘟"},
}
if responses, exists := responsesMap[saidType]; exists {
return responses[r.Intn(len(responses))]
2025-01-22 17:26:32 +08:00
}
return ""
}
func Execute(c tele.Context, r *rand.Rand) error {
2025-01-22 17:26:32 +08:00
inputText := c.Text()
var outputText string
if strings.Contains(inputText, "有没有") {
outputText = randResponse(1, r)
2025-01-22 17:26:32 +08:00
} else if strings.Contains(inputText, "好不好") {
outputText = randResponse(2, r)
2025-01-22 17:26:32 +08:00
} else if strings.Contains(inputText, "是不是") {
outputText = randResponse(3, r)
2025-01-22 17:26:32 +08:00
} else if strings.Contains(inputText, "尊嘟假嘟") {
outputText = randResponse(4, r)
2025-01-22 17:26:32 +08:00
} else {
return nil
}
return c.Reply(outputText)
}