Beispiel #1
0
        private void BuyInsurance(TwitchUser speaker, string arg2)
        {
            var player = GetPlayer(speaker);

            if (player != null)
            {
                if (player.BuyInsurance())
                {
                    controller.room.SendWhisper(speaker, "Purchased insurance.");

                    bool allDone = true;
                    foreach (var p in controller.game.GetPlayers())
                    {
                        if (!p.boughtInsurance)
                        {
                            allDone = false;
                            break;
                        }
                    }

                    if (allDone)
                    {
                        NoMoreInsurance();
                    }
                }
                else
                {
                    controller.room.SendWhisper(speaker, "You can't afford insurance.");
                }
            }
        }
Beispiel #2
0
        protected override void Init()
        {
            if (String.IsNullOrEmpty(CommandPrefix))
            {
                CommandPrefix = "!";
            }

            if (TextCommands == null)
            {
                TextCommands = new TextCommand[0];
            }
            if (Accounts == null)
            {
                Accounts = new TwitchAccount[0];
            }
            if (TwitchUsers == null)
            {
                TwitchUsers = new TwitchUser[0];
            }

            if (String.IsNullOrEmpty(SubMessageNew))
            {
                SubMessageNew = @"Thank you for the sub %name%! <3";
            }
            if (String.IsNullOrEmpty(SubMessageResub))
            {
                SubMessageResub = @"Thank you for the %months% sub, %name%! <3";
            }
            if (String.IsNullOrEmpty(CoinName))
            {
                CoinName = @"Coin(s)";
            }
        }
        public void Process(ITwitchChannelConnection connection, TwitchMessageData data)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            string channel = data.Params.ValueOrDefault(0) ?? connection.Channel;

            if (channel != connection.Channel)
            {
                return;
            }

            // Get formatted user information if possible.
            string name      = data.Tags.ValueOrDefault("display-name") ?? connection.Username;
            string colorText = data.Tags.ValueOrDefault("color") ?? "Black";

            // Try to get user color.
            Color color = Colors.Black;

            try { color = (Color)ColorConverter.ConvertFromString(colorText); }
            catch (FormatException) { }

            var user = new TwitchUser(name, true, color);

            OnAcquireUserState(user);
        }
        private void GivePointsCommand(TwitchUser speaker, string additionalText)
        {
            if (additionalText != null)
            {
                var otherUser = room.factory.GetUserFromName(additionalText.GetBefore(" "));
                if (otherUser != null)
                {
                    var amount = room.pointManager.GetPointsFromString(additionalText.GetAfter(" "));

                    if (amount > 0)
                    {
                        var myPoints    = room.pointManager.ForUser(speaker);
                        var otherPoints = room.pointManager.ForUser(otherUser);
                        if (myPoints.ReserveBet(amount, true) > 0)
                        {
                            otherPoints.Award(0, (long)amount);
                            myPoints.Award(amount, -1 * (long)amount);
                        }
                    }
                    else
                    {
                        room.SendWhisper(speaker, "How much?");
                    }
                }
                else
                {
                    room.SendWhisper(speaker, "Who are you giving points to?");
                }
            }
            else
            {
                room.SendWhisper(speaker, "Who and how much?");
            }
        }
        private void PointCommand(TwitchUser speaker, string message)
        {
            string otherUserName = message.GetBefore(" ");

            if (otherUserName == null)
            {
                otherUserName = message;
            }
            otherUserName = otherUserName?.Trim().ToLower();
            TwitchUser otherUser = room.factory.GetUserFromName(otherUserName);

            TwitchUserPointManager yourPoints = room.pointManager.ForUser(speaker);
            string chatMessage = "You have ";

            chatMessage += room.pointManager.ToPointsString(yourPoints.Points);

            if (otherUser != null && !otherUser.id.Equals(speaker.id))
            {
                TwitchUserPointManager otherPoints = room.pointManager.ForUser(otherUser);

                chatMessage += " & " + otherUser.name + " has " + room.pointManager.ToPointsString(otherPoints.Points);
            }

            room.SendWhisper(speaker, chatMessage);
        }
    private void OnChooseTeamReceived(TwitchUser _user, Teams _team)
    {
        if (!gameStarted)
        {
            return;
        }

        //Ist der User Bereits in einem team
        if (playerLists.SelectMany(pair => pair.Value).Any(teamMember => teamMember.twitchName == _user.DisplayName))
        {
            TwitchChatCommunicationManager.Instance.SendChatMessage($"{_user.DisplayName}, du gehörst bereits einem Team an!");
            return;
        }

        //Ist das gewünschte team bereits voll?
        if (playerLists[_team].Count >= maxTeamMembers)
        {
            TwitchChatCommunicationManager.Instance.SendChatMessage($"{_user.DisplayName}, Team {_team} ist bereits voll!");
            return;
        }

        Player player = new Player()
        {
            twitchName = _user.DisplayName, isDead = true, isSub = _user.IsSub, team = _team, twitchID = Convert.ToInt32(_user.Id), unitType = (UnitType)UnityEngine.Random.Range(0, 3)
        };

        if (!playerLists[_team].Add(player))
        {
            Debug.LogError($"Player {player.twitchName} already inside the team");
        }

        TwitchChatCommunicationManager.Instance.SendChatMessage($"{_user.DisplayName} ist dem Team { _team } beigetreten.");

        onPlayerCreated?.Invoke(player);
    }
