void Observe(TwitchChatRoom room, TwitchUser speaker, string message)
 {
     foreach (var observer in observers)
     {
         observer(room, speaker, message);
     }
 }
        public void Run()
        {
            Thread[] ircThreads = null;
            rooms = null;

            var bots = factory.GetAllBots();

            foreach (var bot in bots)
            {
                var connections = factory.GetAllAutoConnectingConnections(bot);
                if (connections != null && connections.Length > 0)
                {
                    var chatConnection    = new TwitchIrcConnection(factory, bot, false);
                    var whisperConnection = new TwitchIrcConnection(factory, bot, true);

                    foreach (var connection in connections)
                    {
                        var room = new TwitchChatRoom(factory, chatConnection, whisperConnection, connection);
                        rooms = rooms.Append(room);
                    }

                    ircThreads = ircThreads.Append(new[] {
                        new Thread(whisperConnection.Run),
                        new Thread(chatConnection.Run)
                    });
                }
            }

            ircThreads.Run();
        }
Beispiel #3
0
        public void Run()
        {
            Thread[] ircThreads = null;
            rooms = null;

            var bots = SqlTwitchBot.GetAll();
            foreach(var bot in bots) {
                var connections = SqlTwitchConnection.GetAllAutoConnectingConnections(bot);
                if(connections != null && connections.Length > 0) {
                    var chatConnection = new TwitchIrcConnection(bot, false);
                    var whisperConnection = new TwitchIrcConnection(bot, true);

                    foreach(var connection in connections) {
                        var room = new TwitchChatRoom(chatConnection, whisperConnection, connection);
                        rooms = rooms.Append(room);
                    }

                    ircThreads = ircThreads.Append(new[] {
                        new Thread(whisperConnection.Run),
                        new Thread(chatConnection.Run)
                        });
                }
            }

            ircThreads.Run();
        }
 public DynamicCommands(TwitchChatRoom room)
     : base(room)
 {
     var commands = room.factory.GetAllCommands(room.twitchConnection);
     foreach(var command in commands) {
         ChatCommand.Create(room, command.command, ActionWithStaticData<string, TwitchUser, string>.For(DynamicCommandResponse, command.response), command.description, null, command.isModOnly, command.coolDown, false);
     }
 }
Beispiel #5
0
 public ViewPoints(TwitchChatRoom room)
     : base(room)
 {
     ChatCommand.Create(room, "points", PointCommand, "View how many points you, or another user, has. !points <username>", new[] { "point", "kappas" }, false, TimeSpan.FromSeconds(30), true);
     ChatCommand.Create(room, "brag", BragCommand, "Shows everyone how many points you have.  This costs 50 to run.", null, false, TimeSpan.FromMinutes(1), true);
     ChatCommand.Create(room, "leaderboard", LeaderboardCommand, "Displays the peeps with the most points.", null, false, TimeSpan.FromMinutes(2), false);
     ChatCommand.Create(room, "aboutpoints", AboutPointsCommand, "Displays the point units and values.", null, false, TimeSpan.FromMinutes(2), true);
 }
        internal static List<ChatCommand> ForRoom(TwitchChatRoom room)
        {
            List<ChatCommand> commands;
            if(roomCommands.TryGetValue(room.twitchConnection.channel, out commands)) {
                return commands;
            }

            return null;
        }
Beispiel #7
0
        public DynamicCommands(TwitchChatRoom room) : base(room)
        {
            var commands = room.factory.GetAllCommands(room.twitchConnection);

            foreach (var command in commands)
            {
                ChatCommand.Create(room, command.command, ActionWithStaticData <string, TwitchUser, string> .For(DynamicCommandResponse, command.response), command.description, null, command.isModOnly, command.coolDown, false);
            }
        }
 public PointCommands(TwitchChatRoom room) : base(room)
 {
     ChatCommand.Create(room, "points", PointCommand, "View how many points you, or another user, has. !points <username>", new[] { "point", "kappas" }, false, TimeSpan.FromSeconds(30), true);
     ChatCommand.Create(room, "brag", BragCommand, "Shows everyone how many points you have.  This costs 50 to run.", null, false, TimeSpan.FromMinutes(1), true);
     ChatCommand.Create(room, "leaderboard", LeaderboardCommand, "Displays the peeps with the most points.", null, false, TimeSpan.FromMinutes(2), false);
     ChatCommand.Create(room, "aboutpoints", AboutPointsCommand, "Displays the point units and values.", null, false, TimeSpan.FromMinutes(2), true);
     ChatCommand.Create(room, "givepoints", GivePointsCommand, "Gives someone points from your account.", null, false, TimeSpan.FromMinutes(2), true);
     ChatCommand.Create(room, "awardpoints", AwardPointsCommand, "Gives someone points from the house.", null, true, TimeSpan.FromMinutes(2), true);
 }
