private async Task RunGameWispCommand(EventCommand command, GameWispSubscribeEvent subscribeEvent) { if (command != null) { UserViewModel user = new UserViewModel(0, subscribeEvent.Username); UserModel userModel = await ChannelSession.Connection.GetUser(subscribeEvent.Username); if (userModel != null) { user = new UserViewModel(userModel); } GameWispTier tier = null; if (ChannelSession.Services.GameWisp != null) { tier = ChannelSession.Services.GameWisp.ChannelInfo.GetActiveTiers().FirstOrDefault(t => t.ID.ToString().Equals(subscribeEvent.TierID)); } command.AddSpecialIdentifier("subscribemonths", subscribeEvent.SubscribeMonths.ToString()); command.AddSpecialIdentifier("subscribeamount", subscribeEvent.Amount); if (tier != null) { command.AddSpecialIdentifier("subscribetier", tier.Title); } await command.Perform(user); } }
public bool DoesMeetRequirement(UserViewModel user) { if (user.PrimaryRole == MixerRoleEnum.Streamer) { return(true); } else if (this.MixerRole == MixerRoleEnum.Follower) { return(user.IsFollower); } else if (this.MixerRole == MixerRoleEnum.Subscriber) { return(user.IsSubscriber); } else if (this.MixerRole == MixerRoleEnum.Custom && !string.IsNullOrEmpty(this.CustomRole)) { if (this.CustomRole.StartsWith(GameWispTier.MIURolePrefix)) { if (ChannelSession.Services.GameWisp != null && user.GameWispTier != null) { GameWispTier requirementTier = ChannelSession.Services.GameWisp.ChannelInfo.GetActiveTiers().FirstOrDefault(t => t.MIURoleName.Equals(this.CustomRole)); return(requirementTier != null && user.GameWispTier.Level >= requirementTier.Level); } return(false); } return(false); } else { return(user.PrimaryRole >= this.MixerRole); } }
private async Task RunGameWispCommand(EventCommand command, GameWispSubscribeEvent subscribeEvent) { if (command != null) { UserViewModel user = new UserViewModel(0, subscribeEvent.Username); UserModel userModel = await ChannelSession.Connection.GetUser(subscribeEvent.Username); if (userModel != null) { user = new UserViewModel(userModel); } GameWispTier tier = null; if (ChannelSession.Services.GameWisp != null) { tier = ChannelSession.Services.GameWisp.ChannelInfo.GetActiveTiers().FirstOrDefault(t => t.ID.ToString().Equals(subscribeEvent.TierID)); } Dictionary <string, string> specialIdentifiers = new Dictionary <string, string>(); specialIdentifiers["subscribemonths"] = subscribeEvent.SubscribeMonths.ToString(); specialIdentifiers["subscribeamount"] = subscribeEvent.Amount; if (tier != null) { specialIdentifiers["subscribetier"] = tier.Title; } await command.Perform(user, arguments : null, extraSpecialIdentifiers : specialIdentifiers); } }