Beispiel #7
0
 private void ModLeft(TwitchChannel conn, TwitchUser user)
 {
     if (user == CurrentUser)
     {
         ModButtonVisibility = Visibility.Collapsed;
     }
 }
 private void PlaceBet(TwitchUser speaker, string additionalText, bool toWin)
 {
     if(controller.game.Contains(speaker)) {
         var bettingPlayer = controller.game.GetPlayer(speaker);
         if(bettingPlayer.toWin == toWin) {
             ulong amount = controller.room.pointManager.GetPointsFromString(additionalText);
             amount = bettingPlayer.PlaceBet(amount, false);
             if(amount > 0) {
                 controller.room.SendWhisper(speaker, "You raised your bet " + controller.room.pointManager.ToPointsString(amount)
                     + " to " + controller.room.pointManager.ToPointsString(bettingPlayer.bet));
             } else {
                 // no more cash
             }
         } else {
             // no switching sides
         }
     } else {
         var bettingPlayer = new ParimutuelPlayer<TwitchUser>(controller.room.pointManager.ForUser(speaker), speaker, toWin);
         ulong amount = controller.room.pointManager.GetPointsFromString(additionalText);
         amount = bettingPlayer.PlaceBet(amount, false);
         if(amount > 0) {
             controller.game.Join(bettingPlayer);
             controller.room.SendWhisper(speaker, "You bet " + controller.room.pointManager.ToPointsString(amount));
         } else {
             // Broke dude.
         }
     }
 }
Beispiel #9
0
 public ChatMessage(DateTime time, TwitchUser user, Action action, string text = null)
 {
     m_time   = time;
     m_user   = user;
     m_text   = text;
     m_action = action;
 }
Beispiel #10
0
 public SqlTwitchUserPoints(TwitchUser user, TwitchChannel channel, ulong points = 0, DateTime timeOfLastBonus = default(DateTime))
     : base(new object[] { user.id, channel.user.id, points, timeOfLastBonus })
 {
     user.Save();
     this.user    = user;
     this.channel = channel;
 }
        private void ProcessSongRequest(TwitchUser requestor, string request)
        {
            if (!_requestTracker.ContainsKey(requestor.id))
            {
                _requestTracker.Add(requestor.id, new RequestUserTracker());
            }

            // Only rate limit users who aren't mods or the broadcaster
            if (!requestor.isMod && !requestor.isBroadcaster)
            {
                if (_requestTracker[requestor.id].resetTime <= DateTime.Now)
                {
                    _requestTracker[requestor.id].resetTime   = DateTime.Now.AddMinutes(Config.Instance.RequestCooldownMinutes);
                    _requestTracker[requestor.id].numRequests = 0;
                }
                if (_requestTracker[requestor.id].numRequests >= Config.Instance.RequestLimit)
                {
                    var time = (_requestTracker[requestor.id].resetTime - DateTime.Now);
                    QueueChatMessage($"{requestor.displayName}, you can make another request in{(time.Minutes > 0 ? $" {time.Minutes} minute{(time.Minutes > 1 ? "s" : "")}" : "")} {time.Seconds} second{(time.Seconds > 1 ? "s" : "")}.");
                    return;
                }
            }

            RequestInfo newRequest = new RequestInfo(requestor, request, _digitRegex.IsMatch(request) || _beatSaverRegex.IsMatch(request));

            if (!newRequest.isBeatSaverId && request.Length < 3)
            {
                Instance.QueueChatMessage($"Request \"{request}\" is too short- Beat Saver searches must be at least 3 characters!");
            }
            else if (!UnverifiedRequestQueue.Contains(newRequest))
            {
                UnverifiedRequestQueue.Enqueue(newRequest);
            }
        }