Beispiel #9
0
        public static List <ChatCommand> ForRoom(TwitchChatRoom room)
        {
            List <ChatCommand> commands;

            if (roomCommands.TryGetValue(room.twitchConnection.channel, out commands))
            {
                return(commands);
            }

            return(null);
        }
Beispiel #10
0
        public static ChatCommand Create(TwitchChatRoom room, string name, Action <TwitchUser, 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))
            {
                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);
        }
        ChatCommand(TwitchChatRoom room, string name, Action<SqlTwitchUser, string> action, string description, string[] aliases, bool modOnly, TimeSpan timeToThrottleFor, bool throttlePerUser, bool enabled)
            : base(room)
        {
            this.commandName = name;
            this.action = action;
            this.description = description;
            this.aliases = aliases;
            this.modOnly = modOnly;
            if(timeToThrottleFor > TimeSpan.FromSeconds(0)) {
                throttle = new Throttle(timeToThrottleFor);
            } else {
                throttle = null;
            }
            this.throttlePerUser = throttlePerUser;

            this.enabled = enabled;
        }
        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;
        }
Beispiel #13
0
        ChatCommand(TwitchChatRoom room, string name, Action <TwitchUser, string> action, string description, string[] aliases, bool modOnly, TimeSpan timeToThrottleFor, bool throttlePerUser, bool enabled) : base(room)
        {
            this.commandName = name;
            this.action      = action;
            this.description = description;
            this.aliases     = aliases;
            this.modOnly     = modOnly;
            if (timeToThrottleFor != null)
            {
                throttle = new Throttle(timeToThrottleFor);
            }
            else
            {
                throttle = null;
            }
            this.throttlePerUser = throttlePerUser;

            this.enabled = enabled;
        }
 static void Observe(TwitchChatRoom room, SqlTwitchUser speaker, string message)
 {
     foreach(var observer in observers) {
         observer(room, speaker, message);
     }
 }
 public TwitchRussianRoulette(TwitchChatRoom room) : base(room, typeof(RRStateOff))
 {
 }
 public TwitchGameStateMachine(TwitchChatRoom room, Type startingStateType) : base(room)
 {
     SetState(null, startingStateType);
 }
 internal void Join(TwitchChatRoom room)
 {
     ircClient.WriteLine("JOIN #" + room.twitchConnection.channel.user.userName);
     chatRooms.AddLast(room);
 }
Beispiel #18
0
        public TwitchHearthstone(TwitchChatRoom room) : base(room, typeof(HSStateOff))
        {
            HearthstoneEventObserver hearthObserver = new HearthstoneEventObserver(room.factory.CreateHearthstoneFactory());

            hearthObserver.RegisterObserver(HearthEvent);
        }
Beispiel #19
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);
 }
Beispiel #20
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);
 }
 public TwitchCommandController(TwitchChatRoom room)
 {
     this.room = room;
 }
 public TwitchCommandController(TwitchChatRoom room)
 {
     this.room = room;
 }
Beispiel #23
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);
 }
Beispiel #24
0
 public StrawPollCommands(TwitchChatRoom room) : base(room)
 {
     ChatCommand.Create(room, "getvote", GetVote, "Gets a strawpoll winner", new[] { "viewpoll" }, false, TimeSpan.FromSeconds(30), 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 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);
 }
 internal void Join(TwitchChatRoom room)
 {
     ircClient.WriteLine("JOIN #" + room.twitchConnection.channel.user.userName);
     chatRooms.AddLast(room);
 }
 public AboutCommands(TwitchChatRoom room) : base(room)
 {
     ChatCommand.Create(room, "commands", ListCommands, "Lists all active commands", null, false, null, false);
 }
 public AboutCommands(TwitchChatRoom room)
     : base(room)
 {
     ChatCommand.Create(room, "commands", ListCommands, "Lists all active commands", null, false, null, false);
 }
Beispiel #30
0
 public StrawPollCommands(TwitchChatRoom room)
     : base(room)
 {
     ChatCommand.Create(room, "getvote", GetVote, "Gets a strawpoll winner", null, false, TimeSpan.FromSeconds(30), false);
 }
Beispiel #31
0
 public TwitchGame(TwitchChatRoom room)
 {
     this.room = room;
     game      = new GameLogicController();
 }