public async Task UpdateV5Channel(V5API.Channel.ChannelModel channel, string status = null, GameModel game = null)
 {
     ChannelUpdateModel update = new ChannelUpdateModel()
     {
         status = (!string.IsNullOrEmpty(status)) ? status : null,
         game   = (game != null) ? game.name : null
     };
     await AsyncRunner.RunAsync(this.Connection.V5API.Channels.UpdateChannel(channel, update));
 }
Example #2
0
 public async Task UnbanUser(UserViewModel user)
 {
     await AsyncRunner.RunAsync(async() =>
     {
         if (this.userClient != null)
         {
             await this.userClient.UnbanUser((UserModel)ChannelSession.TwitchUserNewAPI, user.GetTwitchNewAPIUserModel());
         }
     });
 }
Example #3
0
 public async Task RunCommercial(int lengthInSeconds)
 {
     await AsyncRunner.RunAsync(async() =>
     {
         if (this.userClient != null)
         {
             await this.userClient.RunCommercial((UserModel)ChannelSession.TwitchUserNewAPI, lengthInSeconds);
         }
     });
 }
Example #4
0
 public async Task TimeoutUser(UserViewModel user, int lengthInSeconds)
 {
     await AsyncRunner.RunAsync(async() =>
     {
         if (this.userClient != null)
         {
             await this.userClient.TimeoutUser((UserModel)ChannelSession.TwitchUserNewAPI, user.GetTwitchNewAPIUserModel(), lengthInSeconds);
         }
     });
 }
Example #5
0
 public async Task ClearMessages()
 {
     await AsyncRunner.RunAsync(async() =>
     {
         if (this.userClient != null)
         {
             await this.userClient.ClearChat((UserModel)ChannelSession.TwitchUserNewAPI);
         }
     });
 }
