public object SendPasswordRedPacket(
            [KouPluginArgument(Name = "总金额", NumberMin = 1, DefaultNumberRangeError = true)] int total,
            [KouPluginArgument(Name = "数量", NumberMin = 1, DefaultNumberRangeError = true)] int quantity,
            [KouPluginArgument(Name = "口令(默认生成6位数字)")] string password = null)
        {
            if (password == "")
            {
                password = null;
            }
            if (!ValidateAvailableTime())
            {
                return(ConveyMessage);
            }
            KouRedPacket redPacket = new KouRedPacket(CurrentPlatformUser, total, quantity, IsIdentical, password, Duration)
            {
                EndAction           = RedPacketEndAction,
                IsCompeteInVelocity = IsCompeteInVelocity,
                Remark = Remark
            };

            if (redPacket.TotalCoins / redPacket.TotalCount == 0)
            {
                return($"每人至少需要有{CurrentGlobalKouConfig.CoinFormat(1)}");
            }
            var rest = CurrentUser.CoinFree - redPacket.TotalCoins;

            if (rest >= 0)
            {
                string ask =
                    $"发送总额为{CurrentGlobalKouConfig.CoinFormat(redPacket.TotalCoins)}的{quantity}个{IsCompeteInVelocity.BeIfTrue("竞速")}红包{password?.Be($"(口令为\"{password}\")")}" +
                    $"(成功后余额为{CurrentGlobalKouConfig.CoinFormat(rest)})\n" +
                    $"输入\"y\"确认";
                if (!SessionService.AskConfirm(ask))
                {
                    return(null);
                }
                if (IsCompeteInVelocity)
                {
                    CurrentPlatformUser.SendMessage(CurrentPlatformGroup, "将随机在5~30秒内发送竞速红包");
                    Thread.Sleep(RandomTool.GenerateRandomInt(5000, 30000));
                }
                if (!redPacket.Sent())
                {
                    return("发红包失败" + redPacket.ErrorMsg?.Be($",{redPacket.ErrorMsg}"));
                }

                return($"发送红包成功!{redPacket.ToString(FormatType.Customize1)}");
            }

            return(this.ReturnNullWithError(null, ErrorCodes.Core_BankNotEnoughMoney));
        }
        private void RedPacketEndAction(KouRedPacket r)
        {
            string reply;
            int    exp = r.TotalCoins - r.RemainCoins - r.FromUserGet;

            r.FromUser.KouUser.GainExp(exp);
            if (r.RemainCount == 0)
            {
                reply = $"{CurrentPlatformUser.Name}的红包抢完啦!\n[{CurrentPlatformUser.Name}获得了{exp}点经验]";
            }
            else
            {
                reply = $"{CurrentPlatformUser.Name}的口令红包\"{r.Password}\"到期," +
                        $"共{r.TotalCount - r.RemainCount}人领取," +
                        $"剩余{CurrentGlobalKouConfig.CoinFormat(r.RemainCoins)}\n" +
                        $"[获得了{exp}点经验]";
            }

            CurrentPlatformUser.SendMessage(TargetGroup ?? CurrentPlatformGroup, reply);
        }
        public object OpenPasswordRedPacket(string password)
        {
            var red = KouRedPacket.TryGetGlobalRedPacket(password);

            if (red == null)
            {
                return("找不到对应的红包诶...");
            }
            string speedAppend =
                red.IsCompeteInVelocity ? $"(耗时{(DateTime.Now - red.StartTime).TotalSeconds:0.##}秒)" : null;

            speedAppend += red.Remark?.Be($"\n红包留言:{red.Remark}");
            if (red.TestIfHaveOpened(CurrentPlatformUser))
            {
                return($"{CurrentPlatformUser.Name}已经抢过该红包啦");
            }
            if (!red.Open(CurrentPlatformUser, out var coinsGot))
            {
                return("可惜,没有抢到这个红包呢");
            }
            return($"{CurrentPlatformUser.Name}打开{(red.FromUser.KouUser == CurrentPlatformUser.KouUser ? "自己" : red.FromUser.Name)}的红包获得了{CurrentGlobalKouConfig.CoinFormat(coinsGot)}!{speedAppend}");
        }