public string KouLearnAnotherName( [KouPluginArgument(Name = "歌曲名等")] string songName, [KouPluginArgument(Name = "要学的歌曲别名")] string songAnotherName) { if (songName.IsNullOrWhiteSpace() || songAnotherName.IsNullOrWhiteSpace()) { return("好好教我嘛"); } var haveTheAlias = SongAlias.SingleOrDefault(p => p.Alias == songAnotherName); if (haveTheAlias != null) { return($"可是我之前就知道{haveTheAlias.CorrespondingSong.SongTitle}可以叫做{songAnotherName}了"); } var song = SongAlias.SingleOrDefault(p => p.Alias == songName)?.CorrespondingSong; if (song == null) { var satisfiedSongs = Song.Find(s => s.SongId.ToString() == songName || s.SongTitle.Contains(songName, StringComparison.OrdinalIgnoreCase)).ToList(); if (satisfiedSongs.Count > 1) { return($"具体是以下哪一首歌呢(暂时不支持选择id):\n{satisfiedSongs.ToSetString()}"); } if (satisfiedSongs.Count == 0) { return($"找不到哪个歌叫{songName}哦..."); } song = satisfiedSongs[0]; } var sourceUser = CurrentPlatformUser.FindThis(KouContext); var dbSong = song.FindThis(KouContext); var havenHadAliases = dbSong.Aliases?.Select(p => p.Alias).ToStringJoin("、"); var success = SongAlias.Add(alias => { alias.CorrespondingSong = dbSong; alias.Alias = songAnotherName; alias.SourceUser = sourceUser; }, out var added, out var error, KouContext); if (success) { var reward = RandomTool.GenerateRandomInt(1, 2); CurrentPlatformUser.KouUser.GainCoinFree(reward); return($"学会了,{song.SongTitle}可以叫做{songAnotherName}({added.AliasID})" + $"{havenHadAliases?.Be($",我知道它还可以叫做{havenHadAliases}!")}(目前暂不会立即同步)\n" + $"[{CurrentUser.FormatGainFreeCoin(CurrentGlobalKouConfig,reward)}!]"); } return($"没学会,就突然:{error}"); }
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)); }