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); }
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); }
static async Task RequestBeat(DateTime time) { if (time > CheckTime) { //Abbybot.print("running abc!!"); CheckTime = CheckTime.AddMinutes(1); SocketTextChannel channel = null; List <Character> characters = await AbbyBooruCharacterSql.GetListFromSqlAsync(); foreach (var character in characters) { //Abbybot.print("{}"); //AbbybotGuild bool safe = true; List <string> tags = new List <string>(); try { var Gl = Apis.Discord.__client.Guilds.ToList().Any(x => x.Id == character.guildId); if (!Gl) { continue; } //Console.WriteLine($"{character.tag}, guild found!"); var G = Apis.Discord.__client.GetGuild(character.guildId); var pref = await GuildSql.GetGuild(character.guildId); if (pref.PrefAbbybot != Apis.Discord.__client.CurrentUser.Id) { continue; } channel = G.GetTextChannel(character.channelId); tags.Add(character.tag); //Console.WriteLine($"channel nsfw? {channel.IsNsfw}, character lewd? {character.IsLewd}"); safe = !channel.IsNsfw; } catch (Exception e) { //Console.WriteLine(e.ToString()); continue; } if (safe) { tags.Add("rating:safe"); } Post[] charpicx = new Post[0]; try { charpicx = (await Apis.AbbyBooru.GetLatest(tags.ToArray())).ToArray(); if (charpicx == null) { continue; } if (charpicx.Length > 5) { charpicx = charpicx.Take(5).ToArray(); } else { continue; } } catch { //Console.WriteLine("aaaa"); } List <img> nngs = new List <img>(); var postIds = (await AbbyBooruCharacterSql.GetLatestPostIdsAsync(character)); Post[] eeee = charpicx.Where(x => !postIds.Contains((ulong)x.id)).Take(5).ToArray(); foreach (var ex in eeee) { img nng = new img() { Id = (ulong)ex.id, imgurl = ex.fileUrl, source = ex.source, safe = (ex.rating.Contains($"safe")), GelId = ex.id, md5 = ex.md5 }; nngs.Add(nng); } for (int i = 0; i < nngs.Count; i++) { img sr = nngs[i]; EmbedBuilder embededodizer = new EmbedBuilder { ImageUrl = sr.imgurl }; string fixedsource = "no source found"; try { if (sr.source != null) { fixedsource = sr.source.Replace("/member_illust.php?mode=medium&illust_id=", "/en/artworks/"); } embededodizer.AddField($"New picture of {character.tag.Replace("_", " ")} :)", $"[Source]({fixedsource})"); embededodizer.Color = Color.LightOrange; await channel.SendMessageAsync("", false, embededodizer.Build()); } catch { } await AbbyBooruCharacterSql.AddLatestPostIdAsync(character.Id, sr.Id, sr.GelId); if (character.Id == 3) { var dl = await FunAbbybotFactsSql.GetFactsList(true, "twitter"); Random r = new Random(); var ranfac = dl.Count > 0? dl[r.Next(0, dl.Count)].fact:""; Tweet tweet = new() { message = $"A new tweet just came in from gelbooru!!\n{ranfac}", url = sr.imgurl, sourceurl = fixedsource, GelId = sr.GelId }; await TweetQueueSql.Add(tweet, true); } } } } } }