1- // Package qqwife 娶群友 基于“翻牌”和江林大佬的“群老婆”插件魔改作品
1+ // Package qqwife 娶群友 基于“翻牌”和江林大佬的“群老婆”插件魔改作品
22package qqwife
33
44import (
@@ -21,13 +21,25 @@ var (
2121 qqwifegroup = make (map [int64 ]map [int64 ]int64 , 64 ) // 64个群的预算大小
2222 lastdate time.Time
2323 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+ }
2435)
2536
2637func init () {
2738 engine := control .Register ("qqwife" , & control.Options {
2839 DisableOnDefault : false ,
2940 Help : "一群一天一夫一妻制群老婆\n " +
3041 "- 娶群友\n " +
42+ "- 娶[老婆QQ号|@老婆QQ]\n (注:单身专属技能,CD24H,不跨天刷新)\n " +
3143 "- 群老婆列表" ,
3244 })
3345 engine .OnFullMatch ("娶群友" , zero .OnlyGroup ).SetBlock (true ).Limit (ctxext .LimitByUser ).
@@ -37,16 +49,20 @@ func init() {
3749 if time .Now ().Day () != lastdate .Day () {
3850 qqwifegroup = make (map [int64 ]map [int64 ]int64 , 64 ) // 跨天就重新初始化数据
3951 }
40- // 先判断是否已经娶过或者被娶
52+ // 看列表是为为空
4153 gid := ctx .Event .GroupID
54+ if qqwifegroup [gid ] == nil {
55+ qqwifegroup [gid ] = make (map [int64 ]int64 , 32 )
56+ }
57+ // 先判断是否已经娶过或者被娶
4258 uid := ctx .Event .UserID
4359 // 如果娶过
4460 wife , ok := qqwifegroup [gid ][uid ]
4561 if ok {
4662 ctx .SendChain (
4763 message .At (uid ),
4864 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 ) ,
5066 message .Text (
5167 "\n " ,
5268 "[" , ctx .CardOrNickName (wife ), "]" ,
@@ -56,20 +72,19 @@ func init() {
5672 return
5773 }
5874 // 如果被娶过
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
7388 }
7489 // 无缓存获取群员列表
7590 temp := ctx .GetThisGroupMemberListNoCache ().Array ()
@@ -86,9 +101,14 @@ func init() {
86101 } else {
87102 for k := 0 ; k < len (temp ); k ++ {
88103 _ , 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
91110 }
111+ qqgrouplist = append (qqgrouplist , temp [k ].Get ("user_id" ).Int ())
92112 }
93113 }
94114 // 没有人(只剩自己)的时候
@@ -103,15 +123,13 @@ func init() {
103123 return
104124 }
105125 // 绑定CP
106- if qqwifegroup [gid ] == nil {
107- qqwifegroup [gid ] = make (map [int64 ]int64 , 32 )
108- }
109126 qqwifegroup [gid ][uid ] = wife
127+ qqwifegroup [gid ][- wife ] = uid
110128 // 输出结果
111129 ctx .SendChain (
112130 message .At (uid ),
113131 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 ) ,
115133 message .Text (
116134 "\n " ,
117135 "[" , ctx .CardOrNickName (wife ), "]" ,
@@ -121,6 +139,41 @@ func init() {
121139 // 更新时间
122140 lastdate = time .Now ()
123141 })
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+ })
124177 engine .OnFullMatch ("群老婆列表" , zero .OnlyGroup ).SetBlock (true ).Limit (ctxext .LimitByUser ).
125178 Handle (func (ctx * zero.Ctx ) {
126179 mu .Lock ()
@@ -135,10 +188,73 @@ func init() {
135188 return
136189 }
137190 cplist := make ([]string , 1 , len (group )+ 1 )
138- cplist [0 ] = "群老公←———→群老婆\n -------------------------- "
191+ cplist [0 ] = "群老公←———→群老婆\n ----------------------"
139192 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+ }
141196 }
142197 ctx .SendChain (message .Text (strings .Join (cplist , "\n " )))
143198 })
144199}
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