public static async Task Drink(SocketMessage message, Settings settings, DiscordSocketClient client, Func <LogMessage, Task> log) { await log(new LogMessage(LogSeverity.Info, "Discord", $"{message.Content.ToLower()} detected, finding a drinker")); var drinkers = settings.CurrentSettings.Drinkers; if (drinkers.Count() <= 0) { await message.Channel.SendMessageAsync($"No users in the drinking crew, set the crew with !drinkers "); return; } var roll = DrinkingRandom.Next(0, drinkers.Length); var user = client.GetUser(drinkers[roll]); if (user == null) { await message.Channel.SendMessageAsync($"Could not find user in the drinking crew :( "); return; } roll = DrinkingRandom.Next(0, Insults.Count); var insult = Insults[roll]; await message.Channel.SendMessageAsync($"Drinky time { user.Mention } you {insult}"); await RandomImageHandler.AquaKanpai(message, log, false); }
// At this point we know the message contains the text Aqua, lets see if we can find any other text from our abuse list public static async Task HandlePotentialAbuse(SocketMessage message, Func <LogMessage, Task> log) { foreach (var abuse in AbuseTerms) { if (message.Content.ToLower().Replace(" ", "").IndexOf(abuse) >= 0) { await RandomImageHandler.AquaAbuse(message, log); break; } } }
// TODO - This feels wrong being in here? Maybe some better way to handle a large if like this? private async Task MessageReceived(SocketMessage message) { if (message.Author.IsBot == false) { if (message.Content.IndexOf("!addBannedWord", StringComparison.OrdinalIgnoreCase) == 0) { await BannedWords.AddBannedWord(message, message.Content.Replace("!addBannedWord", "", StringComparison.OrdinalIgnoreCase).Trim(), Settings); } else if (BannedWords.CheckMessage(message, Settings.CurrentSettings.BannedWords)) { await BannedWords.HandleUseOfBannedWords(Settings.CurrentSettings.BannedWords, message); } if (string.Equals(message.Content, "!aqua", StringComparison.OrdinalIgnoreCase)) { await PostImageSearchAsync(message, "aqua_(konosuba) 1girl", safeBooruImages); } else if (string.Equals(message.Content, "!megumin", StringComparison.OrdinalIgnoreCase)) { await PostImageSearchAsync(message, "megumin 1girl", safeBooruImages); } else if (string.Equals(message.Content, "!darkness", StringComparison.OrdinalIgnoreCase)) { await PostImageSearchAsync(message, "darkness_(konosuba) 1girl", safeBooruImages); } else if (string.Equals(message.Content, "!konosuba", StringComparison.OrdinalIgnoreCase)) { await PostImageSearchAsync(message, "kono_subarashii_sekai_ni_shukufuku_wo! -1girl -1boy", safeBooruImages); } else if (message.Content.IndexOf("!safebooru", StringComparison.OrdinalIgnoreCase) >= 0) { await PostSafebooruAsync(message); } else if (message.Content.IndexOf("!gelbooru", StringComparison.OrdinalIgnoreCase) >= 0) { await PostGelbooruAsync(message); } else if (string.Equals(message.Content, "!bugmatty", StringComparison.OrdinalIgnoreCase)) { await BugMatty(message); } else if (string.Equals(message.Content, "!flip", StringComparison.OrdinalIgnoreCase)) { await FilpHeadsTails(message); } // spaces could be between the letters, k a m p a i, because josh does that else if (message.Content.Replace(" ", "").IndexOf("kanpai", StringComparison.OrdinalIgnoreCase) >= 0) { await RandomImageHandler.AquaKanpai(message, Log, true); } else if (message.Content.IndexOf("aqua", StringComparison.OrdinalIgnoreCase) >= 0) { await AquaAbuseHandler.HandlePotentialAbuse(message, Log); } else if (message.Content.IndexOf("!wiki", StringComparison.OrdinalIgnoreCase) == 0) { await WikiSearch(message); } else if (message.Content.IndexOf("!drinking", StringComparison.OrdinalIgnoreCase) == 0 || message.Content.IndexOf("!drinkers", StringComparison.OrdinalIgnoreCase) == 0) { await DrinkingHandler.SetDrinkers(message, Settings, Log); } else if (message.Content.IndexOf("!drink", StringComparison.OrdinalIgnoreCase) == 0) { await DrinkingHandler.Drink(message, Settings, Client, Log); } else if (message.Content.IndexOf("!d", StringComparison.OrdinalIgnoreCase) == 0 && Regex.Match(message.Content.ToLower().Replace(" ", ""), @"!d\d+").Success) { await RollDX(message); } else if (message.Content.IndexOf("!tuck", StringComparison.OrdinalIgnoreCase) == 0 && message.MentionedUsers.Count > 0) { await Tuck(message); } else if (message.Content.Replace("!", "").Contains(Client.CurrentUser.Mention.Replace("!", ""))) { if (message.Content.IndexOf(" or ", StringComparison.OrdinalIgnoreCase) >= 0) { await MakeDecision(message); } else if (message.Content.LastIndexOf('?') == message.Content.Length - 1) { await Magic8Ball.Answer(message, Log); } } } }