private async void UserClient_OnChatClearReceived(object sender, ChatClearChatPacketModel chatClear) { UserViewModel user = ChannelSession.Services.User.GetUserByTwitchID(chatClear.UserID); if (user == null) { user = new UserViewModel(chatClear); } if (chatClear.IsClear) { await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(StreamingPlatformTypeEnum.Twitch, user, "Chat Cleared", ChannelSession.Settings.AlertModerationColor)); } else if (chatClear.IsTimeout) { EventTrigger trigger = new EventTrigger(EventTypeEnum.ChatUserTimeout); trigger.Arguments.Add("@" + user.Username); trigger.SpecialIdentifiers["timeoutlength"] = chatClear.BanDuration.ToString(); await ChannelSession.Services.Events.PerformEvent(trigger); await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(StreamingPlatformTypeEnum.Twitch, user, string.Format("{0} Timed Out for {1} seconds", user.Username, chatClear.BanDuration), ChannelSession.Settings.AlertModerationColor)); } else if (chatClear.IsBan) { EventTrigger trigger = new EventTrigger(EventTypeEnum.ChatUserBan); trigger.Arguments.Add("@" + user.Username); await ChannelSession.Services.Events.PerformEvent(trigger); await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(StreamingPlatformTypeEnum.Twitch, user, string.Format("{0} Banned", user.Username), ChannelSession.Settings.AlertModerationColor)); await ChannelSession.Services.User.RemoveUserByTwitchLogin(user.Data.TwitchUsername); } }
private async void UserClient_OnChatClearReceived(object sender, ChatClearChatPacketModel chatClear) { UserViewModel user = ChannelSession.Services.User.GetActiveUserByPlatformID(StreamingPlatformTypeEnum.Twitch, chatClear.UserID); if (user == null) { user = await UserViewModel.Create(chatClear); } if (chatClear.IsClear) { await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(StreamingPlatformTypeEnum.Twitch, user, "Chat Cleared", ChannelSession.Settings.AlertModerationColor)); } else if (chatClear.IsTimeout) { CommandParametersModel parameters = new CommandParametersModel(); parameters.Arguments.Add("@" + user.Username); parameters.TargetUser = user; parameters.SpecialIdentifiers["timeoutlength"] = chatClear.BanDuration.ToString(); await ChannelSession.Services.Events.PerformEvent(EventTypeEnum.ChatUserTimeout, parameters); await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(StreamingPlatformTypeEnum.Twitch, user, string.Format("{0} Timed Out for {1} seconds", user.FullDisplayName, chatClear.BanDuration), ChannelSession.Settings.AlertModerationColor)); } else if (chatClear.IsBan) { CommandParametersModel parameters = new CommandParametersModel(); parameters.Arguments.Add("@" + user.Username); parameters.TargetUser = user; await ChannelSession.Services.Events.PerformEvent(EventTypeEnum.ChatUserBan, parameters); await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(StreamingPlatformTypeEnum.Twitch, user, string.Format("{0} Banned", user.FullDisplayName), ChannelSession.Settings.AlertModerationColor)); await ChannelSession.Services.User.RemoveActiveUserByID(user.ID); } }
public UserViewModel(ChatClearChatPacketModel packet) { this.SetUserData(twitchID: packet.UserID); this.TwitchID = packet.UserID; this.TwitchUsername = packet.UserLogin; this.SetTwitchRoles(); }
public static async Task <UserViewModel> Create(ChatClearChatPacketModel packet) { UserViewModel user = await UserViewModel.Create(StreamingPlatformTypeEnum.Twitch, packet.UserID); user.TwitchID = packet.UserID; user.TwitchUsername = packet.UserLogin; user.SetTwitchRoles(); ChannelSession.Settings.SetUserData(user.Data); return(user); }