Example #1
0
        public static ChatCommand Create(TwitchChatRoom room, string name, Action<SqlTwitchUser, string> action, string description, string[] aliases, bool modOnly, TimeSpan timeToThrottleFor, bool throttlePerUser, bool enabled = true)
        {
            List<ChatCommand> commands;
            if(roomCommands.TryGetValue(room.twitchConnection.channel, out commands)) {
                //foreach(var command in commands) {
                //	if(command.commandName.Equals(name)) {
                //		return command;
                //	}
                //}
            } else {
                commands = new List<ChatCommand>();
                roomCommands.Add(room.twitchConnection.channel, commands);
            }

            // TODO, ensure no name/alias conflicts
            var newCommand = new ChatCommand(room, name, action, description, aliases, modOnly, timeToThrottleFor, throttlePerUser, enabled);
             commands.Add(newCommand);
            return newCommand;
        }
Example #2
0
 protected override void OpenState()
 {
     if (controller.game.isReadyToStart)
     {
         controller.game.StartGame();
         if (controller.game.InsuranceAvailable())
         {
             insuranceCommand = AddCommand(controller.room, "insurance", BuyInsurance, "Buy insurance against dealer Blackjack", new[] { "buyinsurance" }, false);
             controller.room.SendChatMessage("Dealer has an Ace... !insurance anyone?");
             insuranceTimer.Start();
         }
         else
         {
             StartPlaying();
         }
     }
     else
     {
         controller.SetState(this, typeof(BJStateOff));
     }
 }
        void ListCommands(TwitchUser speaker, string additionalText)
        {
            var commands = ChatCommand.ForRoom(room);

            string chatMessage = "";

            if (commands != null)
            {
                foreach (var command in commands)
                {
                    if (!command.modOnly && command.enabled)
                    {
                        if (chatMessage.Length > 0)
                        {
                            chatMessage += ", ";
                        }
                        chatMessage += command.commandName;
                    }
                }
            }

            room.SendWhisper(speaker, chatMessage);
        }
Example #4
0
 public TwitchPickANumber(TwitchChatRoom room) : base(room)
 {
     ChatCommand.Create(room, "pick", PickCommand, "Pick a number 1-10... !pick <guess> for <bet amount>.", null, false, TimeSpan.FromSeconds(10), true);
 }
Example #5
0
 public TwitchHoldem(TwitchChatRoom room) : base(room, typeof(HoldemStateOff))
 {
     aboutCommand  = ChatCommand.Create(room, "aboutholdem", AboutHoldem, "How to play Texas Holdem", new[] { "aboutholdem", "howtoplayholdem", "howtoplayholdem" }, false, TimeSpan.FromMinutes(2), false);
     cancelCommand = ChatCommand.Create(room, "cancelholdem", CancelHoldem, "Cancels/ends any current games.  No money lost.", null, true, null, false);
 }
Example #6
0
 public StrawPollCommands(TwitchChatRoom room) : base(room)
 {
     ChatCommand.Create(room, "getvote", GetVote, "Gets a strawpoll winner", new[] { "viewpoll" }, false, TimeSpan.FromSeconds(30), false);
 }
Example #7
0
 public TwitchBlackjack(TwitchChatRoom room) : base(room, typeof(BJStateOff))
 {
     ChatCommand.Create(room, "aboutbj", AboutBJ, "How to play Blackjack", new[] { "aboutblackjack", "howtoplaybj", "howtoplayblackjack" }, false, TimeSpan.FromMinutes(2), false);
     ChatCommand.Create(room, "cancelbj", CancelBJ, "Cancels/ends any current games.  No money lost.", null, true, null, false);
 }
 public UserAccountManagementCommands(TwitchChatRoom room) : base(room)
 {
     ChatCommand.Create(room, "setgreeting", SetGreetingCommand, "Sets the welcome greeting message", null, false, null, false);
     ChatCommand.Create(room, "cleargreeting", ClearGreetingCommand, "Clears your greeting message", null, false, null, false);
 }
 public AboutCommands(TwitchChatRoom room) : base(room)
 {
     ChatCommand.Create(room, "commands", ListCommands, "Lists all active commands", null, false, null, false);
 }