Example #6
0
 public async Task DeleteMessage(ChatMessageViewModel message)
 {
     await AsyncRunner.RunAsync(async() =>
     {
         if (this.userClient != null)
         {
             await this.userClient.DeleteMessage((UserModel)ChannelSession.TwitchUserNewAPI, message.ID);
         }
     });
 }
        protected async Task <IEnumerable <T> > RunAsync <T>(Task <IEnumerable <T> > task)
        {
            IEnumerable <T> result = null;

            try
            {
                result = await AsyncRunner.RunAsync(task);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }

            if (result == null)
            {
                result = ReflectionHelper.CreateInstanceOf <List <T> >();
            }
            return(result);
        }
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            List <bool> results = new List <bool>();

            foreach (ConditionalClauseModel clause in this.Clauses)
            {
                results.Add(await this.Check(clause, user, arguments));
            }

            bool finalResult = false;

            if (this.Operator == ConditionalOperatorTypeEnum.And)
            {
                finalResult = results.All(r => r);
            }
            else if (this.Operator == ConditionalOperatorTypeEnum.Or)
            {
                finalResult = results.Any(r => r);
            }
            else if (this.Operator == ConditionalOperatorTypeEnum.ExclusiveOr)
            {
                finalResult = results.Count(r => r) == 1;
            }

            if (finalResult)
            {
                if (this.CommandID != Guid.Empty)
                {
                    CommandBase command = this.GetCommand();
                    if (command != null)
                    {
                        await command.Perform(user, this.platform, arguments, this.GetExtraSpecialIdentifiers());
                    }
                }
                else if (this.Action != null)
                {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    AsyncRunner.RunAsync(this.Action.Perform(user, this.platform, arguments, this.GetExtraSpecialIdentifiers()));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                }
            }
        }
 public async Task <NewAPI.Predictions.PredictionModel> CreatePrediction(NewAPI.Predictions.CreatePredictionModel prediction)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Predictions.CreatePrediction(prediction)));
 }
 public async Task <NewAPI.Polls.PollModel> CreatePoll(NewAPI.Polls.CreatePollModel poll)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Polls.CreatePoll(poll)));
 }
 public async Task <NewAPI.Bits.BitsLeaderboardModel> GetBitsLeaderboard(NewAPIServices.BitsLeaderboardPeriodEnum period, int count)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Bits.GetBitsLeaderboard(startedAt: DateTimeOffset.Now, period: period, count: count)));
 }
 public async Task <NewAPI.Clips.ClipCreationModel> CreateClip(NewAPI.Users.UserModel channel, bool delay)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Clips.CreateClip(channel, delay)));
 }
 public async Task <bool> GetStreamTagsForChannel(NewAPI.Users.UserModel channel, IEnumerable <NewAPI.Tags.TagModel> tags)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Tags.UpdateStreamTags(channel, tags)));
 }
 public async Task <bool> UpdateChannelInformation(NewAPI.Users.UserModel channel, string title = null, string gameID = null)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Channels.UpdateChannelInformation(channel, title, gameID)));
 }
 public async Task <V5API.Channel.ChannelModel> GetV5APIChannel(string channelID)
 {
     return(await AsyncRunner.RunAsync(this.Connection.V5API.Channels.GetChannelByID(channelID)));
 }
 public async Task <NewAPI.Games.GameModel> GetNewAPIGameByID(string id)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Games.GetGameByID(id)));
 }
 public async Task <NewAPI.Channels.ChannelInformationModel> GetChannelInformation(NewAPI.Users.UserModel channel)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Channels.GetChannelInformation(channel)));
 }
 public async Task <V5API.Users.UserSubscriptionModel> CheckIfSubscribedV5(V5API.Channel.ChannelModel channel, V5API.Users.UserModel userToCheck)
 {
     return(await AsyncRunner.RunAsync(this.Connection.V5API.Channels.GetChannelUserSubscription(channel, userToCheck)));
 }
 public async Task <CreatedStreamMarkerModel> CreateStreamMarker(NewAPI.Users.UserModel channel, string description)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Streams.CreateStreamMarker(channel, description)));
 }
 public async Task <long> GetSubscriberCountV5(V5API.Channel.ChannelModel channel)
 {
     return(await AsyncRunner.RunAsync(this.Connection.V5API.Channels.GetChannelSubscribersCount(channel)));
 }
 public async Task <NewAPI.Ads.AdResponseModel> RunAd(NewAPI.Users.UserModel channel, int length)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Ads.RunAd(channel, length)));
 }
 public async Task <V5API.Streams.StreamModel> GetV5LiveStream(V5API.Channel.ChannelModel channel)
 {
     return(await AsyncRunner.RunAsync(this.Connection.V5API.Streams.GetChannelStream(channel)));
 }
 public async Task <NewAPI.Clips.ClipModel> GetClip(NewAPI.Clips.ClipCreationModel clip)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Clips.GetClip(clip)));
 }
 public async Task <TeamDetailsModel> GetTeamDetails(TeamModel team)
 {
     return(await AsyncRunner.RunAsync(this.Connection.V5API.Teams.GetTeam(team)));
 }
 public async Task <NewAPI.ChannelPoints.CustomChannelPointRewardModel> UpdateCustomChannelPointReward(NewAPI.Users.UserModel broadcaster, Guid id, JObject jobj)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.ChannelPoints.UpdateCustomReward(broadcaster, id, jobj)));
 }
        // New API Methods

        public async Task <NewAPI.Users.UserModel> GetNewAPICurrentUser()
        {
            return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Users.GetCurrentUser()));
        }
 public async Task <NewAPI.Polls.PollModel> GetPoll(NewAPI.Users.UserModel broadcaster, string pollID)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Polls.GetPoll(broadcaster, pollID)));
 }
 public async Task <NewAPI.Users.UserModel> GetNewAPIUserByID(string userID)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Users.GetUserByID(userID)));
 }
 public async Task <NewAPI.Predictions.PredictionModel> GetPrediction(NewAPI.Users.UserModel broadcaster, string predictionID)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Predictions.GetPrediction(broadcaster, predictionID)));
 }
 public async Task <NewAPI.Users.UserModel> GetNewAPIUserByLogin(string login)
 {
     return(await AsyncRunner.RunAsync(this.Connection.NewAPI.Users.GetUserByLogin(login)));
 }