Beispiel #12
0
        public void RemoveCommand(WinterBot sender, TwitchUser user, string c, string a)
        {
            Args   args = a.ParseArguments(m_bot);
            string cmd  = args.GetOneWord();

            if (cmd == null)
            {
                sender.SendResponse(Importance.Med, m_removeCommandUsage);
                return;
            }

            if (cmd[0] == '!')
            {
                cmd = cmd.Substring(1);
            }

            lock (m_sync)
            {
                cmd = cmd.ToLower();
                if (m_commands.ContainsKey(cmd))
                {
                    m_commands.Remove(cmd);
                    m_remove.Add(cmd);
                    m_dirty = true;
                    sender.SendResponse(Importance.Low, string.Format("Removed command {0}.", cmd));
                    WinterBotSource.Log.RemoveCommand(user.Name, cmd);
                }
                else
                {
                    sender.SendResponse(Importance.Med, string.Format("Command {0} not found.", cmd));
                }
            }
        }
 public SqlTwitchUserPoints(TwitchUser user, TwitchChannel channel, ulong points = 0, DateTime timeOfLastBonus = default(DateTime))
     : base(new object[] { user.id, channel.user.id, points, timeOfLastBonus })
 {
     user.Save();
     this.user = user;
     this.channel = channel;
 }
Beispiel #14
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TwitchClearchatEventArgs"/> class.
 /// </summary>
 internal TwitchCheerEventArgs(TwitchUser user, TwitchChannel channel, string message, int bits)
 {
     Channel = channel;
     User    = user;
     Message = message;
     Bits    = bits;
 }
 private void StartCommand(TwitchUser speaker, string additionalText)
 {
     if (controller.game.isReadyToStart)
     {
         StartGame();
     }
 }
        private void CallCommand(TwitchUser speaker, string arg2)
        {
            if (MyTurn(speaker))
            {
                ulong amount = controller.game.GetCallAmount();
                amount = controller.game.Call();
                if (amount > 0)
                {
                    if (controller.game.sidepotPlayers.Contains(controller.game.currentPlayer))
                    {
                        Success(speaker, "Called & went all in");
                    }
                    else
                    {
                        Success(speaker, "Called for " + controller.room.pointManager.ToPointsString(amount));
                    }
                }
                else
                {
                    if (controller.game.canCheck)
                    {
                        CheckCommand(speaker, arg2);
                    }
                    else
                    {
                        FailedAction(speaker, "call");
                    }
                }
            }

            CheckForNextState();
        }
