public async Task SetDetails(bool checkForFollow = true)
        {
            if (this.ID > 0)
            {
                UserWithChannelModel userWithChannel = await ChannelSession.Connection.GetUser(this.GetModel());
                if (userWithChannel != null)
                {
                    if (!string.IsNullOrEmpty(userWithChannel.avatarUrl))
                    {
                        this.AvatarLink = userWithChannel.avatarUrl;
                    }
                    this.MixerAccountDate = userWithChannel.createdAt;
                    this.Sparks = (int)userWithChannel.sparks;
                    this.GameTypeID = userWithChannel.channel.typeId.GetValueOrDefault();
                }
            }

            if (checkForFollow)
            {
                DateTimeOffset? followDate = await ChannelSession.Connection.CheckIfFollows(ChannelSession.Channel, this.GetModel());
                this.SetFollowDate(followDate);

                if (this.Roles.Contains(UserRole.Subscriber))
                {
                    await this.SetSubscribeDate();
                }
            }
        }
Beispiel #2
0
        public async Task RefreshDetails(bool force = false)
        {
            if (!this.IsAnonymous && (this.LastUpdated.TotalMinutesFromNow() >= 1 || force))
            {
                UserWithChannelModel user = await ChannelSession.Connection.GetUser(this.ID);

                if (user != null)
                {
                    this.SetMixerUserDetails(user);

                    this.FollowDate = await ChannelSession.Connection.CheckIfFollows(ChannelSession.Channel, this.GetModel());

                    if (this.IsMixerSubscriber)
                    {
                        UserWithGroupsModel userGroups = await ChannelSession.Connection.GetUserInChannel(ChannelSession.Channel, this.ID);

                        if (userGroups != null)
                        {
                            this.MixerSubscribeDate = userGroups.GetSubscriberDate();
                        }
                    }
                }

                if (!this.IsInChat)
                {
                    await this.RefreshChatDetails(addToChat : false);
                }

                await this.SetCustomRoles();

                this.LastUpdated = DateTimeOffset.Now;
            }
        }
Beispiel #3
0
 private void SetMixerUserDetails(UserModel user)
 {
     this.MixerAccountDate = user.createdAt;
     this.Sparks           = (int)user.sparks;
     this.TwitterURL       = user.social?.twitter;
     if (user is UserWithChannelModel)
     {
         UserWithChannelModel userChannel = (UserWithChannelModel)user;
         this.CurrentViewerCount = userChannel.channel.viewersCurrent;
     }
 }
Beispiel #4
0
        public void GetUser()
        {
            this.TestWrapper(async(MixerClient client) =>
            {
                UserModel user = await UsersServiceUnitTests.GetCurrentUser(client);

                UserWithChannelModel channelUser = await client.Users.GetUser(user);

                Assert.IsNotNull(channelUser);
                Assert.IsTrue(channelUser.id > (uint)0);
            });
        }
        public void GetUser()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection);

                UserWithChannelModel channelUser = await connection.Users.GetUser(user);

                Assert.IsNotNull(channelUser);
                Assert.IsTrue(channelUser.id > (uint)0);
            });
        }
Beispiel #6
0
 public SparksChatCommand()
     : base("Sparks", "sparks", UserRole.User, 5)
 {
     this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) =>
     {
         if (ChannelSession.Chat != null)
         {
             UserWithChannelModel userModel = await ChannelSession.Connection.GetUser(user.GetModel());
             await ChannelSession.Chat.SendMessage(user.UserName + "'s Sparks: " + userModel.sparks);
         }
     }));
 }
        public async Task RefreshDetails(bool getChatDetails = true)
        {
            if (this.ID > 0)
            {
                UserWithChannelModel user = await ChannelSession.Connection.GetUser(this.ID);

                if (user != null)
                {
                    if (!string.IsNullOrEmpty(user.avatarUrl))
                    {
                        this.AvatarLink = user.avatarUrl;
                    }
                    this.MixerAccountDate = user.createdAt;
                    this.Sparks           = (int)user.sparks;

                    this.GameTypeID = user.channel.typeId.GetValueOrDefault();

                    this.Data.UpdateData(user);
                }

                if (getChatDetails)
                {
                    ChatUserModel chatUser = await ChannelSession.Connection.GetChatUser(ChannelSession.Channel, this.ID);

                    if (chatUser != null)
                    {
                        this.SetChatDetails(chatUser);
                    }
                }

                this.FollowDate = await ChannelSession.Connection.CheckIfFollows(ChannelSession.Channel, this.GetModel());

                if (this.IsSubscriber)
                {
                    UserWithGroupsModel userGroups = await ChannelSession.Connection.GetUserInChannel(ChannelSession.Channel, this.ID);

                    if (userGroups != null && userGroups.groups != null)
                    {
                        UserGroupModel subscriberGroup = userGroups.groups.FirstOrDefault(g => g.name.Equals("Subscriber") && g.deletedAt == null);
                        if (subscriberGroup != null)
                        {
                            this.SubscribeDate = subscriberGroup.createdAt;
                        }
                    }
                }

                await this.SetCustomRoles();
            }
        }
        private async Task <ChannelModel> UpdateChannel(ChannelHostModel channel)
        {
            UserWithChannelModel channelModel = await this.connection.Users.GetUser(channel.ID);

            if (channelModel != null)
            {
                channel.ID       = channel.ID;
                channel.Name     = channelModel.username;
                channel.IsOnline = channelModel.channel.online;
            }
            else
            {
                channel.IsOnline = false;
            }
            return(channelModel.channel);
        }
        public async Task <IEnumerable <UserWithChannelModel> > GetUsers()
        {
            if (this.IsTeam)
            {
                return(await ChannelSession.Connection.GetTeamUsers(this.Group.Team, 10000));
            }
            else
            {
                List <UserWithChannelModel> users = new List <UserWithChannelModel>();
                foreach (uint userID in this.Group.GroupUserIDs)
                {
                    UserWithChannelModel user = await ChannelSession.Connection.GetUser(userID);

                    if (user != null)
                    {
                        users.Add(user);
                    }
                }
                return(users);
            }
        }
Beispiel #10
0
 public FavoriteUser(UserWithChannelModel user, GameTypeSimpleModel game, bool canBeRemoved = false)
 {
     this.User         = user;
     this.game         = game;
     this.CanBeRemoved = canBeRemoved;
 }