Ejemplo n.º 1
0
 public User(ChatterFormatted chatter) : base(chatter)
 {
     Id         = chatter.Username;
     Nickname   = chatter.Username;
     Status     = "";
     Attributes = new string[0];
 }
Ejemplo n.º 2
0
        public static ChatUser ToChatUser(this ChatterFormatted chatterFormatted)
        {
            var chatUser = new ChatUser
            {
                DisplayName = chatterFormatted.Username,
                Role        = chatterFormatted.UserType.ToUserRole()
            };

            return(chatUser);
        }
Ejemplo n.º 3
0
        public static TwitchUser GetById(ulong id, UserLevel userLevel = UserLevel.Unknown)
        {
            TwitchLib.Api.V5.Models.Users.User user = TwitchBot.TwitchApi.V5.Users.GetUserByIDAsync(id.ToString()).Result;

            if (user == null)
            {
                return(null);
            }

            if (userLevel == UserLevel.Unknown)
            {
                ChatterFormatted chatter = TwitchBot.TwitchApi.Undocumented.GetChattersAsync(Configuration.TwitchChannelName).Result.Find(c => c.Username == user.Name);

                if (chatter != null)
                {
                    userLevel = chatter.UserType.ToUserLevel();
                }
            }

            return(new TwitchUser(userLevel, user.DisplayName, ulong.Parse(user.Id)));
        }
Ejemplo n.º 4
0
        public static TwitchUser GetByName(string name, UserLevel userLevel = UserLevel.Unknown)
        {
            Users users = TwitchBot.TwitchApi.V5.Users.GetUserByNameAsync(name).Result;

            if (users.Matches.Length == 0)
            {
                return(null);
            }

            if (userLevel == UserLevel.Unknown)
            {
                ChatterFormatted chatter = TwitchBot.TwitchApi.Undocumented.GetChattersAsync(Configuration.TwitchChannelName).Result.Find(c => c.Username == name);

                if (chatter != null)
                {
                    userLevel = chatter.UserType.ToUserLevel();
                }
            }

            TwitchLib.Api.V5.Models.Users.User user = users.Matches[0];

            return(new TwitchUser(userLevel, user.DisplayName, ulong.Parse(user.Id)));
        }