@@ -46,7 +46,7 @@ public TeamCommand(IConfiguration configuration, ILoggerFactory loggerFactory, I
46
46
if ( ! string . IsNullOrEmpty ( TwitchTokenConfig . Tokens ? . access_token ) )
47
47
{
48
48
_HttpClient = httpClientFactory . CreateClient ( "TeamLookup" ) ;
49
- _HttpClient . BaseAddress = new Uri ( $ "https://api.twitch.tv/kraken /teams/ ") ;
49
+ _HttpClient . BaseAddress = new Uri ( $ "https://api.twitch.tv/helix /teams") ;
50
50
_HttpClient . DefaultRequestHeaders . Add ( "Client-ID" , configuration [ "StreamServices:Twitch:ClientId" ] ) ;
51
51
_HttpClient . DefaultRequestHeaders . Add ( "Accept" , "application/vnd.twitchtv.v5+json" ) ;
52
52
@@ -65,9 +65,11 @@ public TeamCommand(IConfiguration configuration, ILoggerFactory loggerFactory, I
65
65
private void SendNotificationsToWidget ( )
66
66
{
67
67
68
- while ( true ) {
68
+ while ( true )
69
+ {
69
70
70
- if ( _TeammateNotifications . TryPeek ( out var _ ) ) {
71
+ if ( _TeammateNotifications . TryPeek ( out var _ ) )
72
+ {
71
73
72
74
_Context . Clients . All . SendAsync ( "Teammate" , _TeammateNotifications . Dequeue ( ) ) ;
73
75
Task . Delay ( 5000 ) . GetAwaiter ( ) . GetResult ( ) ; // TODO: This notification needs to go into a queue
@@ -111,53 +113,41 @@ public async Task Execute(IChatService chatService, string userName, string full
111
113
private async Task GetTeammates ( )
112
114
{
113
115
114
- var response = await _HttpClient . GetStringAsync ( _TeamName ) ;
116
+ var response = await _HttpClient . GetStringAsync ( $ "?name= { _TeamName } " ) ;
115
117
var team = JsonConvert . DeserializeObject < TeamResponse > ( response ) ;
116
118
117
- _Teammates = team . users . Select ( u => u . name ) . ToHashSet ( ) ;
119
+ _Teammates = team . data . First ( ) . users . Select ( u => u . user_name ) . ToHashSet ( ) ;
118
120
119
121
}
120
122
121
123
122
- internal class TeamResponse
124
+ public class TeamResponse
123
125
{
124
- public int _id { get ; set ; }
125
- public object background { get ; set ; }
126
- public string banner { get ; set ; }
127
- public DateTime created_at { get ; set ; }
128
- public string display_name { get ; set ; }
129
- public string info { get ; set ; }
130
- public string logo { get ; set ; }
131
- public string name { get ; set ; }
132
- public DateTime updated_at { get ; set ; }
133
- public User [ ] users { get ; set ; }
126
+ public TeamSummary [ ] data { get ; set ; }
134
127
}
135
128
136
-
137
- internal class User
129
+ public class TeamSummary
138
130
{
139
- public int _id { get ; set ; }
140
- public string broadcaster_language { get ; set ; }
131
+ public User [ ] users { get ; set ; }
132
+ public object background_image_url { get ; set ; }
133
+ public object banner { get ; set ; }
141
134
public DateTime created_at { get ; set ; }
142
- public string display_name { get ; set ; }
143
- public int followers { get ; set ; }
144
- public string game { get ; set ; }
145
- public string language { get ; set ; }
146
- public string logo { get ; set ; }
147
- public bool mature { get ; set ; }
148
- public string name { get ; set ; }
149
- public bool partner { get ; set ; }
150
- public string profile_banner { get ; set ; }
151
- public object profile_banner_background_color { get ; set ; }
152
- public string status { get ; set ; }
153
135
public DateTime updated_at { get ; set ; }
154
- public string url { get ; set ; }
155
- public object video_banner { get ; set ; }
156
- public int views { get ; set ; }
136
+ public string info { get ; set ; }
137
+ public string thumbnail_url { get ; set ; }
138
+ public string team_name { get ; set ; }
139
+ public string team_display_name { get ; set ; }
140
+ public string id { get ; set ; }
141
+ }
142
+
143
+ public class User
144
+ {
145
+ public string user_id { get ; set ; }
146
+ public string user_name { get ; set ; }
147
+ public string user_login { get ; set ; }
157
148
}
158
149
159
150
160
151
}
161
152
162
-
163
153
}
0 commit comments