2025-01-22 17:26:32 +08:00
|
|
|
package torf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/rand"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
tele "gopkg.in/telebot.v3"
|
|
|
|
)
|
|
|
|
|
2025-01-24 16:17:44 +08:00
|
|
|
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 {
|
2025-01-24 16:17:44 +08:00
|
|
|
return responses[r.Intn(len(responses))]
|
2025-01-22 17:26:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2025-01-24 16:17:44 +08:00
|
|
|
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, "有没有") {
|
2025-01-24 16:17:44 +08:00
|
|
|
outputText = randResponse(1, r)
|
2025-01-22 17:26:32 +08:00
|
|
|
} else if strings.Contains(inputText, "好不好") {
|
2025-01-24 16:17:44 +08:00
|
|
|
outputText = randResponse(2, r)
|
2025-01-22 17:26:32 +08:00
|
|
|
} else if strings.Contains(inputText, "是不是") {
|
2025-01-24 16:17:44 +08:00
|
|
|
outputText = randResponse(3, r)
|
2025-01-22 17:26:32 +08:00
|
|
|
} else if strings.Contains(inputText, "尊嘟假嘟") {
|
2025-01-24 16:17:44 +08:00
|
|
|
outputText = randResponse(4, r)
|
2025-01-22 17:26:32 +08:00
|
|
|
} else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.Reply(outputText)
|
|
|
|
}
|