Beispiel #17
0
        public TwitchUser GetTwitchUserFromSharedUser(SharedUser Followeruser, SharedUser StreamerUser)
        {
            var result = new TwitchUser()
            {
                ChatTime             = (uint)Followeruser.ChatTime,
                CompoundScore        = Followeruser.UserScore,
                DisplayName          = Followeruser.DisplayName,
                FirstTimeSeen        = Followeruser.FirstTimeSeen.GetValueOrDefault(),
                LastSeen             = Followeruser.LastSeen.GetValueOrDefault(),
                IsTurbo              = Followeruser.IsTurbo == 1 ? true:false,
                TotalChatMessages    = (uint)Followeruser.TotalChatMessages,
                ReferringStreamer    = Followeruser.ReferringStreamer,
                TotalTimesSeen       = (uint)Followeruser.TotalTimesSeen,
                TotalWhisperMessages = (uint)Followeruser.TotalWhisperMessages,
                UserId   = Followeruser.UserId,
                UserName = Followeruser.UserName,
                UserType = (Enums.UserType)Followeruser.UserType
            };
            var followdata = data.GetFollowsForFollowerUserId(Followeruser.Id, StreamerUser.Id);

            foreach (var item in followdata)
            {
                result.FollowDate.Add(item.FollowDate);
            }
            return(result);
        }
        private void RaiseCommand(TwitchUser speaker, string additionalText)
        {
            if (MyTurn(speaker))
            {
                ulong callAmount = controller.game.GetCallAmount();
                ulong amount     = controller.room.pointManager.GetPointsFromString(additionalText);
                amount = controller.game.Raise(amount);
                if (amount > 0)
                {
                    Success(speaker, "You rose " + controller.room.pointManager.ToPointsString(amount - callAmount));
                }
                else
                {
                    if (controller.game.canBet)
                    {
                        BetCommand(speaker, additionalText);
                    }
                    else
                    {
                        FailedAction(speaker, "raise");
                    }
                }
            }

            CheckForNextState();
        }
 void StartCommand(TwitchUser speaker, string additionalText)
 {
     if (controller.game.isReadyToStart)
     {
         controller.SetState(this, typeof(BJStatePlay));
     }
 }
 private void ClearGreetingCommand(TwitchUser speaker, string additionalText)
 {
     TwitchUserInChannel inChannel = room.factory.GetUserInChannel(speaker, room.twitchConnection.channel);
     inChannel.Load();
     inChannel.greetingMessage = null;
     inChannel.Save();
 }
        void SendJoinMessage(TwitchUser speaker)
        {
            string chatMessage = "You're in, sit tight we start ";

            chatMessage += GetStartingInMessage();
            controller.room.SendWhisper(speaker, chatMessage);
        }
Beispiel #22
0
    private void HandlePlayerJoin(string incomingUserID, string incomingUsername)
    {
        //If joining is not allowed then tell user and exit
        if (!joinAllowed)
        {
            TwitchChatClient.Instance.SendChatMessageTargeted(incomingUsername, "Joining the minigame is not currently allowed!");
            return;
        }

        //Add the user to our user list - if they are not already
        if (!joinedUsers.ContainsKey(incomingUserID))
        {
            TwitchUser user = new TwitchUser(incomingUserID, incomingUsername);
            joinedUsers.Add(incomingUserID, user);

            //Tell the user that we have added them
            TwitchChatClient.Instance.SendChatMessageTargeted(incomingUsername, "You have been added to the game!");
            PlayerJoin?.Invoke(incomingUsername);

            //We just added a new user, check if we have reached our max player count if we have then stop new joins
            if (joinedUsers.Count == maxPlayersInList)
            {
                SetAllowJoin(false, "Max players reached");
            }
        }
    }
Beispiel #23
0
        private void ChatMessageReceived(TwitchChannel sender, TwitchUser user, string text)
        {
            if (m_options.Ignore.Contains(user.Name))
            {
                return;
            }

            var emotes = Emoticons;

            if (emotes != null)
            {
                emotes.EnsureDownloaded(user.ImageSet);
            }

            bool question = false;

            if (HighlightQuestions)
            {
                foreach (var highlight in m_options.Highlights)
                {
                    if (text.ToLower().Contains(highlight))
                    {
                        question = true;
                        break;
                    }
                }
            }

            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action <ChatItem>(AddItem), new ChatMessage(sender, this, user, text, question));
        }
Beispiel #24
0
 private void ModJoined(TwitchChannel conn, TwitchUser user)
 {
     if (user == CurrentUser)
     {
         ModButtonVisibility = Visibility.Visible;
     }
 }
