/// <summary>
 /// Sends a message to the specified broadcaster's channel.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel to send the message to</param>
 /// <param name="user">The user to whisper</param>
 /// <param name="message">The message to send</param>
 /// <returns>An awaitable Task</returns>
 public async Task SendWhisperMessage(V5.Users.UserModel broadcaster, V5.Users.UserModel user, string message)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     Validator.ValidateVariable(user, "user");
     Validator.ValidateString(message, "message");
     await this.Send(string.Format("PRIVMSG #{0} :.w {1} {2}", broadcaster.name, user.name, message));
 }
 /// <summary>
 /// Sends a reply message to the specified broadcaster's channel and message ID.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel to send the message to</param>
 /// <param name="message">The message to send</param>
 /// <param name="messageID">The message ID to reply to</param>
 /// <returns>An awaitable Task</returns>
 public async Task SendReplyMessage(V5.Users.UserModel broadcaster, string message, string messageID)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     Validator.ValidateString(message, "message");
     Validator.ValidateString(messageID, "messageID");
     await this.Send(string.Format("@reply-parent-msg-id={0} PRIVMSG #{1} :{2}", messageID, broadcaster.name, message));
 }
Example #3
0
        private async Task RefreshTwitchUserAccountDate()
        {
            TwitchV5API.Users.UserModel twitchV5User = await ChannelSession.TwitchUserConnection.GetV5APIUserByLogin(this.TwitchUsername);

            if (twitchV5User != null && !string.IsNullOrEmpty(twitchV5User.created_at))
            {
                this.AccountDate = TwitchPlatformService.GetTwitchDateTime(twitchV5User.created_at);
            }
        }
Example #4
0
        public UserViewModel(TwitchV5API.Users.UserModel twitchUser)
        {
            this.SetUserData(twitchID: twitchUser.id);

            this.TwitchID          = twitchUser.id;
            this.TwitchUsername    = twitchUser.name;
            this.TwitchDisplayName = (!string.IsNullOrEmpty(twitchUser.display_name)) ? twitchUser.display_name : this.TwitchUsername;
            this.TwitchAvatarLink  = twitchUser.logo;

            this.SetTwitchRoles();
        }
Example #5
0
        public static async Task <UserViewModel> Create(TwitchV5API.Users.UserModel twitchUser)
        {
            UserViewModel user = await UserViewModel.Create(StreamingPlatformTypeEnum.Twitch, twitchUser.id);

            user.TwitchID          = twitchUser.id;
            user.TwitchUsername    = twitchUser.name;
            user.TwitchDisplayName = (!string.IsNullOrEmpty(twitchUser.display_name)) ? twitchUser.display_name : user.TwitchUsername;
            user.TwitchAvatarLink  = twitchUser.logo;

            user.SetTwitchRoles();

            ChannelSession.Settings.SetUserData(user.Data);

            return(user);
        }
        public static async Task RefreshUser()
        {
            if (ChannelSession.TwitchUserNewAPI != null)
            {
                TwitchNewAPI.Users.UserModel twitchUserNewAPI = await ChannelSession.TwitchUserConnection.GetNewAPICurrentUser();

                if (twitchUserNewAPI != null)
                {
                    ChannelSession.TwitchUserNewAPI = twitchUserNewAPI;

                    TwitchV5API.Users.UserModel twitchUserV5 = await ChannelSession.TwitchUserConnection.GetV5APIUserByLogin(ChannelSession.TwitchUserNewAPI.login);

                    if (twitchUserV5 != null)
                    {
                        ChannelSession.TwitchUserV5 = twitchUserV5;
                    }
                }
            }
        }
 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)));
 }
 /// <summary>
 /// Runs a commercial for the specified time length in specified broadcaster's channel.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel</param>
 /// <param name="lengthInSeconds">The length of the commercial</param>
 /// <returns>An awaitable Task</returns>
 public async Task RunCommercial(V5.Users.UserModel broadcaster, int lengthInSeconds)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     await this.Send(string.Format("PRIVMSG #{0} :.commercial {1}", broadcaster.name, lengthInSeconds));
 }
 /// <summary>
 /// Bans the specified user in specified broadcaster's channel.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel</param>
 /// <param name="user">The user to ban</param>
 /// <returns>An awaitable Task</returns>
 public async Task UnbanUser(V5.Users.UserModel broadcaster, V5.Users.UserModel user)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     Validator.ValidateVariable(user, "user");
     await this.Send(string.Format("PRIVMSG #{0} :.unban {1}", broadcaster.name, user.name));
 }
 /// <summary>
 /// Clears all messages from chat.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel to use</param>
 /// <returns>An awaitable Task</returns>
 public async Task ClearChat(V5.Users.UserModel broadcaster)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     await this.Send(string.Format("PRIVMSG #{0} :.clear", broadcaster.name));
 }
 /// <summary>
 /// Purges a user's messages.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel to use</param>
 /// <param name="targetUser">The target user to purge</param>
 /// <param name="lengthInSeconds">The length in seconds to time out for</param>
 /// <returns>An awaitable Task</returns>
 public async Task TimeoutUser(V5.Users.UserModel broadcaster, V5.Users.UserModel targetUser, int lengthInSeconds)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     Validator.ValidateVariable(targetUser, "targetUser");
     await this.Send(string.Format("PRIVMSG #{0} :.timeout {1} {2}", broadcaster.name, targetUser.name, lengthInSeconds));
 }
 /// <summary>
 /// Deletes the specified message.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel to use</param>
 /// <param name="messageID">The ID of the message to clear</param>
 /// <returns>An awaitable Task</returns>
 public async Task DeleteMessage(V5.Users.UserModel broadcaster, string messageID)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     Validator.ValidateString(messageID, "messageID");
     await this.Send(string.Format("PRIVMSG #{0} :/delete {1}", broadcaster.name, messageID));
 }
 /// <summary>
 /// Leaves the specified broadcaster's channel.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel to leave</param>
 /// <returns>An awaitable Task</returns>
 public async Task Leave(V5.Users.UserModel broadcaster)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     await this.Send("PART #" + broadcaster.name);
 }
 /// <summary>
 /// Joins the specified broadcaster's channel in the specified room.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel to join</param>
 /// <param name="room">The room to join</param>
 /// <returns>An awaitable Task</returns>
 public async Task Join(V5.Users.UserModel broadcaster, V5.Chat.ChatRoomModel room)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     Validator.ValidateVariable(room, "room");
     await this.Send(string.Format("JOIN #chatrooms:{0}:{1}" + broadcaster.id, room.id));
 }
 /// <summary>
 /// Joins the specified broadcaster's channel.
 /// </summary>
 /// <param name="broadcaster">The broadcaster's channel to join</param>
 /// <returns>An awaitable Task</returns>
 public async Task Join(V5.Users.UserModel broadcaster)
 {
     Validator.ValidateVariable(broadcaster, "broadcaster");
     await this.Send("JOIN #" + broadcaster.name);
 }
 public async Task <IEnumerable <V5API.Emotes.EmoteModel> > GetEmotesForUserV5(V5API.Users.UserModel user)
 {
     return(await this.RunAsync(this.Connection.V5API.Users.GetUserEmotes(user)));
 }