private bool CanExecuteCommand(IntelliTwitchUser user, IIntelliTwitchCommand cmd)
 {
     if (cmd.modRequired)
     {
         return(user.IsChannelMod);
     }
     else
     {
         return(true);
     }
 }
        private IntelliTwitchUser CreateNewUser(string[] userInfo, int userID)
        {
            var user = new IntelliTwitchUser();

            //We already parsed out the user-id from the message, no need to relocate it. So we just pass it along.
            user.ID = userID;

            user.UserName      = IntelliTwitchStringParser.GetDisplayName(userInfo);
            user.UserNameColor = IntelliTwitchStringParser.GetUserNameColor(userInfo);
            user.IsSubscriber  = IntelliTwitchStringParser.GetSubscriberStatus(userInfo);
            user.IsTurbo       = IntelliTwitchStringParser.GetTurboStatus(userInfo);
            user.IsChannelMod  = IntelliTwitchStringParser.GetChannelModStatus(userInfo);
            user.UserTypeID    = FindUserType(IntelliTwitchStringParser.GetUserType(userInfo));

            user.joinDate = GetCurrentUtcTime();

            CreateUser(user);

            return(user);
        }
        /// <summary>
        /// Updates a user in the database.
        /// Compares the stored twitch user with the info recieved from twitch.
        /// Use GetUser() unless you want to handle this yourself.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public IntelliTwitchUser UpdateUser(IntelliTwitchUser user, string[] userInfo)
        {
            //Compare old user values, with new userInfo
            //Update if they are different
            var update = false;

            //TODO: Check if twitch user names can change easily, might be unneccessary
            if (user.UserName != IntelliTwitchStringParser.GetDisplayName(userInfo))
            {
                user.UserName = IntelliTwitchStringParser.GetDisplayName(userInfo);
                update        = true;
            }
            if (user.UserNameColor != IntelliTwitchStringParser.GetUserNameColor(userInfo))
            {
                user.UserNameColor = IntelliTwitchStringParser.GetUserNameColor(userInfo);
                update             = true;
            }
            if (user.IsSubscriber != IntelliTwitchStringParser.GetSubscriberStatus(userInfo))
            {
                user.IsSubscriber = IntelliTwitchStringParser.GetSubscriberStatus(userInfo);
                update            = true;
            }
            if (user.IsTurbo != IntelliTwitchStringParser.GetTurboStatus(userInfo))
            {
                user.IsTurbo = IntelliTwitchStringParser.GetTurboStatus(userInfo);
                update       = true;
            }
            if (user.IsChannelMod != IntelliTwitchStringParser.GetChannelModStatus(userInfo))
            {
                user.IsChannelMod = IntelliTwitchStringParser.GetChannelModStatus(userInfo);
                update            = true;
            }

            if (update)
            {
                _connection.Update(user);
            }

            return(user);
        }
 public int DeleteUser(IntelliTwitchUser user)
 {
     return(_connection.Delete(user));
 }
 /// <summary>
 /// Creates a new user in the database.
 /// Useful if you want to manually add a user and handle the IntelliTwitchUser creation yourself.
 /// Otherwise, GetUser() will automatically create/update a user if needed.
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public int CreateUser(IntelliTwitchUser userInfo)
 {
     return(_connection.Insert(userInfo));
 }
 public IntelliTwitchCommandActor(IntelliTwitchUser sender, string channelActedOn)
 {
     user    = sender;
     Channel = channelActedOn;
 }
 private IntelliTwitchCommandActor BuildCommandActor(IntelliTwitchUser user, string channel)
 {
     return(new IntelliTwitchCommandActor(user, channel));
 }