Beispiel #25
0
        private void RunStartupScripts()
        {
            ReadRemapList(); // BUG: This should use list manager

            MapperBanList(ChatHandler.Self, "mapperban.list");
            WhiteList(ChatHandler.Self, "whitelist.unique");
            BlockedUserList(ChatHandler.Self, "blockeduser.unique");
            accesslist("whitelist.unique");
            accesslist("blockeduser.unique");
            accesslist("mapperban.list");

#if UNRELEASED
            OpenList(ChatHandler.Self, "mapper.list"); // Open mapper list so we can get new songs filtered by our favorite mappers.
            MapperAllowList(ChatHandler.Self, "mapper.list");

            accesslist("mapper.list");

            OpenList(ChatHandler.Self, "automtt.list"); // Open mapper list so we can get new songs filtered by our favorite mappers.
            automtt = listcollection.OpenList("automtt.list");
            accesslist("automtt.list");

            string dummy = "";

            TwitchUser user = ChatHandler.Self;

            loaddecks(new ParseState(ref user, ref dummy, CmdFlags.Silent, ref dummy)); // Load our default deck collection
            // BUG: Command failure observed once, no permission to use /chatcommand. Possible cause: OurTwitchUser isn't authenticated yet.

            RunScript(ChatHandler.Self, "startup.script"); // Run startup script. This can include any bot commands.
#endif
        }
Beispiel #26
0
 async void BanWorker(TwitchChannel chan, TwitchUser user)
 {
     while (!chan.Ban(user) && chan.IsJoined)
     {
         await Task.Delay(250);
     }
 }
 void Observe(TwitchChatRoom room, TwitchUser speaker, string message)
 {
     foreach (var observer in observers)
     {
         observer(room, speaker, message);
     }
 }
Beispiel #28
0
 public void Timeout(TwitchUser speaker, TimeSpan timeSpan)
 {
     if (timeSpan.TotalSeconds > 0)
     {
         SendChatMessage(".timeout " + speaker.userName + " " + timeSpan.TotalSeconds);
     }
 }
Beispiel #29
0
 public TwitchChatMessage(TwitchUser user, string message, int bits, string idMessage = "")
 {
     Message    = message;
     User       = user;
     Bits       = bits;
     _idMessage = idMessage;
 }
        private void JoinGame(TwitchUser speaker, string additionalText)
        {
            var pointManager = controller.room.pointManager.ForUser(speaker);
            var player       = new RussianRoulettePlayer <TwitchUser>(pointManager, speaker);

            if (controller.game.Join(player))
            {
                controller.room.SendWhisper(speaker, "You're in");

                if (controller.game.isFull)
                {
                    StartGame();
                }
                else if (controller.game.isReadyToStart)
                {
                    MinHit_StartWaitingForAdditionalPlayers();
                }
            }
            else
            {
                if (controller.game.Contains(speaker))
                {
                    controller.room.SendWhisper(speaker, "You're already in.");
                }
                else
                {
                    controller.room.SendWhisper(speaker, "You can't afford to play.");
                }
            }
        }
 public void ObserveChatMessage(TwitchChatRoom room, TwitchUser speaker, string message)
 {
     if(this.room.Equals(room)) {
         if(message != null && message.StartsWith("!")) {
             ObserveCommand(speaker, message.Substring(1));
         }
     }
 }
        private void ClearGreetingCommand(TwitchUser speaker, string additionalText)
        {
            TwitchUserInChannel inChannel = room.factory.GetUserInChannel(speaker, room.twitchConnection.channel);

            inChannel.Load();
            inChannel.greetingMessage = null;
            inChannel.Save();
        }
