Esempio n. 1
0
 public TwitchMassGiftedSubEventModel(ChatUserNoticePacketModel userNotice, UserViewModel gifter)
 {
     this.IsAnonymous    = TwitchMassGiftedSubEventModel.IsAnonymousGifter(userNotice);
     this.Gifter         = gifter;
     this.TotalGifted    = userNotice.SubTotalGifted;
     this.LifetimeGifted = userNotice.SubTotalGiftedLifetime;
     this.PlanTier       = TwitchEventService.GetSubTierNameFromText(userNotice.SubPlan);
     this.PlanTierNumber = 1;
 }
Esempio n. 2
0
        private async void UserClient_OnUserNoticeReceived(object sender, ChatUserNoticePacketModel userNotice)
        {
            try
            {
                if (RaidUserNoticeMessageTypeID.Equals(userNotice.MessageTypeID))
                {
                    UserViewModel user = ChannelSession.Services.User.GetUserByTwitchID(userNotice.UserID.ToString());
                    if (user == null)
                    {
                        user = new UserViewModel(userNotice);
                    }
                    user.SetTwitchChatDetails(userNotice);

                    EventTrigger trigger = new EventTrigger(EventTypeEnum.TwitchChannelRaided, user);
                    if (ChannelSession.Services.Events.CanPerformEvent(trigger))
                    {
                        ChannelSession.Settings.LatestSpecialIdentifiersData[SpecialIdentifierStringBuilder.LatestRaidUserData]        = user.ID;
                        ChannelSession.Settings.LatestSpecialIdentifiersData[SpecialIdentifierStringBuilder.LatestRaidViewerCountData] = userNotice.RaidViewerCount;

                        foreach (CurrencyModel currency in ChannelSession.Settings.Currency.Values.ToList())
                        {
                            currency.AddAmount(user.Data, currency.OnHostBonus);
                        }

                        GlobalEvents.RaidOccurred(user, userNotice.RaidViewerCount);

                        trigger.SpecialIdentifiers["hostviewercount"] = userNotice.RaidViewerCount.ToString();
                        trigger.SpecialIdentifiers["raidviewercount"] = userNotice.RaidViewerCount.ToString();
                        await ChannelSession.Services.Events.PerformEvent(trigger);

                        await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(StreamingPlatformTypeEnum.Twitch, user, string.Format("{0} raided with {1} viewers", user.Username, userNotice.RaidViewerCount), ChannelSession.Settings.AlertRaidColor));
                    }
                }
                else if (SubMysteryGiftUserNoticeMessageTypeID.Equals(userNotice.MessageTypeID) && userNotice.SubTotalGifted > 0)
                {
                    if (ChannelSession.Services.Events.TwitchEventService != null)
                    {
                        await ChannelSession.Services.Events.TwitchEventService.AddMassGiftedSub(new TwitchMassGiftedSubEventModel(userNotice));
                    }
                }
                else if (SubGiftPaidUpgradeUserNoticeMessageTypeID.Equals(userNotice.MessageTypeID))
                {
                    if (ChannelSession.Services.Events.TwitchEventService != null)
                    {
                        await ChannelSession.Services.Events.TwitchEventService.AddSub(new TwitchSubEventModel(userNotice));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ForceLog(LogLevel.Debug, JSONSerializerHelper.SerializeToString(userNotice));
                Logger.Log(ex);
                throw ex;
            }
        }
Esempio n. 3
0
 public TwitchSubEventModel(ChatUserNoticePacketModel userNotice)
 {
     this.User = ChannelSession.Services.User.GetUserByTwitchID(userNotice.UserID.ToString());
     if (this.User == null)
     {
         this.User = new UserViewModel(userNotice);
     }
     this.User.SetTwitchChatDetails(userNotice);
     this.PlanTier        = this.PlanName = MixItUp.Base.Resources.Tier1;
     this.IsGiftedUpgrade = true;
 }
Esempio n. 4
0
        public UserViewModel(ChatUserNoticePacketModel packet)
        {
            this.SetUserData(twitchID: packet.UserID.ToString());

            this.TwitchID          = packet.UserID.ToString();
            this.TwitchUsername    = !string.IsNullOrEmpty(packet.RaidUserLogin) ? packet.RaidUserLogin : packet.Login;
            this.TwitchDisplayName = !string.IsNullOrEmpty(packet.RaidUserDisplayName) ? packet.RaidUserDisplayName : packet.DisplayName;
            if (string.IsNullOrEmpty(this.TwitchDisplayName))
            {
                this.TwitchDisplayName = this.TwitchUsername;
            }

            this.SetTwitchRoles();
        }
Esempio n. 5
0
        public TwitchSubEventModel(UserViewModel user, ChatUserNoticePacketModel userNotice)
        {
            this.User = user;
            if (this.User.IsPlatformSubscriber)
            {
                this.PlanTier = this.PlanName = this.User.SubscribeTierString;
            }
            else
            {
                this.PlanTier = this.PlanName = MixItUp.Base.Resources.Tier1;
            }

            this.IsGiftedUpgrade = true;
        }
Esempio n. 6
0
        public TwitchMassGiftedSubEventModel(ChatUserNoticePacketModel userNotice)
        {
            this.IsAnonymous = string.Equals(userNotice.Login, AnonymousGiftedUserNoticeLogin, StringComparison.InvariantCultureIgnoreCase);

            this.Gifter = new UserViewModel("An Anonymous Gifter");
            if (!this.IsAnonymous)
            {
                this.Gifter = ChannelSession.Services.User.GetUserByTwitchID(userNotice.UserID.ToString());
                if (this.Gifter == null)
                {
                    this.Gifter = new UserViewModel(userNotice);
                }
                this.Gifter.SetTwitchChatDetails(userNotice);
            }

            this.TotalGifted    = userNotice.SubTotalGifted;
            this.LifetimeGifted = userNotice.SubTotalGiftedLifetime;
            this.PlanTier       = TwitchEventService.GetSubTierNameFromText(userNotice.SubPlan);
        }
Esempio n. 7
0
        public static async Task <UserViewModel> Create(ChatUserNoticePacketModel packet)
        {
            UserViewModel user = await UserViewModel.Create(StreamingPlatformTypeEnum.Twitch, packet.UserID.ToString());

            user.TwitchID          = packet.UserID.ToString();
            user.TwitchUsername    = !string.IsNullOrEmpty(packet.RaidUserLogin) ? packet.RaidUserLogin : packet.Login;
            user.TwitchDisplayName = !string.IsNullOrEmpty(packet.RaidUserDisplayName) ? packet.RaidUserDisplayName : packet.DisplayName;
            if (string.IsNullOrEmpty(user.TwitchDisplayName))
            {
                user.TwitchDisplayName = user.TwitchUsername;
            }

            user.SetTwitchRoles();

            user.SetTwitchChatDetails(packet);

            ChannelSession.Settings.SetUserData(user.Data);

            return(user);
        }
Esempio n. 8
0
 public void SetTwitchChatDetails(ChatUserNoticePacketModel userNotice)
 {
     this.SetTwitchChatDetails(userNotice.UserDisplayName, userNotice.BadgeDictionary, userNotice.BadgeInfoDictionary, userNotice.Color);
 }
Esempio n. 9
0
 private static void Chat_OnUserNoticeReceived(object sender, ChatUserNoticePacketModel packet)
 {
     System.Console.WriteLine(string.Format("USER NOTICE: {0} {1}", packet.UserDisplayName, packet.SystemMessage));
 }
Esempio n. 10
0
        private async void UserClient_OnUserNoticeReceived(object sender, ChatUserNoticePacketModel userNotice)
        {
            try
            {
                if (RaidUserNoticeMessageTypeID.Equals(userNotice.MessageTypeID))
                {
                    UserViewModel user = ChannelSession.Services.User.GetActiveUserByPlatformID(StreamingPlatformTypeEnum.Twitch, userNotice.UserID.ToString());
                    if (user == null)
                    {
                        user = await UserViewModel.Create(userNotice);
                    }
                    user.SetTwitchChatDetails(userNotice);

                    CommandParametersModel parameters = new CommandParametersModel(user);
                    if (ChannelSession.Services.Events.CanPerformEvent(EventTypeEnum.TwitchChannelRaided, parameters))
                    {
                        ChannelSession.Settings.LatestSpecialIdentifiersData[SpecialIdentifierStringBuilder.LatestRaidUserData]        = user.ID;
                        ChannelSession.Settings.LatestSpecialIdentifiersData[SpecialIdentifierStringBuilder.LatestRaidViewerCountData] = userNotice.RaidViewerCount;

                        foreach (CurrencyModel currency in ChannelSession.Settings.Currency.Values.ToList())
                        {
                            currency.AddAmount(user.Data, currency.OnHostBonus);
                        }

                        foreach (StreamPassModel streamPass in ChannelSession.Settings.StreamPass.Values)
                        {
                            if (user.HasPermissionsTo(streamPass.Permission))
                            {
                                streamPass.AddAmount(user.Data, streamPass.HostBonus);
                            }
                        }

                        GlobalEvents.RaidOccurred(user, userNotice.RaidViewerCount);

                        parameters.SpecialIdentifiers["hostviewercount"] = userNotice.RaidViewerCount.ToString();
                        parameters.SpecialIdentifiers["raidviewercount"] = userNotice.RaidViewerCount.ToString();
                        await ChannelSession.Services.Events.PerformEvent(EventTypeEnum.TwitchChannelRaided, parameters);

                        await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(StreamingPlatformTypeEnum.Twitch, user, string.Format("{0} raided with {1} viewers", user.FullDisplayName, userNotice.RaidViewerCount), ChannelSession.Settings.AlertRaidColor));
                    }
                }
                else if (SubMysteryGiftUserNoticeMessageTypeID.Equals(userNotice.MessageTypeID) && userNotice.SubTotalGifted > 0)
                {
                    if (ChannelSession.Services.Events.TwitchEventService != null)
                    {
                        UserViewModel gifter = UserViewModel.Create("An Anonymous Gifter");
                        if (!TwitchMassGiftedSubEventModel.IsAnonymousGifter(userNotice))
                        {
                            gifter = await ChannelSession.Services.User.GetUserFullSearch(StreamingPlatformTypeEnum.Twitch, userNotice.UserID.ToString(), userNotice.Login);

                            gifter.SetTwitchChatDetails(userNotice);
                        }
                        await ChannelSession.Services.Events.TwitchEventService.AddMassGiftedSub(new TwitchMassGiftedSubEventModel(userNotice, gifter));
                    }
                }
                else if (SubGiftPaidUpgradeUserNoticeMessageTypeID.Equals(userNotice.MessageTypeID))
                {
                    if (ChannelSession.Services.Events.TwitchEventService != null)
                    {
                        UserViewModel user = ChannelSession.Services.User.GetActiveUserByPlatformID(StreamingPlatformTypeEnum.Twitch, userNotice.UserID.ToString());
                        if (user == null)
                        {
                            user = await UserViewModel.Create(userNotice);
                        }
                        user.SetTwitchChatDetails(userNotice);

                        await ChannelSession.Services.Events.TwitchEventService.AddSub(new TwitchSubEventModel(user, userNotice));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ForceLog(LogLevel.Debug, JSONSerializerHelper.SerializeToString(userNotice));
                Logger.Log(ex);
                throw ex;
            }
        }
Esempio n. 11
0
 public static bool IsAnonymousGifter(ChatUserNoticePacketModel userNotice)
 {
     return(string.Equals(userNotice.Login, TwitchMassGiftedSubEventModel.AnonymousGiftedUserNoticeLogin, StringComparison.InvariantCultureIgnoreCase));
 }