@@ -33,7 +33,7 @@ public class TwitchApiProxy : ITwitchApiProxy {
33
33
/// Initializes a new instance of the <see cref="TwitchApiProxy" /> class.
34
34
/// </summary>
35
35
public TwitchApiProxy ( ) {
36
- TwitchAppConfig = new ( ) {
36
+ TwitchAppConfig = new TwitchAppConfig {
37
37
ClientId = Environment . GetEnvironmentVariable ( "TWITCH_BOT_CLIENT_ID" ) ,
38
38
ClientSecret = Environment . GetEnvironmentVariable ( "TWITCH_BOT_CLIENT_SECRET" ) ,
39
39
ClientRedirect = Environment . GetEnvironmentVariable ( "TWITCH_BOT_CLIENT_REDIRECT" )
@@ -46,21 +46,27 @@ public TwitchApiProxy() {
46
46
/// <param name="token">The access token.</param>
47
47
/// <param name="refreshToken">The refresh token.</param>
48
48
/// <param name="tokenExpires">When the token expires (utc).</param>
49
- /// <param name="clientId">The client id of the registered twitch app, uses environment variable
50
- /// "TWITCH_BOT_CLIENT_ID" when null.</param>
51
- /// <param name="clientSecret">The client secret of the registered twitch app, uses environment variable
52
- /// "TWITCH_BOT_CLIENT_SECRET" when null.</param>
53
- /// <param name="clientRedirect">The url to redirect to from the registered twitch app, uses environment variable
54
- /// "TWITCH_BOT_CLIENT_REDIRECT" when null.</param>
55
- public TwitchApiProxy ( string token , string refreshToken , DateTime tokenExpires , string ? clientId = null ,
49
+ /// <param name="clientId">
50
+ /// The client id of the registered twitch app, uses environment variable
51
+ /// "TWITCH_BOT_CLIENT_ID" when null.
52
+ /// </param>
53
+ /// <param name="clientSecret">
54
+ /// The client secret of the registered twitch app, uses environment variable
55
+ /// "TWITCH_BOT_CLIENT_SECRET" when null.
56
+ /// </param>
57
+ /// <param name="clientRedirect">
58
+ /// The url to redirect to from the registered twitch app, uses environment variable
59
+ /// "TWITCH_BOT_CLIENT_REDIRECT" when null.
60
+ /// </param>
61
+ public TwitchApiProxy ( string token , string refreshToken , DateTime tokenExpires , string ? clientId = null ,
56
62
string ? clientSecret = null , string ? clientRedirect = null ) {
57
63
OAuth = new TwitchAccessToken {
58
64
AccessToken = token ,
59
65
RefreshToken = refreshToken ,
60
66
ExpiresUtc = tokenExpires
61
67
} ;
62
-
63
- TwitchAppConfig = new ( ) {
68
+
69
+ TwitchAppConfig = new TwitchAppConfig {
64
70
ClientId = clientId ?? Environment . GetEnvironmentVariable ( "TWITCH_BOT_CLIENT_ID" ) ,
65
71
ClientSecret = clientSecret ?? Environment . GetEnvironmentVariable ( "TWITCH_BOT_CLIENT_SECRET" ) ,
66
72
ClientRedirect = clientRedirect ?? Environment . GetEnvironmentVariable ( "TWITCH_BOT_CLIENT_REDIRECT" )
@@ -74,14 +80,14 @@ public TwitchApiProxy(string token, string refreshToken, DateTime tokenExpires,
74
80
75
81
/// <inheritdoc />
76
82
public virtual TwitchAccessToken ? OAuth { get ; set ; }
77
-
83
+
78
84
/// <inheritdoc />
79
85
public virtual TwitchAppConfig ? TwitchAppConfig { get ; set ; }
80
86
81
87
/// <inheritdoc />
82
88
public virtual async Task < TwitchAccessToken ? > CreateAccessToken ( string code , CancellationToken token = new ( ) ) {
83
89
ITwitchAPI api = GetApi ( ) ;
84
- AuthCodeResponse ? response = await api . Auth . GetAccessTokenFromCodeAsync ( code , TwitchAppConfig ? . ClientSecret ,
90
+ AuthCodeResponse ? response = await api . Auth . GetAccessTokenFromCodeAsync ( code , TwitchAppConfig ? . ClientSecret ,
85
91
TwitchAppConfig ? . ClientRedirect ) ;
86
92
if ( null == response ) {
87
93
return null ;
@@ -101,7 +107,7 @@ public TwitchApiProxy(string token, string refreshToken, DateTime tokenExpires,
101
107
if ( string . IsNullOrWhiteSpace ( TwitchAppConfig ? . ClientSecret ) || string . IsNullOrWhiteSpace ( TwitchAppConfig ? . ClientId ) ) {
102
108
return null ;
103
109
}
104
-
110
+
105
111
ITwitchAPI api = GetApi ( ) ;
106
112
RefreshResponse ? response = await api . Auth . RefreshAuthTokenAsync ( OAuth ? . RefreshToken , TwitchAppConfig ? . ClientSecret , TwitchAppConfig ? . ClientId ) ;
107
113
if ( null == response ) {
@@ -145,7 +151,7 @@ public TwitchApiProxy(string token, string refreshToken, DateTime tokenExpires,
145
151
}
146
152
147
153
/// <inheritdoc />
148
- public virtual async Task < string ? > GetUserEmail ( CancellationToken token = new ( ) ) {
154
+ public virtual async Task < string ? > GetUserEmail ( CancellationToken token = new ( ) ) {
149
155
return await Retry . Execute ( async ( ) => {
150
156
ITwitchAPI api = GetApi ( ) ;
151
157
GetUsersResponse ? response = await api . Helix . Users . GetUsersAsync ( ) ;
@@ -158,7 +164,7 @@ public TwitchApiProxy(string token, string refreshToken, DateTime tokenExpires,
158
164
}
159
165
160
166
/// <inheritdoc />
161
- public virtual async Task < IEnumerable < TwitchModeratedChannel > > GetUserModChannels ( string userId ) {
167
+ public virtual async Task < IEnumerable < TwitchModeratedChannel > > GetUserModChannels ( string userId ) {
162
168
using var client = new HttpClient ( ) ;
163
169
164
170
var ret = new List < TwitchModeratedChannel > ( ) ;
@@ -189,7 +195,7 @@ public virtual async Task<IEnumerable<TwitchModeratedChannel>> GetUserModChanne
189
195
}
190
196
191
197
/// <inheritdoc />
192
- public virtual async Task < IEnumerable < BannedUser > > BanChannelUsers ( string channelId , string botId ,
198
+ public virtual async Task < IEnumerable < BannedUser > > BanChannelUsers ( string channelId , string botId ,
193
199
IEnumerable < ( string Id , string Username ) > users , string reason , CancellationToken token = new ( ) ) {
194
200
return await Retry . Execute ( async ( ) => {
195
201
ITwitchAPI api = GetApi ( ) ;
@@ -223,7 +229,7 @@ public virtual async Task<IEnumerable<BannedUser>> BanChannelUsers(string chann
223
229
}
224
230
225
231
/// <inheritdoc />
226
- public virtual async Task < IEnumerable < Chatter > > GetChannelUsers ( string channelId , string botId ,
232
+ public virtual async Task < IEnumerable < Chatter > > GetChannelUsers ( string channelId , string botId ,
227
233
CancellationToken token = new ( ) ) {
228
234
return await Retry . Execute ( async ( ) => {
229
235
ITwitchAPI api = GetApi ( ) ;
@@ -247,7 +253,7 @@ public virtual async Task<IEnumerable<Chatter>> GetChannelUsers(string channelI
247
253
}
248
254
249
255
/// <inheritdoc />
250
- public virtual async Task < IEnumerable < string > > GetChannelsLive ( IEnumerable < string > userIds ) {
256
+ public virtual async Task < IEnumerable < string > > GetChannelsLive ( IEnumerable < string > userIds ) {
251
257
ITwitchAPI api = GetApi ( ) ;
252
258
253
259
// We can only query 100 at a time, so throttle the search.
@@ -271,7 +277,7 @@ public virtual async Task<IEnumerable<string>> GetChannelsLive(IEnumerable<stri
271
277
}
272
278
273
279
/// <inheritdoc />
274
- public virtual async Task < IEnumerable < Moderator > > GetChannelMods ( string channelId , CancellationToken token = new ( ) ) {
280
+ public virtual async Task < IEnumerable < Moderator > > GetChannelMods ( string channelId , CancellationToken token = new ( ) ) {
275
281
return await Retry . Execute ( async ( ) => {
276
282
ITwitchAPI api = GetApi ( ) ;
277
283
@@ -298,7 +304,7 @@ public virtual async Task<IEnumerable<string>> GetChannelsLive(IEnumerable<stri
298
304
}
299
305
300
306
/// <inheritdoc />
301
- public virtual async Task < bool > AddChannelMod ( string channelId , string userId , CancellationToken token = new ( ) ) {
307
+ public virtual async Task < bool > AddChannelMod ( string channelId , string userId , CancellationToken token = new ( ) ) {
302
308
return await Retry . Execute ( async ( ) => {
303
309
ITwitchAPI api = GetApi ( ) ;
304
310
await api . Helix . Moderation . AddChannelModeratorAsync ( channelId , userId ) ;
0 commit comments