Beispiel #33
0
 internal TwitchSubscriptionEventArgs(TwitchUser user, TwitchChannel channel, TwitchSubscriptionPlan subscriptionPlan, string message, int totalMonthsSubscribed)
 {
     User                  = user;
     Channel               = channel;
     SubscriptionPlan      = subscriptionPlan;
     Message               = message;
     TotalMonthsSubscribed = totalMonthsSubscribed;
 }
 public SongRequest(JSONObject song, TwitchUser requestor, DateTime requestTime, RequestStatus status = RequestStatus.Invalid, string requestInfo = "")
 {
     this.song        = song;
     this.requestor   = requestor;
     this.status      = status;
     this.requestTime = requestTime;
     this.requestInfo = requestInfo;
 }
		public void ProcessCommand(TwitchUser user, string[] command, out bool sendViaChat, out string message) {
			sendViaChat = true;
			if(command[0] == Commands[0][0]) {
				//message = user.Username + ", your song wasn't added as it didn't have the correct parameters." + Environment.NewLine + "Correct syntax is: " + command[0] + " <song> <~url>";
				//return;
			}

			message = null;
		}
        public TwitchUserPointManager ForUser(TwitchUser user)
        {
            TwitchUserPointManager manager;
            if(!userManagers.TryGetValue(user, out manager)) {
                manager = factory.GetUserPointManager(channel, user);
                userManagers.Add(user, manager);
            }

            return manager;
        }
 private void GetVote(TwitchUser speaker, string additionalText)
 {
     uint pollNumber;
     if(uint.TryParse(additionalText, out pollNumber)) {
         string pollResults = Strawpoll.Strawpoll.GetWinner(pollNumber);
         room.SendChatMessage(pollResults);
     } else {
         room.SendWhisper(speaker, "Sorry, I didn't catch that poll number... try again - !getvote 123");
     }
 }
 private void SetGreetingCommand(TwitchUser speaker, string additionalText)
 {
     if(additionalText != null) {
         TwitchUserInChannel inChannel = room.factory.GetUserInChannel(speaker, room.twitchConnection.channel);
         inChannel.Load();
         inChannel.greetingMessage = additionalText;
         var test = inChannel.Save();
         Debug.Assert(test);
     }
 }
 private void BragCommand(TwitchUser speaker, string message)
 {
     TwitchUserPointManager yourPoints = room.pointManager.ForUser(speaker);
     if(yourPoints.Points >= 50) {
         yourPoints.Award(0, -50);
         string chatMessage = speaker.name + " has " + room.pointManager.ToPointsString(yourPoints.Points);
         room.SendChatMessage(chatMessage);
     } else {
         room.SendWhisper(speaker, "You can't afford a brag...");
     }
 }
		public void ProcessCommand(TwitchUser user, string[] command, out bool sendViaChat, out string message) {
			for(var i = 0; i < Commands.Count; i++) {
				if((user.UserType == Commands[0][2] || ChatSettings.Channel == user.Username.ToLower()) && command[0] == Commands[0][0]) {
					ChatSettings.BotEnabled = false;
					sendViaChat = true;
					message = user.Username + " is abusing me, I'm off!";
					return;
				} else if((user.UserType == Commands[0][2] || ChatSettings.Channel == user.Username.ToLower()) && command[0] == Commands[1][0]) {
					ChatSettings.BotEnabled = true;
					sendViaChat = true;
					message = user.Username + " has summoned me. Hello everyone!";
					return;
				}
			}

			sendViaChat = false;
			message = null;
		}
        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);
        }
        private void AwardPointsCommand(TwitchUser speaker, string additionalText)
        {
            if(additionalText != null) {
                var otherUser = room.factory.GetUserFromName(additionalText.GetBefore(" "));
                if(otherUser != null) {
                    var amount = room.pointManager.GetPointsFromString(additionalText.GetAfter(" "));

                    if(amount > 0) {
                        var otherPoints = room.pointManager.ForUser(otherUser);
                        otherPoints.Award(0, (long)amount);
                    } else {
                        room.SendWhisper(speaker, "How much?");
                    }
                } else {
                    room.SendWhisper(speaker, "Who are you giving points to?");
                }
            } else {
                room.SendWhisper(speaker, "Who and how much?");
            }
        }
 public SqlTwitchChannel(TwitchUser user, bool isLive = false, string previewImageUrl = null, string game = null, uint liveViewers = 0, uint totalViews = 0, uint followers = 0)
     : base(new object[] { user.id, isLive, previewImageUrl, game, liveViewers, totalViews, followers })
 {
     this.user = user;
 }
 //public void ObserveWhisperMessage(TwitchChatRoom room, SqlTwitchUser speaker, string message) {
 //    if(this.room.Equals(room)) {
 //        ObserveCommand(speaker, message);
 //    }
 //}
 internal abstract void ObserveCommand(TwitchUser speaker, string message);
 public void Timeout(TwitchUser speaker, TimeSpan timeSpan)
 {
     if(timeSpan.TotalSeconds > 0) {
         SendChatMessage(".timeout " + speaker.userName + " " + timeSpan.TotalSeconds);
     }
 }
 internal void SendWhisper(TwitchUser speakee, string message)
 {
     SendIrcMessage("PRIVMSG #jtv :/w " + speakee.userName + " " + message);
 }
 public TwitchChannel GetChannel(TwitchUser twitchUser)
 {
     return new SqlTwitchChannel(twitchUser);
 }
 public TwitchUserPoints GetUserPoints(TwitchUser user, TwitchChannel channel)
 {
     return new SqlTwitchUserPoints(user, channel);
 }
 void Observe(TwitchChatRoom room, TwitchUser speaker, string message)
 {
     foreach(var observer in observers) {
         observer(room, speaker, message);
     }
 }
 public TwitchChatWhisper(TwitchUser speaker, string message)
 {
     this.speaker = speaker;
     this.message = message;
 }
 public TwitchChatMessage(TwitchChannel channel, TwitchUser speaker, string message)
     : base(channel)
 {
     this.speaker = speaker;
     this.message = message?.Trim();
 }
 public TwitchChannel CreateTwitchChannel(TwitchUser user)
 {
     return new SqlTwitchChannel(user);
 }
 public TwitchUserPointManager GetUserPointManager(TwitchChannel channel, TwitchUser user)
 {
     return new TwitchUserPointManager(this, channel, user);
 }
 public TwitchChannel CreateTwitchChannel(TwitchUser user, bool isLive, string previewImageUrl, string game, uint liveViewers, uint totalViews, uint followers)
 {
     return new SqlTwitchChannel(user, isLive, previewImageUrl, game, liveViewers, totalViews, followers);
 }
		public void ProcessCommand(TwitchUser user, string[] command, out bool sendViaChat, out string message) {
			sendViaChat = true;
			if(File.Exists(Program.GiveawayPointsFile)) {
				if(command[0] == Commands[0][0]) {
					//Enter into giveaway
					if(Program.BotForm.giveawayActive) {
						Program.BotForm.AddGiveawayUserToList(user.Username);
						message = user.Username + " has been added into the giveaway.";
						return;
					} else {
						message = null;
						return;
					}
				} else if(command[0] == Commands[1][0]) {
					//Show amount of points the user has.
					var docTwo = XDocument.Load(Program.GiveawayPointsFile);
					var points = new long();
					foreach(var el in docTwo.Element("Users").Elements()) {
						if(el.Element("Username").Value == user.Username.ToLower()) {
							points = Convert.ToInt64(el.Element("Points").Value);
							break;
						}
					}

					message = user.Username + " has " + points + " points.";
					return;
				} else if(command[0] == Commands[2][0]) {
					//Get the user with the most points.
					var topUser = "";
					var topPoints = new long();
					var doc = XDocument.Load(Program.GiveawayPointsFile);
					foreach(var el in doc.Element("Users").Elements()) {
						if(topUser == "") {
							topUser = el.Element("Username").Value;
							topPoints = Convert.ToInt64(el.Element("Points").Value);
						} else {
							if(Convert.ToInt64(el.Element("Points").Value) > topPoints) {
								topUser = el.Element("Username").Value;
								topPoints = Convert.ToInt64(el.Element("Points").Value);
							}
						}
					}

					message = topUser + " currently has the most points with " + topPoints + " points.";
					return;
				} else if(command[0] == Commands[3][0]) {
					try {
						message = null;

						//!givepoints name amount
						if(command[1] != null) {
							return;
						}

						var givenPoints = Math.Abs(long.Parse(command[2]));
						var docThree = XDocument.Load(Program.GiveawayPointsFile);
						var canAfford = false;
						foreach(var el in docThree.Element("Users").Elements()) {
							if(el.Element("Username").Value == user.Username.ToLower()) {
								if(Convert.ToInt64(el.Element("Points").Value) >= givenPoints) {
									canAfford = true;
								}
								break;
							}
						}

						if(canAfford) {
							foreach(var el in docThree.Element("Users").Elements()) {
								if(el.Element("Username").Value == user.Username.ToLower()) {
									//Remove points from giver.
									el.Element("Points").SetValue(Convert.ToInt64(el.Element("Points").Value) - givenPoints);
									sendViaChat = false;
									message = "/w " + user.Username + " You've given " + givenPoints + " points to " + command[1];
								} else if(el.Element("Username").Value == command[1].ToLower()) {
									//Add points to receiver.
									el.Element("Points").SetValue(Convert.ToInt64(el.Element("Points").Value) + givenPoints);
									sendViaChat = false;
									message = "/w " + command[1] + " You've received " + givenPoints + " points from " + user.Username;
								}
							}
							//ChannelConnection.send_message(sender + " has given " + givenPoints + " points to " + msg[1] + "!");
							docThree.Save(Program.GiveawayPointsFile);
							return;
						} else {
							message = user.Username + ", you can't afford that you dirty peasant!";
							return;
						}
					} catch(Exception ex) {
						//logMessage("Error with command '" + msg[0] + "': " + ex.ToString());
					}
				}
			}

			message = null;
		}
 public SqlTwitchUserInChannel(TwitchUser user, TwitchChannel channel, DateTime created = default(DateTime), bool isCurrentlyFollowing = false, string greetingMessage = null)
     : base(new object[] { user.id, channel.user.id, created, isCurrentlyFollowing, greetingMessage })
 {
     this.user = user;
     this.channel = channel;
 }
 public void SendWhisper(TwitchUser speakee, string message)
 {
     whisperIrcConnection.SendWhisper(speakee, message);
 }
 public TwitchUserInChannel GetUserInChannel(TwitchUser user, TwitchChannel channel)
 {
     return new SqlTwitchUserInChannel(user, channel);
 }
 public TwitchUserPointManager(ITwitchFactory factory, TwitchChannel channel, TwitchUser user)
 {
     sqlPoints = factory.GetUserPoints(user, channel);
 }
		public void ProcessCommand(TwitchUser user, string[] command, out bool sendViaChat, out string message) {
			sendViaChat = true;
			if(command[0] == Commands[0][0]) {
				//if(args.Length == 2 || args.Length == 3 ) { message = null; return; }
				if(command.Length == 2) {
					if(command[1] != null) {
						_musicQueue.Add(new SongData { Requester = user.Username, Name = command[1] });
						message = user.Username + ", your song (" + command[1] + ") has been added to the queue.";
						return;
					}
				} else if(command.Length == 3) {
					if(command[1] != null && command[2] != null) {
						_musicQueue.Add(new SongData { Requester = user.Username, Name = command[1], Url = command[2] });
						message = user.Username + ", your song (" + command[1] + ") has been added to the queue.";
						return;
					}
				}

				message = user.Username + ", your song wasn't added as it didn't have the correct parameters." + Environment.NewLine + "Correct syntax is: " + command[0] + " <song> <~url>";
				return;
			} else if(command[0] == Commands[1][0]) {
				//Retrieve the details of a song and PM them to the user
				sendViaChat = false;
				foreach (var song in _musicQueue){
					if(song.Name == command[1]) {
						if(song.Url == null) {
							message = "Here's the song data you requested: Name: " + command[1];
							return;
						} else {
							message = "Here's the song data you requested: Name: " + command[1] + ", URL: " + song.Url;
							return;
						}
					}
				}

				message = "Couldn't find the song \"" + command[1] + "\" in the queue.";
				return;
			} else if(command[0] == Commands[2][0]) {
				//Only allow the streamer to remove music from the queue
				if(user.Username.ToLower() == ChatSettings.Channel) {
					if(command[1] != null) {
						for(int i = 0; i < _musicQueue.Count; i++) {
							if(_musicQueue[i].Name == command[1]) {
								_musicQueue.Remove(_musicQueue[i]);
								message = command[1] + " has been removed from the music queue.";
								return;
							}
						}
					}
				}
			}else if(command[0] == Commands[3][0]) {
				//Get the next song to be played
				foreach(var song in _musicQueue) {
					sendViaChat = false;
					if(song.Url == null) {
						message = "The next song to be played is: " + song.Name;
					} else {
						message = "The next song to be played is: " + song.Name + ", URL: " + song.Url;
					}
					
					return;
				}
			}

			message = null;
		}