1
- // Package qqwife 娶群友 基于“翻牌”和江林大佬的“群老婆”插件魔改作品
1
+ // Package qqwife 娶群友 基于“翻牌”和江林大佬的“群老婆”插件魔改作品
2
2
package qqwife
3
3
4
4
import (
@@ -21,13 +21,25 @@ var (
21
21
qqwifegroup = make (map [int64 ]map [int64 ]int64 , 64 ) // 64个群的预算大小
22
22
lastdate time.Time
23
23
mu sync.Mutex
24
+ sendtext = [... ][]string {
25
+ {
26
+ "今天你向ta表白了,ta羞涩的点了点头同意了!\n " ,
27
+ "你对ta说“以我之名,冠你指间,一天相伴,一天相随”.ta捂着嘴点了点头\n \n " ,
28
+ },
29
+ {
30
+ "今天你向ta表白了,ta毫无感情的拒绝了你\n " ,
31
+ "今天你向ta表白了,ta对你说“你是一个非常好的人”\n " ,
32
+ "今天你向ta表白了,ta给了你一个拥抱后擦肩而过\n " ,
33
+ },
34
+ }
24
35
)
25
36
26
37
func init () {
27
38
engine := control .Register ("qqwife" , & control.Options {
28
39
DisableOnDefault : false ,
29
40
Help : "一群一天一夫一妻制群老婆\n " +
30
41
"- 娶群友\n " +
42
+ "- 娶[老婆QQ号|@老婆QQ]\n (注:单身专属技能,CD24H,不跨天刷新)\n " +
31
43
"- 群老婆列表" ,
32
44
})
33
45
engine .OnFullMatch ("娶群友" , zero .OnlyGroup ).SetBlock (true ).Limit (ctxext .LimitByUser ).
@@ -37,16 +49,20 @@ func init() {
37
49
if time .Now ().Day () != lastdate .Day () {
38
50
qqwifegroup = make (map [int64 ]map [int64 ]int64 , 64 ) // 跨天就重新初始化数据
39
51
}
40
- // 先判断是否已经娶过或者被娶
52
+ // 看列表是为为空
41
53
gid := ctx .Event .GroupID
54
+ if qqwifegroup [gid ] == nil {
55
+ qqwifegroup [gid ] = make (map [int64 ]int64 , 32 )
56
+ }
57
+ // 先判断是否已经娶过或者被娶
42
58
uid := ctx .Event .UserID
43
59
// 如果娶过
44
60
wife , ok := qqwifegroup [gid ][uid ]
45
61
if ok {
46
62
ctx .SendChain (
47
63
message .At (uid ),
48
64
message .Text ("今天你的群老婆是" ),
49
- message .Image ("http://q4.qlogo.cn/g?b=qq&nk=" + strconv .FormatInt (wife , 10 )+ "&s=640" ),
65
+ message .Image ("http://q4.qlogo.cn/g?b=qq&nk=" + strconv .FormatInt (wife , 10 )+ "&s=640" ). Add ( "cache" , 0 ) ,
50
66
message .Text (
51
67
"\n " ,
52
68
"[" , ctx .CardOrNickName (wife ), "]" ,
@@ -56,20 +72,19 @@ func init() {
56
72
return
57
73
}
58
74
// 如果被娶过
59
- for husband , wife := range qqwifegroup [gid ] {
60
- if wife == uid { // 如果为0且是在本群抽的就输出
61
- ctx .SendChain (
62
- message .At (uid ),
63
- message .Text ("今天你被娶了,群老公是" ),
64
- message .Image ("http://q4.qlogo.cn/g?b=qq&nk=" + strconv .FormatInt (husband , 10 )+ "&s=640" ),
65
- message .Text (
66
- "\n " ,
67
- "[" , ctx .CardOrNickName (husband ), "]" ,
68
- "(" , husband , ")哒" ,
69
- ),
70
- )
71
- return
72
- }
75
+ husband , ok := qqwifegroup [gid ][- uid ]
76
+ if ok {
77
+ ctx .SendChain (
78
+ message .At (uid ),
79
+ message .Text ("今天你被娶了,群老公是" ),
80
+ message .Image ("http://q4.qlogo.cn/g?b=qq&nk=" + strconv .FormatInt (husband , 10 )+ "&s=640" ).Add ("cache" , 0 ),
81
+ message .Text (
82
+ "\n " ,
83
+ "[" , ctx .CardOrNickName (husband ), "]" ,
84
+ "(" , husband , ")哒" ,
85
+ ),
86
+ )
87
+ return
73
88
}
74
89
// 无缓存获取群员列表
75
90
temp := ctx .GetThisGroupMemberListNoCache ().Array ()
@@ -86,9 +101,14 @@ func init() {
86
101
} else {
87
102
for k := 0 ; k < len (temp ); k ++ {
88
103
_ , ok := qqwifegroup [gid ][temp [k ].Get ("user_id" ).Int ()]
89
- if ! ok {
90
- qqgrouplist = append (qqgrouplist , temp [k ].Get ("user_id" ).Int ())
104
+ if ok {
105
+ continue
106
+ }
107
+ _ , ok = qqwifegroup [gid ][- temp [k ].Get ("user_id" ).Int ()]
108
+ if ok {
109
+ continue
91
110
}
111
+ qqgrouplist = append (qqgrouplist , temp [k ].Get ("user_id" ).Int ())
92
112
}
93
113
}
94
114
// 没有人(只剩自己)的时候
@@ -103,15 +123,13 @@ func init() {
103
123
return
104
124
}
105
125
// 绑定CP
106
- if qqwifegroup [gid ] == nil {
107
- qqwifegroup [gid ] = make (map [int64 ]int64 , 32 )
108
- }
109
126
qqwifegroup [gid ][uid ] = wife
127
+ qqwifegroup [gid ][- wife ] = uid
110
128
// 输出结果
111
129
ctx .SendChain (
112
130
message .At (uid ),
113
131
message .Text ("今天你的群老婆是" ),
114
- message .Image ("http://q4.qlogo.cn/g?b=qq&nk=" + strconv .FormatInt (wife , 10 )+ "&s=640" ),
132
+ message .Image ("http://q4.qlogo.cn/g?b=qq&nk=" + strconv .FormatInt (wife , 10 )+ "&s=640" ). Add ( "cache" , 0 ) ,
115
133
message .Text (
116
134
"\n " ,
117
135
"[" , ctx .CardOrNickName (wife ), "]" ,
@@ -121,6 +139,41 @@ func init() {
121
139
// 更新时间
122
140
lastdate = time .Now ()
123
141
})
142
+ //单生狗专属技能
143
+ var singledogCD = ctxext .NewLimiterManager (time .Hour * 24 , 1 )
144
+ engine .OnRegex (`^娶(\d+|\[CQ:at,qq=(\d+)\])` , zero .OnlyGroup , checkdog ).SetBlock (true ).Limit (singledogCD .LimitByUser ).
145
+ Handle (func (ctx * zero.Ctx ) {
146
+ mu .Lock ()
147
+ defer mu .Unlock ()
148
+ fiancee , err := strconv .ParseInt (ctx .State ["regex_matched" ].([]string )[1 ], 10 , 64 )
149
+ if err != nil {
150
+ fiancee , _ = strconv .ParseInt (ctx .State ["regex_matched" ].([]string )[2 ], 10 , 64 )
151
+ }
152
+ gid := ctx .Event .GroupID
153
+ uid := ctx .Event .UserID
154
+ if rand .Intn (2 ) == 1 {
155
+ // 绑定CP
156
+ if qqwifegroup [gid ] == nil {
157
+ qqwifegroup [gid ] = make (map [int64 ]int64 , 32 )
158
+ }
159
+ qqwifegroup [gid ][uid ] = fiancee
160
+ qqwifegroup [gid ][- fiancee ] = uid
161
+ // 输出结果
162
+ ctx .SendChain (
163
+ message .Text (sendtext [0 ][rand .Intn (len (sendtext [0 ]))]),
164
+ message .At (uid ),
165
+ message .Text ("今天你的群老婆是" ),
166
+ message .Image ("http://q4.qlogo.cn/g?b=qq&nk=" + strconv .FormatInt (fiancee , 10 )+ "&s=640" ).Add ("cache" , 0 ),
167
+ message .Text (
168
+ "\n " ,
169
+ "[" , ctx .CardOrNickName (fiancee ), "]" ,
170
+ "(" , fiancee , ")哒" ,
171
+ ),
172
+ )
173
+ } else {
174
+ ctx .SendChain (message .Text (sendtext [1 ][rand .Intn (len (sendtext [1 ]))]))
175
+ }
176
+ })
124
177
engine .OnFullMatch ("群老婆列表" , zero .OnlyGroup ).SetBlock (true ).Limit (ctxext .LimitByUser ).
125
178
Handle (func (ctx * zero.Ctx ) {
126
179
mu .Lock ()
@@ -135,10 +188,73 @@ func init() {
135
188
return
136
189
}
137
190
cplist := make ([]string , 1 , len (group )+ 1 )
138
- cplist [0 ] = "群老公←———→群老婆\n -------------------------- "
191
+ cplist [0 ] = "群老公←———→群老婆\n ----------------------"
139
192
for husband , wife := range group {
140
- cplist = append (cplist , ctx .CardOrNickName (husband )+ " & " + ctx .CardOrNickName (wife ))
193
+ if husband > 0 {
194
+ cplist = append (cplist , ctx .CardOrNickName (husband )+ " & " + ctx .CardOrNickName (wife ))
195
+ }
141
196
}
142
197
ctx .SendChain (message .Text (strings .Join (cplist , "\n " )))
143
198
})
144
199
}
200
+
201
+ //注入判断 是否为单身狗
202
+ func checkdog (ctx * zero.Ctx ) bool {
203
+ fiancee , err := strconv .ParseInt (ctx .State ["regex_matched" ].([]string )[1 ], 10 , 64 )
204
+ //fmt.Println("1:", fiancee)
205
+ if err != nil {
206
+ fiancee , _ = strconv .ParseInt (ctx .State ["regex_matched" ].([]string )[2 ], 10 , 64 )
207
+ //fmt.Println("2:", fiancee)
208
+ }
209
+ gid := ctx .Event .GroupID
210
+ uid := ctx .Event .UserID
211
+ if uid == fiancee {
212
+ ctx .SendChain (message .Text ("今日获得成就:自恋狂" ))
213
+ return false
214
+ }
215
+ // 如果用户娶过
216
+ husband , ok := qqwifegroup [gid ][uid ]
217
+ if ok {
218
+ switch husband {
219
+ case fiancee :
220
+ ctx .SendChain (message .Text ("笨蛋~你明明已经娶了啊w" ))
221
+ default :
222
+ ctx .SendChain (message .Text ("笨蛋~你家里还有个吃白饭的w" ))
223
+ }
224
+ return false
225
+ }
226
+ // 如果用户被娶过
227
+ wife , ok := qqwifegroup [gid ][- uid ]
228
+ if ok {
229
+ switch wife {
230
+ case fiancee :
231
+ ctx .SendChain (message .Text ("笨蛋~你明明已经嫁给他了啊w" ))
232
+ default :
233
+ ctx .SendChain (message .Text ("该是0就是0,当0有什么不好" ))
234
+ }
235
+ return false
236
+ }
237
+ // 如果未婚妻娶过
238
+ wife , ok = qqwifegroup [gid ][fiancee ]
239
+ if ok {
240
+ switch wife {
241
+ case uid :
242
+ ctx .SendChain (message .Text ("笨蛋~你明明已经嫁给他了啊w" ))
243
+ default :
244
+ ctx .SendChain (message .Text ("他有别的女人了,你该放下了" ))
245
+ }
246
+ return false
247
+ }
248
+ // 如果未婚妻被娶过
249
+ husband , ok = qqwifegroup [gid ][- fiancee ]
250
+ if ok {
251
+ switch husband {
252
+ case uid :
253
+ ctx .SendChain (message .Text ("笨蛋~你明明已经娶了啊w" ))
254
+ default :
255
+ ctx .SendChain (message .Text ("这是一个纯爱的世界,拒绝NTR" ))
256
+ }
257
+ return false
258
+ }
259
+ return true
260
+ }
0 commit comments