Skip to content

Commit

Permalink
feat:加大bot存在感
Browse files Browse the repository at this point in the history
  • Loading branch information
ivhu committed Dec 8, 2024
1 parent 0e58564 commit 7eb0bd7
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions handler/quotation_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
= []string{"骂她", "骂他", "骂它", "咬他", "咬她", "咬ta", "咬它"}
= []string{"舔", "tian"}
神经病 = []string{"有病", "神经"}
cp = []string{"爱你", "mua", "宝", "摸摸", "抱抱", "亲亲", "贴贴","rua"}
cp = []string{"爱你", "mua", "宝", "摸摸", "抱抱", "亲亲", "贴贴","rua"}
)

var quotationsKey = map[string]string{
Expand Down Expand Up @@ -107,6 +107,19 @@ func (y *quotationsHandler) CheckUpdate(b *gotgbot.Bot, ctx *ext.Context) bool {
if crossR {
return getRandomProbability(0.75)
}
for key, _ := range quotationsKey {
if strings.HasPrefix(msg, key) {
return getRandomProbability(0.5)
}
}
if ctx.Message.ReplyToMessage == nil {
ctx.EffectiveMessage.ReplyToMessage = new(gotgbot.Message)
if ctx.Message.Sticker != nil {
return getRandomProbability(0.3)
} else {
return getRandomProbability(0.1)
}
}
return false
}

Expand Down Expand Up @@ -182,18 +195,19 @@ func getRandomProbability(p float64) bool {
}

func changeText(ctx *ext.Context) {
if ctx.Message.ReplyToMessage == nil {
// 如果是贴纸 则概率为 0.3 * 0.3 ,第一个0.3在update里面
if ctx.Message.ReplyToMessage == nil { // 前提是msg是空
ctx.EffectiveMessage.ReplyToMessage = new(gotgbot.Message)
if ctx.Message.Sticker != nil {
if getRandomProbability(0.5) {
if getRandomProbability(0.3) {
ctx.EffectiveMessage.ReplyToMessage.From = ctx.EffectiveUser
ctx.EffectiveMessage.Text = "神经"
} else {
ctx.EffectiveMessage.ReplyToMessage.From = ctx.EffectiveUser
ctx.EffectiveMessage.Text = "t"
}
} else {
if getRandomProbability(0.5) {
if getRandomProbability(0.1) {
ctx.EffectiveMessage.ReplyToMessage.From = ctx.EffectiveUser
ctx.EffectiveMessage.Text = "神经"
} else {
Expand Down Expand Up @@ -237,11 +251,10 @@ func changeText(ctx *ext.Context) {
} else {
ctx.EffectiveMessage.Text = "t"
}
} else {
if getRandomProbability(0.5) {
ctx.EffectiveMessage.Text = "神经"
} else {
ctx.EffectiveMessage.Text = "t"
}
for key, value := range quotationsKey {
if strings.HasPrefix(msg, key) {
ctx.EffectiveMessage.Text = value
}
}
}

0 comments on commit 7eb0bd7

Please sign in to comment.