public string KouForgetAnotherName( [KouPluginArgument(Name = "别名ID")] List <int> ids) { if (ids.IsNullOrEmptySet()) { return("这是叫我忘掉什么嘛"); } var result = new StringBuilder(); foreach (var i in ids) { var alias = SongAlias.SingleOrDefault(a => a.AliasID == i); if (alias == null) { result.Append($"\n不记得ID{i}"); } else if (alias.SourceUser != null && alias.SourceUser != CurrentPlatformUser && !CurrentPlatformUser.HasTheAuthority(Authority.BotManager)) { result.Append($"\nID{i}是别人贡献的,不可以删噢"); } else { result.Append($"\n忘记了{alias.ToString(FormatType.Brief)}"); alias.DeleteThis(); }; } return(result.ToString().TrimStart()); }
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}"); }