public static Command GetGetVillageCommand(Bot bot) { return new Command("!getvillage", "Get your current village code.", "", bot, (message) => { return message.text.ToUpper() == "!GETVILLAGE"; }, (message) => { try { var member = Members.GetMemberByGroupMeID(message.sender_id); if (member == null || String.IsNullOrEmpty(member.VillageCode)) { bot.SendMessage("Your village is not set."); } else { bot.SendMessage($"Your village code is {member.VillageCode}"); } } catch (Exception ex) { Bots.TestChatBot.SendMessage(ex.ToString()); } }); }
private static Command BeADoucheCommand(Bot bot) { return new Command("", "", "", CommandType.GodOnly,bot, (message) => { return message.sender_id == Mods.Alckie && message.text.ToUpper() == "!BEADOUCHE"; }, (message) => { if (bot.IsBeingADouche) { bot.SendMessage("I'M DOING IT ALREADY, DAMNIT."); } else { bot.IsBeingADouche = true; bot.SendMessage("Douche mode on."); } }); }
private static Command StopBeingADoucheCommand(Bot bot) { return new Command("", "", "", CommandType.GodOnly, bot, (message) => { return message.sender_id == Mods.Alckie && message.text.ToUpper() == "!STOPBEINGADOUCHE"; }, (message) => { if (bot.IsBeingADouche) { bot.IsBeingADouche = false; bot.SendMessage("Douche mode off."); } else { bot.SendMessage("But I'm not. ;_;"); } }); }
public static Command ClashCallerCommand(Bot bot) { return new Command("!clashcaller, !cc", "Get the url for ClashCaller.", "", bot, (message) => { return message.text.ToUpper() == "!CLASHCALLER" || message.text.ToUpper() == "!CC"; }, (message) => { if (ClashCaller.Code != "") { bot.SendMessage("http://www.clashcaller.com/war/" + ClashCaller.Code); } else { bot.SendMessage("I don't have the code atm."); } }); }
public static Command BabyComeBackCommand(Bot bot) { return new Command("!babycomeback, !starttheparty", "AlckieBot will go back to his usual self.", "", CommandType.ModsOnly, bot, (message) => { return (message.text.ToUpper() == "!BABYCOMEBACK" || message.text.ToUpper() == "!STARTTHEPARTY"); }, (message) => { if (Mods.IsUserAMod(message.sender_id)) { var attachments = new List<dynamic>(); attachments.Add(new { loci = new int[][] { new int[] { 17, message.name.Length + 1 } }, type = "mentions", user_ids = new string[] { message.sender_id } }); bot.SendMessage("Thank you Master @" + message.name + " for letting me be free!", attachments); bot.CanSpeak = true; } else { bot.SendMessage("No can do."); } }, false); }
public static Command RandomQuoteByMemberCommand(Bot bot) { return new Command("!randomquote <search parameters>", "Return a random quote from someone who matches the search parameters.", "!randomquote Alckie", bot, (message) => { return message.text.ToUpper().StartsWith("!RANDOMQUOTE "); }, (message) => { var searchParams = message.text.Substring("!RANDOMQUOTE ".Length).Trim(); var quotes = Quote.GetQuotes().Where(q => q.Member.ToUpper().Contains(searchParams.ToUpper())).ToList(); if (quotes.Count > 0) { var randomNumber = RandomHelper.GetRandomNumber(quotes.Count); var selectedQuote = quotes[randomNumber - 1]; bot.SendMessage($"\"{selectedQuote.Message.Trim()}\" - {selectedQuote.Member}, {selectedQuote.SavedAt.Year} "); } else { var randomNumber = RandomHelper.GetRandomNumber(3); switch (randomNumber) { case 1: bot.SendMessage("\"I can't find shit with that filter.\" - AlckieBot, 2015"); break; case 2: bot.SendMessage("Nothing to see here."); break; default: bot.SendMessage("Search for something else."); break; } } }); }
public static Command RandomQuoteCommand(Bot bot) { return new Command("!randomquote", "Return a random quote from someone", "", bot, (message) => { return (message.text.ToUpper() == "!RANDOMQUOTE"); }, (message) => { var quotes = Quote.GetQuotes(); var randomNumber = RandomHelper.GetRandomNumber(quotes.Count); var selectedQuote = quotes[randomNumber - 1]; bot.SendMessage($"\"{selectedQuote.Message.Trim()}\" - {selectedQuote.Member}, {selectedQuote.SavedAt.Year} "); }); }
public static Command GetGroupIDsCommand(Bot bot) { return new Command("", "", "", CommandType.GodOnly, bot, (message) => { return message.text.ToUpper().StartsWith("!GROUPIDS"); }, (message) => { var groups = Chat.GetAllGroups(ConfigurationManager.AppSettings["GROUPME_TOKEN"]); var sb = new StringBuilder(); foreach(var group in groups) { sb.AppendLine($"- Name: {group.Name} - ID: {group.ID}"); } bot.SendMessage(sb.ToString()); }); }
public static Command CallModsCommand(Bot bot) { return new Command("@mods", "Tag all Mist mods.", "", bot, (message) => { return message.text.ToUpper() == "@MODS"; }, (message) => { if (bot.CanCallMods) { var leadershipGroup = Chat.GetGroup(ConfigurationManager.AppSettings["GROUPME_TOKEN"], ConfigurationManager.AppSettings["LEADERSHIPCHAT_ID"]); if (leadershipGroup != null) { var callMessage = "Masters, one of your minions needs your attention."; if (bot.GroupID == ConfigurationManager.AppSettings["LEADERSHIPCHAT_ID"]) { callMessage = "Listen up, ya cunts!"; } if (callMessage.Length < leadershipGroup.Members.Count) { var charactersToFill = leadershipGroup.Members.Count - callMessage.Length; callMessage = callMessage.PadRight(charactersToFill); } var userIDs = leadershipGroup.Members.Select(g => g.UserID).ToArray(); var locis = new int[leadershipGroup.Members.Count][]; for (var i = 0; i < leadershipGroup.Members.Count; i++) { if (i < leadershipGroup.Members.Count - 1) { locis[i] = new int[] { i, 1 }; } else { //fill out the mention with the rest of the message locis[i] = new int[] { i, callMessage.Length - i }; } } var attachments = new List<dynamic>(); attachments.Add(new { loci = locis, type = "mentions", user_ids = userIDs }); bot.SendMessage(callMessage, attachments); } } else { bot.SendMessage("Plebs are not allowed to call the Masters right now."); } }); }
private static void BanOrUnbanMember(Bot bot, string userId, bool ban) { var member = Members.GetMembers().Where(m => m.GroupMeID == userId).FirstOrDefault(); if (member == null) { bot.SendMessage("Can't find anyone. Use !members and get the right ID."); } else { member.Banned = ban; Members.UpdateMember(member); bot.SendMessage($"{member.Name} is now " + (ban ? "banned" : "unbanned")); } }
public static Command UnixTimeCommand(Bot bot) { return new Command("!time", "Gets the current date and time in Unix time.", "", bot, (message) => { return (message.text.ToUpper() == "!TIME"); }, (message) => { var unixTime = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds; bot.SendMessage($"{unixTime} UTC."); }); }
public static Command TagMeInWithReasonCommand(Bot bot) { return new Command("!tagmein {X}h{Y}m {reminder}", "AlckieBot will tag you after some time, and remind you of something.", "!tagmein 0h10m Call my dad.", bot, (message) => { var validate = Regex.Match(message.text.ToUpper(), @"^!TAGMEIN ((\d+)h)?((\d+)m) ", RegexOptions.IgnoreCase); return validate.Success; }, (message) => { var validate = Regex.Match(message.text, @"^!TAGMEIN ((\d+)h)?((\d+)m) ", RegexOptions.IgnoreCase); var timeParameter = validate.Value.Substring("!TAGMEIN ".Length); var reasonParameter = message.text.Substring(validate.Value.Length); var hours = 0; var minutes = 0; if (timeParameter.Contains("h")) { hours = Int32.Parse(timeParameter.Split('h')[0]); minutes = Int32.Parse(timeParameter.Replace("m", "").Split('h')[1]); } else { minutes = Int32.Parse(timeParameter.Replace("m", "")); } var time = new TimeSpan(hours, minutes, 0); bot.SendMessage("Sure thing. I will tag you in " + timeParameter); TimerHelper.ExecuteDelayedActionAsync(() => { var attachments = new List<dynamic>(); attachments.Add(new { loci = new int[][] { new int[] { 0, message.name.Length + 1 } }, type = "mentions", user_ids = new string[] { message.sender_id } }); bot.SendMessage($"@{message.name}! You told me to remind you: {reasonParameter}.", attachments); }, time); }); }
public static Command ShutupCommand(Bot bot) { return new Command("!shutup", "AlckieBot won't reply to commands anymore. Use !backcomebacy to restart him.", "", CommandType.ModsOnly, bot, (message) => { return (message.text.ToUpper() == "!SHUTUP"); }, (message) => { if (Mods.IsUserAMod(message.sender_id)) { bot.SendMessage("Sure thing, master. I will shut up for now."); bot.CanSpeak = false; } else { var attachments = new List<dynamic>(); attachments.Add(new { loci = new int[][] { new int[] { 17, message.name.Length + 1 } }, type = "mentions", user_ids = new string[] { message.sender_id } }); bot.SendMessage("No, you shut up, @" + message.name + "!", attachments); } }); }
public static Command EveryoneCommand(Bot bot) { return new Command("@everyone", "Tag everyone in the chat.", "", CommandType.ModsOnly, bot, (message) => { return Mods.IsUserAMod(message.sender_id) && (message.text.ToUpper() == "@EVERYONE"); }, (message) => { var group = Chat.GetGroup(ConfigurationManager.AppSettings["GROUPME_TOKEN"], bot.GroupID); if (group != null) { var callMessage = $"Hey everyone, listen up! {message.name} has something to tell you."; var userIDs = group.Members.Select(g => g.UserID).ToArray(); var locis = new int[group.Members.Count][]; for (var i = 0; i < group.Members.Count; i++) { if (i < group.Members.Count - 1) { locis[i] = new int[] { i, 1 }; } else { //fill out the mention with the rest of the message locis[i] = new int[] { i, callMessage.Length - i }; } } var attachments = new List<dynamic>(); attachments.Add(new { loci = locis, type = "mentions", user_ids = userIDs }); bot.SendMessage(callMessage, attachments); } }); }
public static Command GetSetVillageCommand(Bot bot) { return new Command("!setvillage #{village code}", "Set your village code, so you can call targets using the !call command (Still under development).", "!setvillage #00000000", bot, (message) => { var validate = Regex.Match(message.text.ToUpper(), "^!SETVILLAGE #([0-Z])+$", RegexOptions.IgnoreCase); return validate.Success; }, (message) => { var villageCode = message.text.ToUpper().Substring("!SETVILLAGE ".Length); var member = Members.GetMemberByGroupMeID(message.sender_id); if (member == null) { member = new Model.Member { GroupMeID = message.sender_id, Name = message.name, Banned = false }; } member.VillageCode = villageCode; Members.UpdateMember(member); bot.SendMessage($"Village code set to {villageCode}"); }); }
public static Command WelcomeMessageCommand(Bot bot) { return new Command("", "", "", CommandType.Automatic, bot, (message) => { return (message.system && ( message.text.ToUpper().Contains("JOINED") || message.text.ToUpper().Contains("ENTROU") || message.text.ToUpper().Contains("ADICIONOU") || message.text.ToUpper().Contains("ADDED") )); }, (message) => { bot.SendMessage("Welcome to Reddit Mist! Please change your name to match your IGN and, if you haven't already, make sure to read our rules available at www.reddit.com/r/RedditMist"); }); }
public static Command KickCommand(Bot bot) { return new Command("!kick {tag}", "Kick someone from the chat", "!kick @Cha", CommandType.ModsOnly, bot, (message) => { var isKickCommand = (message.text.ToUpper().StartsWith("!KICK ")); if (!isKickCommand) { //Return earlier return false; } var isAMod = Mods.AllMods.Contains(message.user_id); var containsAttachment = message.attachments?.Length == 1; var isAMention = message.attachments[0]?.Type == "mentions"; var containsOnlyOneMention = message.attachments[0]?.User_ids?.Length == 1; return isAMod && containsAttachment && isAMention && containsOnlyOneMention; }, (message) => { var mention = message.attachments[0]; var userID = mention.User_ids[0]; if (Mods.AllMods.Contains(userID)) { bot.SendMessage("I won't turn against my Master."); } else { if (bot.KickUser(ConfigurationManager.AppSettings["GROUPME_TOKEN"], userID)) { bot.SendMessage("rekt"); } else { bot.SendMessage("Shit! I can't..."); } } }); }
public static Command CuntCommand(Bot bot) { return new Command("!c**t", "Send a c**t.", "", bot, (message) => { return (message.text.ToUpper() == "!C**T" || message.text.ToUpper() == "C**T"); }, (message) => { bot.SendMessage("C**t received!"); }); }
public static Command HiCommand(Bot bot) { return new Command("!hi, !hey, !howdy, !hello", "AlckieBot will greet you back.", "", bot, (message) => { return (message.text.ToUpper() == "!HI" || message.text.ToUpper() == "!HEY" || message.text.ToUpper() == "!HOWDY" || message.text.ToUpper() == "!HELLO" || message.text.ToUpper() == "@ALCKIEBOT"); }, (message) => { var messageNumber = RandomHelper.GetRandomNumber(5); switch (messageNumber) { case 1: bot.SendMessage("Hey, c**t!"); break; case 2: bot.SendMessage("Hi"); break; case 3: { var attachments = new List<dynamic>(); attachments.Add(new { loci = new int[][] { new int[] { 4, message.name.Length + 1 } }, type = "mentions", user_ids = new string[] { message.sender_id } }); bot.SendMessage("Sup @" + message.name + "!", attachments); break; } case 4: bot.SendMessage("Hello sir! Or lady. Or Siscim..."); break; default: { var attachments = new List<dynamic>(); attachments.Add(new { loci = new int[][] { new int[] { 3, message.name.Length + 1 } }, type = "mentions", user_ids = new string[] { message.sender_id } }); bot.SendMessage("Hi @" + message.name + "!", attachments); break; } } }); }
public static Command GifCommand(Bot bot) { return new Command("!gif {search parameters}", "Search for a random gif in Giphy.", "!gif angelina taxi srs", bot, (message) => { return (message.text.ToUpper().StartsWith("!GIF ")); }, (message) => { var timeBeforeDecreasingGifCounter = new TimeSpan(0, 5, 0); var userGifCounter = bot.GetUserSpamCounter(message.sender_id, Model.SpamCounter.SpamType.GIPHY); if (userGifCounter.Counter < SpamCounter.DEFAULT_MAX_SPAM_COUNTER) { userGifCounter.HasBeenWarned = false; var searchParams = message.text.Substring(5); if (searchParams.ToUpper().Contains("ALCKIE") && searchParams.ToUpper().Contains("BOT")) { var randomNumber = RandomHelper.GetRandomNumber(5); switch (randomNumber) { case 1: bot.SendMessage("Try searching for awesome instead."); break; case 2: bot.SendMessage("Do you know how many times people search for that? F*****g boring..."); break; case 3: bot.SendMessage("I won't search for it, just to avoid AlckieBotception."); break; case 4: bot.SendMessage("There are no gifs in this world that can represent my awesome self."); break; default: bot.SendMessage("F**k off."); break; } } else { var url = Giphy.GetGiphyUrl(searchParams); if (url != "") { bot.SendMessage(url); userGifCounter.Counter++; TimerHelper.ExecuteDelayedActionAsync(() => { userGifCounter.Counter--; }, timeBeforeDecreasingGifCounter); } else { bot.SendMessage("I can't find shit. Either you are an idiot, or Giphy sucks too much..."); } } } else if (!userGifCounter.HasBeenWarned) { userGifCounter.HasBeenWarned = true; bot.SendMessage("F**k off... Just leave me alone for a while."); } }); }
public static Command FlipACoinCommand(Bot bot) { return new Command("!flipacoin", "AlckieBot will flip a coin for you.", "", bot, (message) => { return (message.text.ToUpper() == "!FLIPACOIN"); }, (message) => { //Dice roll method is more precise with the odds than the random number method. var diceRoll = RandomHelper.RollDice(2); if (diceRoll == 1) { bot.SendMessage("Head!"); } else { bot.SendMessage("Tail!"); } }); }
public static Command CommandListCommand(Bot bot) { return new Command("!commands", "Get a url with all the available commands.", "", bot, (message) => { return (message.text.ToUpper() == "!COMMANDS"); }, (message) => { bot.SendMessage($"http://alckiebot.azurewebsites.net/commands/{bot.GroupName}"); }); }
public static void UpdateMembersByGroupAndKickIfBanned(string groupMeToken, string groupID, Bot bot) { var dbMembers = GetMembers(); var chat = Model.GroupMe.Chat.GetGroup(groupMeToken, groupID); if (chat != null) { foreach (var member in chat.Members) { var dbMember = dbMembers.FirstOrDefault(m => m.GroupMeID == member.UserID); if (dbMember == null) { UpdateMember(new Model.Member { GroupMeID = member.UserID, Name = member.Name, VillageCode = "", Banned = false }); } else if (dbMember.Banned) { bot.KickUser(groupMeToken, member.UserID); bot.SendMessage("GTFO!"); } } } }
public static Command RollDiceCommand(Bot bot) { return new Command("!roll {X}d{Y}", "Roll X dices with Y faces.", "!roll 1d6", bot, (message) => { return (message.text.ToUpper().StartsWith("!ROLL ")); }, (message) => { var diceParams = message.text.Substring(6); const string diceValidatorRegex = @"^(\d+)?d(\d+)$"; var validate = Regex.Match(diceParams, diceValidatorRegex, RegexOptions.IgnoreCase); if (validate.Success) { var diceArray = diceParams.ToUpper().Split('D'); var numberOfDices = Int32.Parse(diceArray[0]); var diceSides = Int32.Parse(diceArray[1]); if (numberOfDices == 0 || diceSides < 2) { bot.SendMessage("Are you dumb or something?"); } else if (numberOfDices > 10) { bot.SendMessage("Nah. Too tired to roll that many dice..."); } else if (diceSides > 100) { bot.SendMessage("That's not a dice. That's a f*****g ball."); } else { var rollResults = new string[numberOfDices]; for (var i = 0; i < numberOfDices; i++) { var rollResult = RandomHelper.RollDice(diceSides); rollResults[i] = rollResult.ToString(); } bot.SendMessage($"The results for your roll are: {String.Join(",", rollResults)}"); } } else { var randomNumber = RandomHelper.GetRandomNumber(5); switch (randomNumber) { case 1: bot.SendMessage("Gotta roll it right..."); break; case 2: bot.SendMessage("Nope."); break; case 3: bot.SendMessage("Try again!"); break; case 4: bot.SendMessage("Omg, you can't even roll a dice."); break; default: bot.SendMessage("That's not how it works."); break; } } }); }
public static Command MembersListCommand(Bot bot) { return new Command("!members", "Get a url with all the GM members.", "", bot, (message) => { return (message.text.ToUpper() == "!MEMBERS"); }, (message) => { bot.SendMessage("http://alckiebot.azurewebsites.net/Members"); }); }
public static Command DontFlipTheTableCommand(Bot bot) { return new Command("", "", "", bot, (message) => { return (new Regex(@"[(].+[))].+┻[━]{0,}┻")).Match($"{message.text}|{message.name}").Success; }, (message) => { int flipTableCounter; bot.CustomCounters.TryGetValue("FlipTableCounter", out flipTableCounter); switch (flipTableCounter) { case 0: bot.SendMessage(@"┬─┬ノ(°-°ノ) Please dont flip the table."); break; case 1: bot.SendMessage(@"┬─┬ノ(>_<ノ) Please dont flip the f*****g table."); break; case 2: bot.SendMessage(@"┬─┬ノ(ò_óノ) STOP FLIPPING THE F*****G TABLE!"); break; case 3: bot.SendMessage(@"(╯>_<)╯︵ /(.□.\) F**K YOU!."); Thread.Sleep(100); bot.SendMessage(@"┬─┬ノ(°-°ノ)"); break; case 4: bot.SendMessage(@"(/.□.)\ ︵╰('□')╯︵ /(.□.\) F**k you all, I'm done with this."); break; } if (flipTableCounter < 4) { flipTableCounter++; bot.CustomCounters["FlipTableCounter"] = flipTableCounter; TimerHelper.ExecuteDelayedActionAsync(() => { bot.CustomCounters["FlipTableCounter"]--; }, new TimeSpan(0, 10, 0)); } }); }
public static Command ModTagCommand(Bot bot) { return new Command("!modtag", "Set whether plebs can tag the mods or not.", "", CommandType.ModsOnly, bot, (message) => { return (Mods.IsUserAMod(message.sender_id) && message.text.ToUpper() == "!MODTAG"); }, (message) => { bot.CanCallMods = !bot.CanCallMods; if (bot.CanCallMods) { bot.SendMessage("Plebs are now allowed to call the Masters"); } else { bot.SendMessage("Plebs lost the right to call upon the Masters. Now stop messing around before we take away your other rights."); } }); }
public static Command RandomHandsUpCommand(Bot bot) { return new Command("", "", "", bot, (message) => { return (message.text.Contains(@"\o/")); }, (message) => { var randomNumber = RandomHelper.GetRandomNumber(10); //Only 10% chance of this command being executed. if (randomNumber == 1) { bot.SendMessage(@"\o/"); } }); }
public static Command SaveQuoteCommand(Bot bot) { return new Command("!savequote <tag> <quote>", "Save a quote for eternity.", "!savequote @Logan AlckieBot is amazing!", bot, (message) => { var isSaveQuoteCommand = (message.text.ToUpper().StartsWith("!SAVEQUOTE ")); if (!isSaveQuoteCommand) { //Return earlier return false; } var containsAttachment = message.attachments?.Length == 1; var isAMention = message.attachments[0]?.Type == "mentions"; var containsOnlyOneMention = message.attachments[0]?.User_ids?.Length == 1; return isSaveQuoteCommand && containsAttachment && isAMention && containsOnlyOneMention; }, (message) => { var mention = message.attachments[0]; var quote = message.text.Substring(mention.Loci[0][0] + mention.Loci[0][1] + 1); var userName = message.text.Substring(mention.Loci[0][0] + 1, mention.Loci[0][1] - 1); var userID = mention.User_ids[0]; if (mention.Loci[0][0] != "!SAVEQUOTE ".Length || quote.Length == 0) { var randomNumber = RandomHelper.GetRandomNumber(5); switch (randomNumber) { case 1: bot.SendMessage("Ask someone who knows his shit to do this for you."); break; case 2: bot.SendMessage("The command is all wrong!"); break; case 3: bot.SendMessage("Try again, but try it right this time."); break; case 4: bot.SendMessage("\"!savequote <tag> <quote>\", ffs."); break; default: bot.SendMessage("That's not how it works."); break; } } else { Quote.AddQuote(new Model.Quote { Member = userName, SavedAt = DateTime.UtcNow, Message = quote }); bot.SendMessage("This quote has been saved for eternity!"); } }); }
public static Command GetWarMatchUsCommand(Bot bot) { return new Command("!warmatch, !wm", "Get the url for the current WarMatch.Us war.", "", bot, (message) => { return message.text.ToUpper() == "!WARMATCH" || message.text.ToUpper() == "!WM"; }, (message) => { bot.SendMessage("http://warmatch.us/wars/mist/"); }); }