Ejemplo n.º 1
0
        public UserViewModel GetUserFullSearch(StreamingPlatformTypeEnum platform, string userID, string username)
        {
            UserViewModel user = null;

            if (!string.IsNullOrEmpty(userID))
            {
                if (platform.HasFlag(StreamingPlatformTypeEnum.Twitch) && user == null)
                {
                    user = ChannelSession.Services.User.GetUserByTwitchID(userID);
                }

                if (user == null)
                {
                    UserDataModel userData = null;
                    if (platform.HasFlag(StreamingPlatformTypeEnum.Twitch) && userData == null)
                    {
                        userData = ChannelSession.Settings.GetUserDataByTwitchID(userID);
                    }

                    if (userData != null)
                    {
                        user = new UserViewModel(userData);
                    }
                }
            }

            if (user == null)
            {
                user = ChannelSession.Services.User.GetUserByUsername(username);
                if (user == null)
                {
                    UserDataModel userData = ChannelSession.Settings.GetUserDataByUsername(platform, username);
                    if (userData != null)
                    {
                        user = new UserViewModel(userData);
                    }
                    else
                    {
                        user = new UserViewModel(username);
                    }
                }
            }

            return(user);
        }
Ejemplo n.º 2
0
        public async Task SendMessage(string message, bool sendAsStreamer = false, StreamingPlatformTypeEnum platform = StreamingPlatformTypeEnum.All)
        {
            if (platform.HasFlag(StreamingPlatformTypeEnum.Twitch))
            {
                await this.TwitchChatService.SendMessage(message, sendAsStreamer);

                if (sendAsStreamer || ChannelSession.TwitchBotConnection == null)
                {
                    UserViewModel user = ChannelSession.GetCurrentUser();
                    await this.AddMessage(new TwitchChatMessageViewModel(user, message));
                }
            }
        }
Ejemplo n.º 3
0
        public UserViewModel GetUserByUsername(string username, StreamingPlatformTypeEnum platform = StreamingPlatformTypeEnum.None)
        {
            UserViewModel user = null;

            if (!string.IsNullOrEmpty(username))
            {
                username = username.ToLower().Replace("@", "").Trim();
                if (platform.HasFlag(StreamingPlatformTypeEnum.Twitch) || platform == StreamingPlatformTypeEnum.None)
                {
                    if (this.usersByTwitchLogin.TryGetValue(username.ToLower(), out user))
                    {
                        return(user);
                    }
                }
            }
            return(user);
        }
        public static async Task <UserViewModel> SearchForUser(string username, StreamingPlatformTypeEnum platform = StreamingPlatformTypeEnum.All)
        {
            username = username.Replace("@", "");
            UserViewModel user = ChannelSession.Services.User.GetUserByUsername(username, platform);

            if (user == null)
            {
                if (platform.HasFlag(StreamingPlatformTypeEnum.Twitch) && ChannelSession.TwitchUserConnection != null)
                {
                    Twitch.Base.Models.NewAPI.Users.UserModel twitchUser = await ChannelSession.TwitchUserConnection.GetNewAPIUserByLogin(username);

                    if (twitchUser != null)
                    {
                        user = new UserViewModel(twitchUser);
                    }
                }
            }
            return(user);
        }
Ejemplo n.º 5
0
        public async Task <UserViewModel> GetUserFullSearch(StreamingPlatformTypeEnum platform, string userID = null, string username = null)
        {
            UserViewModel user = null;

            if (!string.IsNullOrEmpty(userID))
            {
                if (platform.HasFlag(StreamingPlatformTypeEnum.Twitch) && user == null)
                {
                    user = ChannelSession.Services.User.GetActiveUserByPlatformID(StreamingPlatformTypeEnum.Twitch, userID);
                }

                if (user == null)
                {
                    UserDataModel userData = await ChannelSession.Settings.GetUserDataByPlatformID(StreamingPlatformTypeEnum.Twitch, userID);

                    if (userData != null)
                    {
                        user = new UserViewModel(userData);
                    }
                    else
                    {
                        if (platform.HasFlag(StreamingPlatformTypeEnum.Twitch))
                        {
                            var twitchUser = await ChannelSession.TwitchUserConnection.GetNewAPIUserByID(userID);

                            if (twitchUser != null)
                            {
                                user = await UserViewModel.Create(twitchUser);
                            }
                        }
                    }
                }
            }

            if (user == null && !string.IsNullOrEmpty(username))
            {
                username = this.SanitizeUsername(username);
                user     = ChannelSession.Services.User.GetActiveUserByUsername(username);
                if (user == null)
                {
                    UserDataModel userData = await ChannelSession.Settings.GetUserDataByPlatformUsername(StreamingPlatformTypeEnum.Twitch, username);

                    if (userData != null)
                    {
                        user = new UserViewModel(userData);
                    }
                    else
                    {
                        if (platform.HasFlag(StreamingPlatformTypeEnum.Twitch))
                        {
                            var twitchUser = await ChannelSession.TwitchUserConnection.GetNewAPIUserByLogin(username);

                            if (twitchUser != null)
                            {
                                user = await UserViewModel.Create(twitchUser);
                            }
                        }
                    }

                    if (user == null)
                    {
                        user = UserViewModel.Create(username);
                    }
                }
            }

            return(user);
        }
Ejemplo n.º 6
0
        public IEnumerable <UserViewModel> GetAllWorkableUsers(StreamingPlatformTypeEnum platform)
        {
            IEnumerable <UserViewModel> results = this.GetAllWorkableUsers();

            return(results.Where(u => platform.HasFlag(u.Platform)));
        }