public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); string allSettings = string.Format("{0} [b]Channel Settings[/b]: \n" + "[b]StartupChannel:[/b] {1}, [b]AllowTableInfo:[/b] {2}, [b]AllowTableRolls:[/b] {3},\n" + "[b]AllowCustomTableRolls:[/b] {4}, [b]GreetNewUsers:[/b] {5}, [b]AllowChips:[/b] {6} \n" + "[b]Add Chips Restriction:[/b] {7} (OnlyOpAddChips), [b]StartWith500Chips[/b]: {8} \n" + "[b]AllowGames:[/b] {9}", thisChannel.Name, thisChannel.StartupChannel, thisChannel.AllowTableInfo, thisChannel.AllowTableRolls, thisChannel.AllowCustomTableRolls, thisChannel.GreetNewUsers, thisChannel.AllowChips, thisChannel.ChipsClearance.ToString(), thisChannel.StartWith500Chips, thisChannel.AllowGames); bot.SendMessageInChannel(allSettings, channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); bool characterIsAdmin = Utils.IsCharacterAdmin(bot.AccountSettings.AdminCharacters, characterName); bool characterIsTrustedForChannel = Utils.IsCharacterTrusted(bot.AccountSettings.TrustedCharacters, characterName, channel); if (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && command.ops == null) { bot.RequestChannelOpListAndQueueFurtherRequest(command); } else if ((thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin && !characterIsAdmin && !characterIsTrustedForChannel) || (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && !command.ops.Contains(characterName) && !characterIsAdmin)) { bot.SendMessageInChannel(Utils.GetCharacterUserTags(characterName) + " cannot perform [" + Name + "] under the current chip settings for this channel.", channel); } else if (thisChannel.AllowChips) { bool pot = false; int chipAmount = Utils.GetNumberFromInputs(terms); if (terms != null && terms.Length >= 1 && terms.Contains("pot")) { pot = true; } string messageString = ""; if (chipAmount <= 0) { messageString = "Error: You must specify a number of chips above 0 to add."; } else { messageString = bot.DiceBot.AddChips(characterName, channel, chipAmount, pot); commandController.SaveChipsToDisk(); } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { bool jokers = false; if (terms != null && terms.Length >= 1 && terms.Contains("j")) { jokers = true; } DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms); string customDeckName = Utils.GetCustomDeckName(characterName); string deckTypeString = Utils.GetDeckTypeStringHidePlaying(deckType, customDeckName); bot.DiceBot.ResetDeck(jokers, channel, deckType, customDeckName); bot.SendMessageInChannel("[i]" + deckTypeString + "Channel deck reset." + (jokers ? " (contains jokers)" : "") + "[/i]", channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { int numberRolled = Utils.GetNumberFromInputs(terms); string resultString = ""; if (numberRolled > DiceBot.MaximumDice) { resultString = "Error: Cannot roll more than " + DiceBot.MaximumDice + " dice."; } else { resultString = bot.DiceBot.RollFitD(numberRolled); } bot.SendMessageInChannel(resultString, channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { string channelId = Utils.GetChannelIdFromInputs(rawTerms); string sendMessage = "Attempting to join channel: " + channelId; bot.JoinChannel(channelId); //send to character if there is no origin channel for this command if (!commandController.MessageCameFromChannel(channel)) { bot.SendPrivateMessage(sendMessage, characterName); } else { bot.SendMessageInChannel(sendMessage, channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { bool fullShuffle = false; if (terms != null && terms.Length >= 1 && terms.Contains("eh")) { fullShuffle = true; } DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms); string deckTypeString = Utils.GetDeckTypeStringHidePlaying(deckType, characterName); string customDeckName = Utils.GetCustomDeckName(characterName); bot.DiceBot.ShuffleDeck(bot.DiceBot.random, channel, deckType, fullShuffle, customDeckName); bot.SendMessageInChannel("[i]" + deckTypeString + "Channel deck shuffled. " + (fullShuffle ? "Hands emptied." : "") + "[/i]", channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { string messageString = ""; if (terms.Length < 2) { messageString = "Error: This command requires a number (first) and a user name (second)."; } else { bool all = false; int giveAmount = Utils.GetNumberFromInputs(rawTerms); string[] rawTermsMost = new string[rawTerms.Length - 1]; for (int i = 1; i < rawTerms.Length; i++) { rawTermsMost[i - 1] = rawTerms[i]; } string targetUserName = Utils.GetFullStringOfInputs(rawTermsMost).Trim(); if (giveAmount <= 0 && !all) { messageString = "Error: You must input a number to give an amount of chips."; } else { messageString = bot.DiceBot.GiveChips(characterName, targetUserName, channel, giveAmount, all); commandController.SaveChipsToDisk(); } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; if (terms.Length < 1) { messageString = "Error: This command requires a game name."; } else { IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); if (gametype == null) { messageString = "Error: Game type not found."; } else { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype, false); if (sesh != null) { double secondsRemain = bot.DiceBot.GetSecondsRemainingOnCountdownTimer(channel, gametype.GetGameName()); messageString = sesh.GetStatus(secondsRemain); } else { messageString = "Game session for " + gametype.GetGameName() + " not found or created."; } } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { if (BotMain._debug) { bot.SendMessageInChannel("Command recieved: " + Utils.PrintList(terms), channel); } bool debugOverride = false; string finalResult = bot.DiceBot.GetRollResult(terms, debugOverride); string userName = "******" + Utils.GetCharacterUserTags(characterName) + "[/i]: "; bot.SendMessageInChannel(userName + finalResult, channel); if (BotMain._debug) { Console.WriteLine("Command finished: " + finalResult); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { string messageString = ""; if (terms.Length < 1) { messageString = "Error: This command requires a number."; } else { bool pot = false; int chipAmount = Utils.GetNumberFromInputs(terms); if (terms != null && terms.Length >= 1 && terms.Contains("pot")) { pot = true; } messageString = ""; if (chipAmount <= 0) { messageString = "Error: You must specify a number of chips above 0 to remove."; } else { messageString = bot.DiceBot.AddChips(characterName, channel, -1 * chipAmount, pot); commandController.SaveChipsToDisk(); } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms); string customDeckName = Utils.GetCustomDeckName(characterName); string deckTypeString = Utils.GetDeckTypeStringHidePlaying(deckType, customDeckName); Deck a = bot.DiceBot.GetDeck(channel, deckType, customDeckName); string sendString = ""; if (a != null) { sendString = "[i]" + deckTypeString + "Channel deck contents: [/i]" + a.ToString(); } else { sendString = "[i]Error: " + deckTypeString + " deck not found[/i]"; } bot.SendMessageInChannel(sendString, channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { string messageText = "[b]General Commands:[/b]\n!roll, !fitd" + "\n!drawcard, !resetdeck, !shuffledeck, !endhand, !showhand, !discardcard, !takefromdiscard, !deckinfo, !playcard, !takefromplay, !discardfromplay, !playfromdiscard\n" + "!register, !addchips, !showchips, !givechips, !bet, !claimpot, !removepile, !takechips, !redeemchips, !removechips\n" + "!joinchannel, !leavethischannel\n!botinfo, !uptime, !help\n" + "!rolltable, !savetable, !deletetable, !tableinfo\n" + "!joingame, !leavegame, !cancelgame, !startgame, !gamestatus, !gamecommand, !gc\n" + "[b]Channel Op only Commands:[/b]\n" + "!removeallpiles, !setstartingchannel, !updatesetting, !viewsettings\n" + "For full information on commands, see the profile [user]Dice Bot[/user]."; if (string.IsNullOrEmpty(channel)) { bot.SendPrivateMessage(messageText + "\nMost of [user]Dice Bot[/user]'s functions require it to be in a [b]channel[/b]. You can invite it to a private channel and then use [b]!joinchannel[/b] to test commands.", characterName); } else { bot.SendMessageInChannel(messageText, channel); } }
public void SendRightCommand() { var inputData = new BotCommandInputModel { Message = "/stock=aapl.us" }; var mockLogicMessage = new Mock <ILogicMessage>(); mockLogicMessage.Setup(x => x.CommandMessage(inputData.Message)).Returns(Task.FromResult("APPL.US quote is $93.42 per share”.")); var botCommandController = new BotCommandController ( mockLogicMessage.Object ); var result = botCommandController.Post(inputData); Assert.IsInstanceOfType(result.Result, typeof(OkObjectResult)); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowTableRolls) { bool includeLabel = true; bool secondaryRolls = true; if (terms != null && terms.Length >= 1 && terms.Contains("nolabel")) { includeLabel = false; } if (terms != null && terms.Length >= 1 && terms.Contains("nosecondary")) { secondaryRolls = false; } int rollModifier = commandController.GetRollModifierFromCommandTerms(terms); string tableName = commandController.GetTableNameFromCommandTerms(terms); SavedRollTable savedTable = Utils.GetTableFromId(bot.SavedTables, tableName); if (savedTable.DefaultTable || thisChannel.AllowCustomTableRolls) { string sendMessage = bot.DiceBot.GetRollTableResult(bot.SavedTables, tableName, characterName, channel, rollModifier, includeLabel, secondaryRolls, 3); bot.SendMessageInChannel(sendMessage, channel); } else { bot.SendMessageInChannel("Only default talbes are allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms); string customDeckName = Utils.GetCustomDeckName(characterName); string deckTypeString = Utils.GetDeckTypeStringHidePlaying(deckType, customDeckName); Deck a = bot.DiceBot.GetDeck(channel, deckType, customDeckName); string sendString = ""; if (a != null) { string cardsString = a.GetCardsRemaining() + " / " + a.GetTotalCards(); string jokersString = a.ContainsJokers() ? " [i](contains jokers)[/i] " : ""; sendString = "[i]" + deckTypeString + "Channel deck cards remaining: [/i]" + cardsString + jokersString; } else { sendString = "[i]Error: " + deckTypeString + " deck not found[/i]"; } bot.SendMessageInChannel(sendString, channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { var thisCharacterTables = bot.SavedTables.Where(a => a.OriginCharacter == characterName); string sendMessage = "No tables found for " + Utils.GetCharacterUserTags(characterName); if (thisCharacterTables.Count() > 0) { string tablesList = ""; foreach (SavedRollTable savedTable in thisCharacterTables) { if (!string.IsNullOrEmpty(tablesList)) { tablesList += ", "; } tablesList += savedTable.TableId; } sendMessage = "Tables found for " + Utils.GetCharacterUserTags(characterName) + ": " + tablesList; } bot.SendMessageInChannel(sendMessage, channel); }
public static void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command, CardMoveType moveType) { CardCommandOptions options = new CardCommandOptions(commandController, terms, characterName); if (!(moveType == CardMoveType.DiscardCard || moveType == CardMoveType.PlayCard)) { options.redraw = false; } string customDeckString = Utils.GetCustomDeckName(characterName); string deckTypeString = Utils.GetDeckTypeStringHidePlaying(options.deckType, customDeckString); string cardDrawingCharacterString = Utils.GetCharacterStringFromSpecialName(options.characterDrawName); int numberDiscards = 0; string actionString = ""; switch (moveType) { case CardMoveType.DiscardCard: actionString = bot.DiceBot.DiscardCards(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards); break; case CardMoveType.PlayCard: actionString = bot.DiceBot.PlayCards(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards); break; case CardMoveType.ToHandFromDiscard: actionString = bot.DiceBot.TakeCardsFromDiscard(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards); break; case CardMoveType.ToPlayFromDiscard: actionString = bot.DiceBot.PlayCardsFromDiscard(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards); break; case CardMoveType.ToHandFromPlay: actionString = bot.DiceBot.TakeCardsFromPlay(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards); break; case CardMoveType.ToDiscardFromPlay: actionString = bot.DiceBot.DiscardCardsFromPlay(options.moveCardsList, options.all, channel, options.deckType, options.characterDrawName, out numberDiscards); break; } if (numberDiscards > 1 || numberDiscards == 0) { options.cardsS = "s"; } string messageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + options.cardsS + " " + Utils.GetCardMoveTypeString(moveType) + "[/i] " + actionString; string trueDraw = ""; string privateMessageDraw = ""; if (options.redraw) { messageOutput += "\n [i]Redrawn:[/i] " + bot.DiceBot.DrawCards(numberDiscards, options.jokers, options.deckDraw, channel, options.deckType, options.characterDrawName, options.secretDraw, out trueDraw); privateMessageDraw = "[i]Redrawn:[/i] " + trueDraw; } if (options.secretDraw && options.redraw && !(options.characterDrawName == DiceBot.DealerName || options.characterDrawName == DiceBot.BurnCardsName || options.characterDrawName == DiceBot.DiscardName)) { bot.SendPrivateMessage(privateMessageDraw, characterName); } if (options.secretDraw) { string redrawSecretString = options.redraw ? " (and redrew)" : ""; string newMessageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + numberDiscards + " Card" + options.cardsS + " " + Utils.GetCardMoveTypeString(moveType) + " (secret)" + redrawSecretString + "[/i] "; bot.SendMessageInChannel(newMessageOutput, channel); } else { bot.SendMessageInChannel(messageOutput, channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { bot.SendMessageInChannel("Goodbye~", channel); bot.LeaveChannel(channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { GameCommand c = new GameCommand(); c.Run(bot, commandController, rawTerms, terms, characterName, channel, command); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); if (gametype == null) { //TODO: make this code somewhere else - it's repeated in many game commands //check game sessions and see if this channel has a session for anything var gamesParticipated = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel && a.Players.Contains(characterName)); if (gamesParticipated.Count() == 0) { messageString = "Error: Game type not found."; } else if (gamesParticipated.Count() > 1) { messageString = "Error: You must specify a game type if you are in more than one game."; } else if (gamesParticipated.Count() == 1) { GameSession sesh = gamesParticipated.First(); gametype = sesh.CurrentGame; } } if (gametype != null) { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype, false); if (sesh != null) { if (!sesh.Players.Contains(characterName)) { messageString = Utils.GetCharacterUserTags(characterName) + " has not joined " + sesh.CurrentGame.GetGameName() + "."; } else { messageString = bot.DiceBot.LeaveGame(characterName, channel, gametype); messageString += "\n" + sesh.Players.Count + " / " + sesh.CurrentGame.GetMaxPlayers() + " players ready."; if (sesh.CurrentGame.GetType() == typeof(Roulette)) { sesh.RemoveRouletteBet(characterName); } if (sesh.Players.Count >= sesh.CurrentGame.GetMinPlayers()) { messageString += "[b] (Ready to start!)[/b]"; } } } else { messageString = "Error: Game session for " + gametype.GetGameName() + " not found or created."; } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { MoveCards.Run(bot, commandController, rawTerms, terms, characterName, channel, command, CardMoveType.ToDiscardFromPlay); //bool all = false; //bool redraw = false; //bool secretDraw = false; //string characterDrawName = commandController.GetCharacterDrawNameFromCommandTerms(characterName, terms); //if (characterDrawName == DiceBot.DiscardName) // characterDrawName = characterName; //if (terms != null && terms.Length >= 1 && terms.Contains("all")) // all = true; //if (terms != null && terms.Length >= 1 && terms.Contains("redraw")) // redraw = true; //if (terms != null && terms.Length >= 1 && (terms.Contains("s") || terms.Contains("secret"))) // secretDraw = true; //List<int> discardsTemp = Utils.GetAllNumbersFromInputs(terms); //List<int> discards = new List<int>(); ////decrease all the numbers by 1 to match array indexes, rather than the card position for a player //if (discardsTemp.Count > 0) //{ // foreach (int i in discardsTemp) // { // discards.Add(i - 1); // } //} //string cardsS = ""; //if (discards.Count > 1) // cardsS = "s"; //DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms); //string deckTypeString = Utils.GetDeckTypeStringHidePlaying(deckType); //string cardDrawingCharacterString = Utils.GetCharacterStringFromSpecialName(characterDrawName); //int numberDiscards = 0; //string messageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + cardsS + " discarded from play:[/i] " + bot.DiceBot.DiscardCardsFromPlay(discards, all, channel, deckType, characterDrawName, out numberDiscards); //if (redraw) //{ // string trueDraw = ""; // messageOutput += "\n [i]Redrawn:[/i] " + bot.DiceBot.DrawCards(numberDiscards, false, true, channel, deckType, characterDrawName, secretDraw, out trueDraw); //} //if (secretDraw && !(characterDrawName == DiceBot.DealerName || characterDrawName == DiceBot.BurnCardsName)) //{ // bot.SendPrivateMessage(messageOutput, characterName); //} //if (secretDraw) //{ // string redrawSecretString = redraw ? " (and redrew)" : ""; // string newMessageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + cardsS + " discarded from play: (secret)" + redrawSecretString + "[/i] "; // bot.SendMessageInChannel(newMessageOutput, channel); //} //else //{ // bot.SendMessageInChannel(messageOutput, channel); //} }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; if (terms.Length < 1) { messageString = "Error: This command requires a game name."; } else { IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); if (gametype == null) { //check game sessions and see if this channel has a session for anything var gamesPresent = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel); if (gamesPresent.Count() == 0) { messageString = "Error: No game sessions are active in this channel to cancel."; } else if (gamesPresent.Count() > 1) { messageString = "Error: You must specify a game type if more than one game session exists in the channel."; } else if (gamesPresent.Count() == 1) { GameSession sesh = gamesPresent.First(); gametype = sesh.CurrentGame; } } if (gametype == null) { messageString = "Error: Game type not found."; } else { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype, false); if (sesh != null) { messageString = bot.DiceBot.IssueGameCommand(characterName, channel, sesh, terms); } else { messageString = "Game session for " + gametype.GetGameName() + " not found or created."; } } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { string saveJson = Utils.GetFullStringOfInputs(rawTerms); string sendMessage = ""; try { //accept JSON format deck SavedDeck d = JsonConvert.DeserializeObject <SavedDeck>(saveJson); FChatDicebot.DiceFunctions.Deck newDeck = new DiceFunctions.Deck(DiceFunctions.DeckType.Custom); newDeck.CreateFromDeckList(d.DeckList); string newDeckId = Utils.GetCustomDeckName(characterName); var thisCharacterDecks = bot.SavedDecks.Where(a => a.OriginCharacter == characterName); SavedDeck existingDeck = Utils.GetDeckFromId(bot.SavedDecks, newDeckId); if (thisCharacterDecks.Count() >= BotMain.MaximumSavedTablesPerCharacter && existingDeck == null) { sendMessage = "Failed: A character can only save up to 3 decks at one time. Delete or overwrite old decks."; } else if (existingDeck != null && existingDeck.OriginCharacter != characterName) { sendMessage = "Failed: This table name is taken by a different character."; } else if (newDeckId.Length < 2) { sendMessage = "Failed: Deck name too short."; } else if (newDeck.GetTotalCards() <= 0) { sendMessage = "Failed: No card entries found for this deck."; } else if (newDeck.GetTotalCards() > BotMain.MaximumCardsInDeck) { sendMessage = "Failed: Deck contains more than " + BotMain.MaximumCardsInDeck + " cards."; } else { SavedDeck newSavedDeck = new SavedDeck() { DeckList = newDeck.GetDeckList(), DeckId = newDeckId, OriginCharacter = characterName }; if (existingDeck != null) { existingDeck.Copy(newSavedDeck); } else { bot.SavedDecks.Add(newSavedDeck); } Utils.WriteToFileAsData(bot.SavedDecks, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.SavedDecksFileName)); bot.DiceBot.ResetDeck(false, channel, DeckType.Custom, newDeckId); sendMessage = "[b]Success[/b]. Deck saved by [user]" + characterName + "[/user]. Draw from this deck using !drawcard custom"; } } catch (Exception) { sendMessage = "Failed to parse deck entry data. Make sure the Json is correctly formatted."; } bot.SendMessageInChannel(sendMessage, channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { string saveJson = Utils.GetFullStringOfInputs(rawTerms); string sendMessage = ""; try { FChatDicebot.DiceFunctions.RollTable newTable = JsonConvert.DeserializeObject <FChatDicebot.DiceFunctions.RollTable>(saveJson); newTable.Name = Utils.LimitStringToNCharacters(newTable.Name, BotMain.MaximumCharactersTableName); string newTableId = newTable.Name.Replace(" ", "").ToLower(); newTable.Description = Utils.LimitStringToNCharacters(newTable.Description, BotMain.MaximumCharactersTableDescription); var thisCharacterTables = bot.SavedTables.Where(a => a.OriginCharacter == characterName); SavedRollTable existingTable = Utils.GetTableFromId(bot.SavedTables, newTableId); if (thisCharacterTables.Count() >= BotMain.MaximumSavedTablesPerCharacter && existingTable == null) { sendMessage = "Failed: A character can only save up to 3 tables at one time. Delete or overwrite old tables."; } else if (existingTable != null && existingTable.OriginCharacter != characterName) { sendMessage = "Failed: This table name is taken by a different character."; } else if (newTableId.Length < 2) { sendMessage = "Failed: Table name too short."; } else if (newTable.TableEntries == null) { sendMessage = "Failed: No table entries found for this table."; } else if (newTable.TableEntries.Count > BotMain.MaximumSavedEntriesPerTable) { sendMessage = "Failed: Table contains more than " + BotMain.MaximumSavedEntriesPerTable + " entries."; } else { foreach (FChatDicebot.DiceFunctions.TableEntry t in newTable.TableEntries) { t.Name = Utils.LimitStringToNCharacters(t.Name, BotMain.MaximumCharactersTableName); t.Description = Utils.LimitStringToNCharacters(t.Description, BotMain.MaximumCharactersTableEntryDescription); if (t.Triggers != null && t.Triggers.Count > BotMain.MaximumRollTriggersPerEntry) { t.Triggers = t.Triggers.Take(BotMain.MaximumRollTriggersPerEntry).ToList(); } } SavedRollTable newSavedRollTable = new SavedRollTable() { Table = newTable, OriginCharacter = characterName, DefaultTable = false, TableId = newTableId }; if (existingTable != null) { existingTable.Copy(newSavedRollTable); } else { bot.SavedTables.Add(newSavedRollTable); } Utils.WriteToFileAsData(bot.SavedTables, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.SavedTablesFileName)); sendMessage = "[b]Success[/b]. Table saved by [user]" + characterName + "[/user]. Roll on this table using !rolltable " + newTableId; } } catch (Exception) { sendMessage = "Failed to parse table entry data. Make sure the Json is correctly formatted."; } bot.SendMessageInChannel(sendMessage, channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); bool keepSession = terms.Contains("keepsession") || terms.Contains("keepgame"); bool endSession = terms.Contains("endsession") || terms.Contains("endgame"); if (gametype == null) { //check game sessions and see if this channel has a session for anything var gamesParticipated = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel && a.Players.Contains(characterName)); if (gamesParticipated.Count() == 0) { messageString = "Error: Game type not found."; } else if (gamesParticipated.Count() > 1) { messageString = "Error: You must specify a game type if you are in more than one game."; } else if (gamesParticipated.Count() == 1) { GameSession sesh = gamesParticipated.First(); gametype = sesh.CurrentGame; } } if (gametype != null) //gametype can be set above after being null so this should no longer be 'else' { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype); if (sesh != null) { ChipPile potChips = bot.DiceBot.GetChipPile(DiceBot.PotName, channel); if (sesh.Ante > 0 && potChips.Chips > 0) { messageString = "The pot already has chips in it. The pot must be empty before starting a game with ante."; } else if (sesh.CurrentGame.GetMinPlayers() > sesh.Players.Count) { messageString = "Cannot start " + sesh.CurrentGame.GetGameName() + " because there are currently less than [b]" + sesh.CurrentGame.GetMinPlayers() + " players[/b]."; } else if (sesh.State == GameState.GameInProgress) { messageString = "Cannot start " + sesh.CurrentGame.GetGameName() + " because the game is already in progress. Please finish the current round first."; } else if (sesh.CurrentGame.GetType() == typeof(Roulette) && !bot.DiceBot.CountdownFinishedOrNotStarted(channel, sesh.CurrentGame.GetGameName())) { double secondsRemain = bot.DiceBot.GetSecondsRemainingOnCountdownTimer(channel, gametype.GetGameName()); messageString = "Cannot start " + sesh.CurrentGame.GetGameName() + " because the starting countdown is not yet finished. [b]" + secondsRemain.ToString("N3") + " seconds [/b]remain."; } else { messageString = sesh.CurrentGame.GetStartingDisplay(); messageString += "\n" + bot.DiceBot.StartGame(channel, gametype, bot, keepSession, endSession); if (sesh.CurrentGame.GetType() == typeof(Roulette)) { bot.DiceBot.StartCountdownTimer(channel, gametype.GetGameName(), characterName, 5 * 60 * 1000); } commandController.SaveChipsToDisk(); } } else { messageString = "Error: Game session for " + gametype.GetGameName() + " not found or created."; } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public virtual void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; int ante = Utils.GetNumberFromInputs(terms); if (ante < 0) { ante = 0; } if (ante > 0 && !thisChannel.AllowChips) { messageString = Name + " [b]with chips[/b] is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel."; } else { IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); if (gametype == null) { //check game sessions and see if this channel has a session for anything var gamesPresent = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel); if (gamesPresent.Count() == 0) { messageString = "Error: No game type specified. [i]You must create a game session by specifying the game type as the first player.[/i]"; } else if (gamesPresent.Count() > 1) { messageString = "Error: You must specify a game type if more than one game session exists in the channel."; } else if (gamesPresent.Count() == 1) { GameSession sesh = gamesPresent.First(); gametype = sesh.CurrentGame; } } if (gametype != null) { if (!gametype.AllowAnte() && ante > 0) { messageString = Name + " cannot be played with ante. Try joining the game without an ante amount."; } else { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype); if (sesh != null) { ChipPile characterChips = bot.DiceBot.GetChipPile(characterName, channel); if (sesh.Players.Contains(characterName)) { messageString = Utils.GetCharacterUserTags(characterName) + " is already in " + sesh.CurrentGame.GetGameName() + "."; } else if (sesh.Players.Count > sesh.CurrentGame.GetMaxPlayers()) { messageString = Utils.GetCharacterUserTags(characterName) + " cannot join " + sesh.CurrentGame.GetGameName() + " because it is already at the [b]maximum amount of players[/b]."; } else if (ante > 0 && characterChips.Chips < ante) { messageString = Utils.GetCharacterUserTags(characterName) + " cannot make a bet for " + ante + " because they do not have enough chips."; } else { //TODO: change game join logic so that each game uses its own method to verify and add players if (gametype.GetType() == typeof(Roulette)) { #region gametype roulette RouletteBet betType = RouletteBet.NONE; int betNumber = -1; if (terms.Contains("red")) { betType = RouletteBet.Red; } else if (terms.Contains("black")) { betType = RouletteBet.Black; } else if (terms.Contains("even")) { betType = RouletteBet.Even; } else if (terms.Contains("odd")) { betType = RouletteBet.Odd; } else if (terms.Contains("first12")) { betType = RouletteBet.First12; } else if (terms.Contains("second12")) { betType = RouletteBet.Second12; } else if (terms.Contains("third12")) { betType = RouletteBet.Third12; } else if (terms.Contains("firsthalf")) { betType = RouletteBet.OneToEighteen; } else if (terms.Contains("secondhalf")) { betType = RouletteBet.NineteenToThirtySix; } else if (terms.Contains("#1")) { betType = RouletteBet.SpecificNumber; betNumber = 1; } else if (terms.Contains("#2")) { betType = RouletteBet.SpecificNumber; betNumber = 2; } else if (terms.Contains("#3")) { betType = RouletteBet.SpecificNumber; betNumber = 3; } else if (terms.Contains("#4")) { betType = RouletteBet.SpecificNumber; betNumber = 4; } else if (terms.Contains("#5")) { betType = RouletteBet.SpecificNumber; betNumber = 5; } else if (terms.Contains("#6")) { betType = RouletteBet.SpecificNumber; betNumber = 6; } else if (terms.Contains("#7")) { betType = RouletteBet.SpecificNumber; betNumber = 7; } else if (terms.Contains("#8")) { betType = RouletteBet.SpecificNumber; betNumber = 8; } else if (terms.Contains("#9")) { betType = RouletteBet.SpecificNumber; betNumber = 9; } else if (terms.Contains("#10")) { betType = RouletteBet.SpecificNumber; betNumber = 10; } else if (terms.Contains("#11")) { betType = RouletteBet.SpecificNumber; betNumber = 11; } else if (terms.Contains("#12")) { betType = RouletteBet.SpecificNumber; betNumber = 12; } else if (terms.Contains("#13")) { betType = RouletteBet.SpecificNumber; betNumber = 13; } else if (terms.Contains("#14")) { betType = RouletteBet.SpecificNumber; betNumber = 14; } else if (terms.Contains("#15")) { betType = RouletteBet.SpecificNumber; betNumber = 15; } else if (terms.Contains("#16")) { betType = RouletteBet.SpecificNumber; betNumber = 16; } else if (terms.Contains("#17")) { betType = RouletteBet.SpecificNumber; betNumber = 17; } else if (terms.Contains("#18")) { betType = RouletteBet.SpecificNumber; betNumber = 18; } else if (terms.Contains("#19")) { betType = RouletteBet.SpecificNumber; betNumber = 19; } else if (terms.Contains("#20")) { betType = RouletteBet.SpecificNumber; betNumber = 20; } else if (terms.Contains("#21")) { betType = RouletteBet.SpecificNumber; betNumber = 21; } else if (terms.Contains("#22")) { betType = RouletteBet.SpecificNumber; betNumber = 22; } else if (terms.Contains("#23")) { betType = RouletteBet.SpecificNumber; betNumber = 23; } else if (terms.Contains("#24")) { betType = RouletteBet.SpecificNumber; betNumber = 24; } else if (terms.Contains("#25")) { betType = RouletteBet.SpecificNumber; betNumber = 25; } else if (terms.Contains("#26")) { betType = RouletteBet.SpecificNumber; betNumber = 26; } else if (terms.Contains("#27")) { betType = RouletteBet.SpecificNumber; betNumber = 27; } else if (terms.Contains("#28")) { betType = RouletteBet.SpecificNumber; betNumber = 28; } else if (terms.Contains("#29")) { betType = RouletteBet.SpecificNumber; betNumber = 29; } else if (terms.Contains("#30")) { betType = RouletteBet.SpecificNumber; betNumber = 30; } else if (terms.Contains("#31")) { betType = RouletteBet.SpecificNumber; betNumber = 31; } else if (terms.Contains("#32")) { betType = RouletteBet.SpecificNumber; betNumber = 32; } else if (terms.Contains("#33")) { betType = RouletteBet.SpecificNumber; betNumber = 33; } else if (terms.Contains("#34")) { betType = RouletteBet.SpecificNumber; betNumber = 34; } else if (terms.Contains("#35")) { betType = RouletteBet.SpecificNumber; betNumber = 35; } else if (terms.Contains("#36")) { betType = RouletteBet.SpecificNumber; betNumber = 36; } if (betType == RouletteBet.NONE) { messageString = "No bet type was found in the [b]!joingame " + sesh.CurrentGame.GetGameName() + "[/b] command. Try adding a bet amount and a bet type."; } else if (ante <= 0) { messageString = "No bet amount was found in the [b]!joingame " + sesh.CurrentGame.GetGameName() + "[/b] command. Try adding a bet amount and a bet type."; } else { RouletteBetData betData = new RouletteBetData() { bet = betType, specificNumberBet = betNumber, characterName = characterName, amount = ante }; string timerString = ""; double secondsRemain = bot.DiceBot.GetSecondsRemainingOnCountdownTimer(channel, gametype.GetGameName()); if (secondsRemain > 0) { timerString = "[i] (game can begin in " + secondsRemain.ToString("N3") + " seconds)[/i]"; } string addDataString = bot.DiceBot.AddGameData(channel, gametype, betData); if (addDataString != "success") { messageString = "Error: Failed to add bet data to game session for " + gametype.GetGameName() + ". Game session terminated."; bot.DiceBot.CancelGame(channel, gametype); } else { messageString = bot.DiceBot.JoinGame(characterName, channel, gametype); messageString += "\n" + sesh.Players.Count + " / " + sesh.CurrentGame.GetMaxPlayers() + " players ready."; if (!string.IsNullOrEmpty(timerString)) { messageString += timerString; } else if (sesh.Players.Count >= sesh.CurrentGame.GetMinPlayers()) { messageString += "[b] (Ready to start!)[/b]"; } } } #endregion } else { bool anteJustSet = false; if (!sesh.AnteSet) //leave as separate if { sesh.AnteSet = true; anteJustSet = true; sesh.Ante = ante > 0 ? ante : 0; } if (anteJustSet && ante > 0 && characterChips.Chips < sesh.Ante) { messageString = Utils.GetCharacterUserTags(characterName) + " does not have [b]" + ante + " chips[/b] to start a game with an ante this high."; bot.DiceBot.RemoveGameSession(channel, sesh.CurrentGame); } else if (sesh.AnteSet && ante > 0 && sesh.Ante != ante) { messageString = "The ante for " + sesh.CurrentGame.GetGameName() + " has already been set to something else. Use [b]!joingame " + sesh.CurrentGame.GetGameName() + "[/b] without an ante."; } else if (characterChips.Chips < sesh.Ante) { messageString = Utils.GetCharacterUserTags(characterName) + " cannot join " + sesh.CurrentGame.GetGameName() + " because they have less than the ante amount of [b]" + sesh.Ante + " chips.[/b]"; } else if (sesh.Players.Contains(characterName)) { messageString = Utils.GetCharacterUserTags(characterName) + " is already in " + sesh.CurrentGame.GetGameName() + "."; } else if (sesh.Players.Count > sesh.CurrentGame.GetMaxPlayers()) { messageString = Utils.GetCharacterUserTags(characterName) + " cannot join " + sesh.CurrentGame.GetGameName() + " because it is already at the [b]maximum amount of players[/b]."; } else { messageString = bot.DiceBot.JoinGame(characterName, channel, gametype); messageString += "\n" + sesh.Players.Count + " / " + sesh.CurrentGame.GetMaxPlayers() + " players ready."; if (sesh.Players.Count >= sesh.CurrentGame.GetMinPlayers()) { messageString += "[b] (Ready to start!)[/b]"; } } } }//end too many players or player already joined } else { messageString = "Error: Game session for " + gametype.GetGameName() + " not found or created."; } //end game session null } } //end if gametype != null } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { SettingType changed = SettingType.NONE; ChannelSettings thisChannel = bot.GetChannelSettings(channel); bool setValue = false; if (terms != null && terms.Length >= 1) { if (terms.Contains("useeicons")) changed = SettingType.UseEicons; if (terms.Contains("greetnewusers")) changed = SettingType.GreetNewUsers; if (terms.Contains("allowtablerolls")) changed = SettingType.AllowTableRolls; if (terms.Contains("allowcustomtablerolls")) changed = SettingType.AllowCustomTableRolls; if (terms.Contains("allowtableinfo")) changed = SettingType.AllowTableInfo; if (terms.Contains("allowchips")) changed = SettingType.AllowChips; if (terms.Contains("allowgames")) changed = SettingType.AllowGames; if (terms.Contains("usevcaccount")) changed = SettingType.UseVcAccountForChips; if (terms.Contains("startupchannel")) changed = SettingType.StartupChannel; if (terms.Contains("startwith500chips")) changed = SettingType.StartWith500Chips; if (terms.Contains("onlyopaddchips")) changed = SettingType.OnlyOpAddChips; if (terms.Contains("onlyopbotcommands")) changed = SettingType.OnlyOpBotCommands; if (terms.Contains("onlyopdeckcontrols")) changed = SettingType.OnlyOpDeckControls; if (terms.Contains("onlyoptablecommands")) changed = SettingType.OnlyOpTableCommands; if (terms.Contains("on") || terms.Contains("true")) setValue = true; if (terms.Contains("off") || terms.Contains("false")) setValue = false; } switch (changed) { case SettingType.NONE: break; case SettingType.UseEicons: thisChannel.UseEicons = setValue; break; case SettingType.GreetNewUsers: thisChannel.GreetNewUsers = setValue; break; case SettingType.AllowTableRolls: thisChannel.AllowTableRolls = setValue; break; case SettingType.AllowCustomTableRolls: thisChannel.AllowCustomTableRolls = setValue; break; case SettingType.AllowTableInfo: thisChannel.AllowTableInfo = setValue; break; case SettingType.AllowChips: thisChannel.AllowChips = setValue; break; case SettingType.AllowGames: thisChannel.AllowGames = setValue; break; case SettingType.UseVcAccountForChips: thisChannel.UseVcAccountForChips = setValue; break; case SettingType.StartupChannel: thisChannel.StartupChannel = setValue; break; case SettingType.StartWith500Chips: thisChannel.StartWith500Chips = setValue; break; case SettingType.OnlyOpAddChips: { if(thisChannel.ChipsClearance != ChipsClearanceLevel.DicebotAdmin) { if(setValue) { thisChannel.ChipsClearance = ChipsClearanceLevel.ChannelOp; } else { thisChannel.ChipsClearance = ChipsClearanceLevel.NONE; } } } break; case SettingType.OnlyOpBotCommands: thisChannel.OnlyChannelOpsCanUseAnyBotCommands = setValue; break; case SettingType.OnlyOpDeckControls: thisChannel.OnlyChannelOpsCanUseDeckControls = setValue; break; case SettingType.OnlyOpTableCommands: thisChannel.OnlyChannelOpsCanUseTableCommands = setValue; break; } if (changed == SettingType.NONE) { string output = "Setting not found. Be sure to specify which setting to change, followed by 'true' or 'false'. Settings use the same name displayed in the !viewsettings command."; bot.SendMessageInChannel(output, channel); } else { Utils.WriteToFileAsData(bot.SavedChannelSettings, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.ChannelSettingsFileName)); string output = "(Channel setting updated) " + Utils.GetCharacterUserTags(characterName) + " set " + changed + " to " + setValue; if (changed == SettingType.OnlyOpAddChips && thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin) { output = "(" + changed + " Channel setting cannot be updated for this channel) "; } bot.SendMessageInChannel(output, channel); } }