private async Task <(string type, bool cons, StringBuilder Fc, StringBuilder TitleFc)> DoRemove(AbbybotCommandArgs a) { StringBuilder sb = new StringBuilder(); var FavoriteCharacter = a.Replace(Command); var TitleFC = a.Replace(Command); var charactertag = a.BreakAbbybooruTag(a.user.FavoriteCharacter); FavoriteCharacter.Remove(0, 7); TitleFC.Remove(0, 7); sb.AppendLine($"you entered {FavoriteCharacter}"); FavoriteCharacter = a.BreakAbbybooruTag(FavoriteCharacter); var chosenChr = FavoriteCharacter.Split(" or "); var chrt = charactertag.Split(" or "); List <string> strs = new List <string>(); if (chrt.Length > 1) { var awf = chrt.Where(c => !chosenChr.Contains(c)); foreach (var chr in awf) { strs.Add(chr); } } else { await a.Send($"silly!! You can't remove the last character from your fc!!"); return("remove", false, FavoriteCharacter, a.BreakAbbybooruTag(TitleFC)); } var ww = new StringBuilder().AppendJoin(" or ", strs); await a.Send(sb); return("remove", true, a.BuildAbbybooruTag(ww), a.BreakAbbybooruTag(TitleFC)); }
private async Task <(string type, bool cons, StringBuilder Fc, StringBuilder TitleFc)> DoBuildTag(AbbybotCommandArgs a) { var FavoriteCharacter = a.Replace(Command); FavoriteCharacter.Remove(0, 9); await a.Send(a.BuildAbbybooruTag(FavoriteCharacter)); return("buildtag", false, null, null); }
public override async Task DoWork(AbbybotCommandArgs a) { var FavoriteCharacter = a.Replace(Command); if (a.user.isGuild && !a.user.admin) { await a.Send($"silly {a.user.Preferedname}, you're not an admin here!!!"); } Abbybot.print("acadd called"); if (FavoriteCharacter.Length < 1) { return; } a.BuildAbbybooruTag(FavoriteCharacter); string pictureurl = "https://img2.gelbooru.com/samples/ee/e2/sample_eee286783bfa37e088d1ffbcf8f098ba.jpg"; var o = new string[1]; o[0] = FavoriteCharacter.ToString() + "*"; var ee = await FCSimplification.awa(a, o, ""); EmbedBuilder eb = new EmbedBuilder(); eb.ImageUrl = pictureurl; var u = a.user; if (ee.canrun) { try { await AbbyBooruCharacterSql.AddCharacterAsync(a.channel, a.guild, ee.fc); } catch (Exception e) { Abbybot.print(e.Message); eb.Title = $"silly!!! {a.user.Preferedname}!!!"; eb.Color = Color.Red; eb.Description = $"silly!! {ee.fc} was already added to this channel!!"; await a.Send(eb); return; } eb.Title = $"{a.user.Preferedname} Yayy!!"; eb.Color = Color.Green; eb.Description = $"I added {ee.fc} to the channel master!! "; } else { eb.Title = $"oof... {a.user.Preferedname}..."; eb.Color = Color.Red; eb.Description = $"sorry {u.Preferedname}... i couldn't find {ee.fc} ({FavoriteCharacter}) ..."; } await a.Send(eb); }
private async Task <(string type, bool cons, StringBuilder Fc, StringBuilder TitleFc)> DoAdd(AbbybotCommandArgs a) { var FavoriteCharacter = a.Replace(Command); var TitleFC = a.Replace(Command); FavoriteCharacter.Remove(0, 4); TitleFC.Remove(0, 4); if ((FavoriteCharacter.Length <= 1)) { return("add", false, null, null); } string[] o = new string[1] { a.BuildAbbybooruTag(FavoriteCharacter.ToString()) }; var ava = await awa(a, o, ""); FavoriteCharacter.Clear().Append(ava.fc); TitleFC.Clear().Append(ava.fc); a.BuildAbbybooruTag(FavoriteCharacter); foreach (var chr in a.GetFCList()) { if (chr == "*" || chr == "**" || chr.Length <= 1) { continue; } if (chr.EndsWith("*")) { FavoriteCharacter.Insert(0, $"{chr.Remove(chr.Length - 1)} or "); } else { FavoriteCharacter.Insert(0, $"{chr} or "); } } while (FavoriteCharacter.Contains("__")) { FavoriteCharacter.Replace("__", "_"); } Console.WriteLine($"{FavoriteCharacter},!!, {TitleFC}"); return("add", true, FavoriteCharacter, TitleFC); }
public override async Task DoWork(AbbybotCommandArgs a) { var FavoriteCharacter = a.Replace(Command); if (FavoriteCharacter.Length < 1) { return; } string fc = FavoriteCharacter.ToString(); a.BuildAbbybooruTag(FavoriteCharacter); var o = new string[1]; o[0] = FavoriteCharacter.ToString() + "*"; EmbedBuilder eb = new EmbedBuilder(); var u = a.user; try { await AbbyBooruCharacterSql.RemoveCharacterAsync(a.channel, FavoriteCharacter.ToString()); eb.Title = $"{fc} aww ok..."; eb.Color = Color.Green; eb.Description = $"I removed the character from the channel {u.Preferedname} master..."; } catch { eb.Title = $"silly!!! {fc}!!!"; eb.Color = Color.Red; eb.Description = $"silly!! {fc} was not in the channel in the first place!!!"; } await a.Send(eb); }
public override async Task DoWork(AbbybotCommandArgs a) { var input = a.Replace(Command); if (input.Length == 0) { if (a.hasMultipleFcs) { var fclists = GetMultiFCStringBuilders(a); await a.Send(fclists); return; } else { string message = $"Your favorite character is: {a.BreakAbbybooruTag(a.user.FavoriteCharacter)}. Get help with {Command} help"; await a.Send(message); return; } } var ofclist = a.GetFCList(); var subCommand = input.Split(" ")[0]; var info = subCommand switch { "help" => await DoHelp(a), "history" => await DoHistory(a), "undo" => await DoUndo(a), "revert" => await DoRevert(a), "add" => await DoAdd(a), "remove" => await DoRemove(a), "buildtag" => await DoBuildTag(a), "breaktag" => await DoBreakTag(a), _ => await DoSet(a) }; if (!info.cons) { return; } string[] o = new string[1]; a.BuildAbbybooruTag(info.TitleFc); a.BuildAbbybooruTag(info.Fc); o[0] = (info.TitleFc ?? info.Fc).ToString(); (bool canrun, string pictureurl, string previewurl, string fc)aaa = (false, null, null, ""); int failcount = 0; bool failed = false; EmbedBuilder eb = new EmbedBuilder(); bool set = false; do { var sif = o[0]; try { aaa = await awa(a, o, info.type); if (!aaa.canrun) { throw new Exception("Can't run"); } } catch { failcount++; continue; } if (info.type == "set") { info.Fc.Clear().Append(aaa.fc); o[0] = aaa.fc; } Console.WriteLine($"{sif}->{o[0]}"); string[] uris = new string[] { aaa.pictureurl, aaa.previewurl }; int count = 0; foreach (var u in uris) { try { eb.ImageUrl = u.ToString(); set = true; break; } catch { count++; } } if (count >= uris.Length) { failcount++; failed = true; } Console.WriteLine($"set? {set}, fails?{failcount}, image? {eb.ImageUrl != null}"); } while (!set && failcount < 3); if (failed) { await a.Send("I'm sorry master... I tried really hard to find you a picture you would like... But nothing came up... I tried 3 searches... oh well..."); return; } var oioio = a.BreakAbbybooruTag(((info.TitleFc != null) ? info.TitleFc : info.Fc).ToString()); Console.WriteLine($"{oioio}: {info.TitleFc}, {info.Fc}"); Console.WriteLine(oioio); if (aaa.canrun) { var u = await FavoriteCharacterHistorySql.GetFavoriteCharacterHistoryAsync(a.user.Id); await FavoriteCharacterSql.SetFavoriteCharacterAsync(a.user.Id, info.Fc.ToString()); var lastId = (u.Count > 0 ? u[0].Id : 0); Console.WriteLine(lastId); await FavoriteCharacterHistorySql.SetFavoriteCharacterHistoryAsync(a.user.Id, info.Fc.ToString(), info.type, oioio, lastId); eb.Color = Color.Green; eb.Title = info.type switch { "add" => $"Added {oioio}!!!", "remove" => $"Removed {oioio}!!!", "set" => $"{oioio} Yayy!!", _ => "I'm kinda confused master..." }; eb.Description = info.type switch { "add" => $"I added {oioio} to your fc!!", "remove" => $"I removed {oioio} from your fc!", "set" => $"I know your favorite character now hehehehe cutie {a.user.Preferedname} master!! ", _ => "I... I really don't know what's going on..." }; } else { var foc = a.BreakAbbybooruTag(info.Fc.ToString()); eb.Title = $"oof... {foc}..."; eb.Description = $"sorry {a.user.Preferedname}... i couldn't find {foc} ({info.Fc}) ..."; eb.Color = Color.Red; } await a.Send(eb); if (ofclist.Length > 2 && info.type == "set") { await a.Send("Hey, ps... I think you may have made a mistake... You set that favorite character instead of adding it. \nIf you didn't mean to override your favorite character list, I suggest you to run: ``%fc undo``"); } }