@@ -96,7 +96,6 @@ func (y *quotationsHandler) CheckUpdate(b *gotgbot.Bot, ctx *ext.Context) bool {
96
96
// 如果是关键词 直接触发
97
97
for _ , i := range 骂 {
98
98
if strings .Contains (msg , i ) {
99
- crossR = true
100
99
return true
101
100
}
102
101
}
@@ -108,7 +107,7 @@ func (y *quotationsHandler) CheckUpdate(b *gotgbot.Bot, ctx *ext.Context) bool {
108
107
return getRandomProbability (0.75 )
109
108
}
110
109
for key := range quotationsKey {
111
- if strings .HasPrefix (msg , key ) {
110
+ if strings .HasPrefix (msg , key ) && len ( msg ) >= 21 {
112
111
return getRandomProbability (0.5 )
113
112
}
114
113
}
@@ -130,16 +129,19 @@ func (y *quotationsHandler) HandleUpdate(b *gotgbot.Bot, ctx *ext.Context) error
130
129
if err != nil {
131
130
m = "s~b~"
132
131
} else {
133
- replyer := ctx .Message .ReplyToMessage .From .Username
134
- if replyer == "" {
135
- replyer = ctx .Message .ReplyToMessage .From .FirstName + " " + ctx .Message .ReplyToMessage .From .LastName
136
- } else {
137
- replyer = " @" + replyer + " "
132
+ var replyer string
133
+ if ctx .Message .ReplyToMessage != nil {
134
+ replyer = ctx .Message .ReplyToMessage .From .Username
135
+ if replyer == "" {
136
+ replyer = ctx .Message .ReplyToMessage .From .FirstName + " " + ctx .Message .ReplyToMessage .From .LastName
137
+ } else {
138
+ replyer = " @" + replyer + " "
139
+ }
138
140
}
139
141
if quotationsKey [ctx .EffectiveMessage .Text ] == anxiety {
140
142
m = strings .ReplaceAll (m , "<name>" , replyer )
141
143
}
142
- if quotationsKey [ctx .EffectiveMessage .Text ] == couple {
144
+ if quotationsKey [ctx .EffectiveMessage .Text ] == couple && ctx . Message . ReplyToMessage != nil {
143
145
if ctx .Message .From .Username == ctx .Message .ReplyToMessage .From .Username {
144
146
m = replyer + " " + " 单身狗,略略略"
145
147
} else {
@@ -154,9 +156,13 @@ func (y *quotationsHandler) HandleUpdate(b *gotgbot.Bot, ctx *ext.Context) error
154
156
}
155
157
}
156
158
}
159
+ var relayToid int64
160
+ if ctx .Message .ReplyToMessage != nil {
161
+ relayToid = ctx .Message .ReplyToMessage .MessageId
162
+ }
157
163
_ , err = b .SendMessage (ctx .Message .Chat .Id , m , & gotgbot.SendMessageOpts {
158
164
ReplyParameters : & gotgbot.ReplyParameters {
159
- MessageId : ctx . Message . ReplyToMessage . MessageId ,
165
+ MessageId : relayToid ,
160
166
ChatId : ctx .Message .Chat .Id ,
161
167
},
162
168
})
@@ -215,6 +221,9 @@ func changeText(ctx *ext.Context) {
215
221
ctx .EffectiveMessage .Text = "t"
216
222
}
217
223
}
224
+ if ctx .EffectiveMessage .Text == "" {
225
+ ctx .EffectiveMessage .Text = "神经"
226
+ }
218
227
}
219
228
// 如果是关键词 直接触发
220
229
msg := ctx .EffectiveMessage .Text
@@ -243,13 +252,14 @@ func changeText(ctx *ext.Context) {
243
252
}
244
253
}
245
254
if ctx .Message .Sticker != nil {
246
- if getRandomProbability (0.4 ) {
255
+ if getRandomProbability (0.4 ) || ctx . Message . ReplyToMessage != nil {
247
256
ctx .EffectiveMessage .Text = "mua"
248
257
} else if getRandomProbability (0.3 ) {
249
258
ctx .EffectiveMessage .Text = "神经"
250
259
} else {
251
260
ctx .EffectiveMessage .Text = "t"
252
261
}
262
+ return
253
263
}
254
264
for key , value := range quotationsKey {
255
265
if strings .HasPrefix (msg , key ) {
@@ -259,5 +269,4 @@ func changeText(ctx *ext.Context) {
259
269
if ctx .EffectiveMessage .Text == "" {
260
270
ctx .EffectiveMessage .Text = "神经"
261
271
}
262
-
263
272
}
0 commit comments