@@ -17,6 +17,16 @@ import (
1717 "github.com/wdvxdr1123/ZeroBot/message"
1818)
1919
20+ var re = regexp .MustCompile (`^\[(.*?)\](.*)\..*$` )
21+
22+ func card2name (card string ) (string , string ) {
23+ match := re .FindStringSubmatch (card )
24+ if len (match ) >= 3 {
25+ return match [1 ], match [2 ]
26+ }
27+ return "" , ""
28+ }
29+
2030func init () {
2131 engine := control .AutoRegister (& ctrl.Options [* zero.Ctx ]{
2232 DisableOnDefault : false ,
@@ -46,22 +56,20 @@ func init() {
4656 card := cards [fcext .RandSenderPerDayN (ctx .Event .UserID , len (cards ))]
4757 data , err := engine .GetLazyData ("wives/" + card , true )
4858 card , _ , _ = strings .Cut (card , "." )
59+ var msgText string
60+ work , name := card2name (card )
61+ if work != "" && name != "" {
62+ msgText = fmt .Sprintf ("今天的二次元老婆是~来自【%s】的【%s】哒" , work , name )
63+ } else {
64+ msgText = fmt .Sprintf ("今天的二次元老婆是~【%s】哒" , card )
65+ }
4966 if err != nil {
5067 ctx .SendChain (
5168 message .At (ctx .Event .UserID ),
52- message .Text ("今天的二次元老婆是~【" , card , "】哒 \n 【图片下载失败: " , err , "】" ),
69+ message .Text (msgText , " \n 【图片下载失败: " , err , "】" ),
5370 )
5471 return
5572 }
56- re := regexp .MustCompile (`^\[(.*?)\](.*)\..*$` )
57- match := re .FindStringSubmatch (card )
58- var msgText string
59- if len (match ) == 3 {
60- work , name := match [1 ], match [2 ]
61- msgText = fmt .Sprintf ("今天的二次元老婆是~来自【%s】的【%s】哒" , work , name )
62- } else {
63- msgText = fmt .Sprintf ("今天的二次元老婆是~【%s】哒" , card )
64- }
6573 if id := ctx .SendChain (
6674 message .At (ctx .Event .UserID ),
6775 message .Text (msgText ),
0 commit comments