@@ -24,33 +24,52 @@ func init() {
2424 "- 卖萌[@xxx]\n " +
2525 "- 抽老婆[@xxx]" ,
2626 })
27- engine .OnPrefix ("异世界转生" , number (587874 )).SetBlock (true ).Limit (ctxext .LimitByUser ).Handle (handle )
28- engine .OnPrefix ("今天是什么少女" , number (162207 )).SetBlock (true ).Limit (ctxext .LimitByUser ).Handle (handle )
29- engine .OnPrefix ("卖萌" , number (360578 )).SetBlock (true ).Limit (ctxext .LimitByUser ).Handle (handle )
30- engine .OnPrefix ("抽老婆" , number (1075116 )).SetBlock (true ).Limit (ctxext .LimitByUser ).Handle (handle )
27+ engine .OnPrefix ("异世界转生" , number (587874 )).SetBlock (true ).Limit (ctxext .LimitByUser ).Handle (handlepic )
28+ engine .OnPrefix ("今天是什么少女" , number (162207 )).SetBlock (true ).Limit (ctxext .LimitByUser ).Handle (handlepic )
29+ engine .OnPrefix ("卖萌" , number (360578 )).SetBlock (true ).Limit (ctxext .LimitByUser ).Handle (handletxt )
30+ engine .OnPrefix ("抽老婆" , number (1075116 )).SetBlock (true ).Limit (ctxext .LimitByUser ).Handle (handlecq )
31+ engine .OnPrefix ("黄油角色" , number (1115465 )).SetBlock (true ).Limit (ctxext .LimitByUser ).Handle (handlepic )
3132}
3233
33- // shindanmaker 处理函数
34- func handle (ctx * zero.Ctx ) {
34+ func handletxt (ctx * zero.Ctx ) {
3535 // 获取名字
3636 name := ctx .NickName ()
3737 // 调用接口
3838 txt , err := shindanmaker .Shindanmaker (ctx .State ["id" ].(int64 ), name )
3939 if err != nil {
40- ctx .SendChain (message .Text ("ERROR: " , err ))
40+ ctx .SendChain (message .Text ("ERROR:" , err ))
41+ return
4142 }
42- // TODO: 可注入
43- switch ctx .State ["id" ].(int64 ) {
44- case 587874 , 162207 :
45- data , err := text .RenderToBase64 (txt , text .FontFile , 400 , 20 )
46- if err != nil {
47- log .Errorln ("[shindan]:" , err )
48- }
49- if id := ctx .SendChain (message .Image ("base64://" + helper .BytesToString (data ))); id .ID () == 0 {
50- ctx .SendChain (message .Text ("ERROR: 可能被风控了" ))
51- }
52- default :
53- ctx .Send (txt )
43+ ctx .SendChain (message .Text (txt ))
44+ }
45+
46+ func handlecq (ctx * zero.Ctx ) {
47+ // 获取名字
48+ name := ctx .NickName ()
49+ // 调用接口
50+ txt , err := shindanmaker .Shindanmaker (ctx .State ["id" ].(int64 ), name )
51+ if err != nil {
52+ ctx .SendChain (message .Text ("ERROR:" , err ))
53+ return
54+ }
55+ ctx .Send (txt )
56+ }
57+
58+ func handlepic (ctx * zero.Ctx ) {
59+ // 获取名字
60+ name := ctx .NickName ()
61+ // 调用接口
62+ txt , err := shindanmaker .Shindanmaker (ctx .State ["id" ].(int64 ), name )
63+ if err != nil {
64+ ctx .SendChain (message .Text ("ERROR:" , err ))
65+ return
66+ }
67+ data , err := text .RenderToBase64 (txt , text .FontFile , 400 , 20 )
68+ if err != nil {
69+ log .Errorln ("[shindan]:" , err )
70+ }
71+ if id := ctx .SendChain (message .Image ("base64://" + helper .BytesToString (data ))); id .ID () == 0 {
72+ ctx .SendChain (message .Text ("ERROR: 可能被风控了" ))
5473 }
5574}
5675
0 commit comments