@@ -198,18 +198,18 @@ public Notifier() {
198
198
log .error ("Failed to create Twitch Client." , exception );
199
199
}
200
200
201
- log .info ("Initializing Twitter Client..." );
202
- twitterSonic = new TwitterSonic ();
203
201
try {
202
+ log .info ("Initializing Twitter Client..." );
203
+ twitterSonic = new TwitterSonic ();
204
204
twitterClient = new TwitterClient (TwitterCredentials .builder ()
205
205
.bearerToken (Main .getInstance ().getConfig ().getConfiguration ().getString ("twitter.bearer" )).build ());
206
206
} catch (Exception exception ) {
207
207
log .error ("Failed to create Twitter Client." , exception );
208
208
}
209
209
210
- log .info ("Initializing Reddit Client..." );
211
- redditSonic = new RedditSonic ();
212
210
try {
211
+ log .info ("Initializing Reddit Client..." );
212
+ redditSonic = new RedditSonic ();
213
213
redditClient = Reddit4J
214
214
.rateLimited ()
215
215
.setClientId (Main .getInstance ().getConfig ().getConfiguration ().getString ("reddit.client.id" ))
@@ -225,87 +225,122 @@ public Notifier() {
225
225
Sentry .captureException (exception );
226
226
}
227
227
}
228
+ try {
229
+ log .info ("Initializing Instagram Client..." );
230
+ instagramSonic = new InstagramSonic ();
231
+ // Callable that returns inputted code from System.in
232
+ Callable <String > inputCode = () -> {
233
+ Scanner scanner = new Scanner (System .in );
234
+ log .error ("Please input code: " );
235
+ String code = scanner .nextLine ();
236
+ scanner .close ();
237
+ return code ;
238
+ };
239
+
240
+ // handler for challenge login
241
+ IGClient .Builder .LoginHandler challengeHandler = (client , response ) -> IGChallengeUtils .resolveChallenge (client , response , inputCode );
242
+
243
+ instagramClient = IGClient .builder ()
244
+ .username (Main .getInstance ().getConfig ().getConfiguration ().getString ("instagram.username" ))
245
+ .password (Main .getInstance ().getConfig ().getConfiguration ().getString ("instagram.password" ))
246
+ .onChallenge (challengeHandler ).build ();
247
+
248
+ instagramClient .sendLoginRequest ().exceptionally (throwable -> {
249
+ if (BotConfig .isDebug ()) {
250
+ log .error ("Failed to login to Instagram API, you can ignore this if you don't use Instagram." , throwable );
251
+ } else {
252
+ log .error ("Failed to login to Instagram API, you can ignore this if you don't use Instagram." );
253
+ log .error ("Error Message: {}" , throwable .getMessage ()
254
+ .replace ("com.github.instagram4j.instagram4j.exceptions.IGResponseException: " , "" )
255
+ .replace ("'" , "'" ));
256
+ }
257
+ return null ;
258
+ });
259
+ } catch (Exception exception ) {
260
+ log .error ("Failed to create Instagram Client." , exception );
261
+ }
228
262
229
- log .info ("Initializing Instagram Client..." );
230
- instagramSonic = new InstagramSonic ();
231
- // Callable that returns inputted code from System.in
232
- Callable <String > inputCode = () -> {
233
- Scanner scanner = new Scanner (System .in );
234
- log .error ("Please input code: " );
235
- String code = scanner .nextLine ();
236
- scanner .close ();
237
- return code ;
238
- };
239
-
240
- // handler for challenge login
241
- IGClient .Builder .LoginHandler challengeHandler = (client , response ) -> IGChallengeUtils .resolveChallenge (client , response , inputCode );
242
-
243
- instagramClient = IGClient .builder ()
244
- .username (Main .getInstance ().getConfig ().getConfiguration ().getString ("instagram.username" ))
245
- .password (Main .getInstance ().getConfig ().getConfiguration ().getString ("instagram.password" ))
246
- .onChallenge (challengeHandler ).build ();
247
-
248
- instagramClient .sendLoginRequest ().exceptionally (throwable -> {
249
- if (BotConfig .isDebug ()) {
250
- log .error ("Failed to login to Instagram API, you can ignore this if you don't use Instagram." , throwable );
251
- } else {
252
- log .error ("Failed to login to Instagram API, you can ignore this if you don't use Instagram." );
253
- log .error ("Error Message: {}" , throwable .getMessage ()
254
- .replace ("com.github.instagram4j.instagram4j.exceptions.IGResponseException: " , "" )
255
- .replace ("'" , "'" ));
256
- }
257
- return null ;
258
- });
259
-
260
- log .info ("Initializing Spotify Client..." );
261
- spotifySonic = new SpotifySonic ();
263
+ try {
264
+ log .info ("Initializing Spotify Client..." );
265
+ spotifySonic = new SpotifySonic ();
266
+ } catch (Exception exception ) {
267
+ log .error ("Failed to create Spotify Client." , exception );
268
+ }
262
269
263
270
log .info ("Initializing Streams..." );
264
271
265
- log .info ("Creating YouTube Streams..." );
266
- youTubeSonic = new YouTubeSonic ();
267
- ThreadUtil .createThread (x -> youTubeSonic .run (), x -> {
268
- log .error ("Failed to run YouTube Stream!" , x );
269
- Sentry .captureException (x );
270
- }, Duration .ofMinutes (5 ), true , true );
271
-
272
- log .info ("Creating Twitter Streams..." );
273
- ThreadUtil .createThread (x -> twitterSonic .run (), x -> {
274
- log .error ("Failed to run Twitter Follower count checker!" , x );
275
- Sentry .captureException (x );
276
- }, Duration .ofMinutes (5 ), true , true );
277
-
278
- log .info ("Creating RSS Streams..." );
279
- rssSonic = new RSSSonic ();
280
- ThreadUtil .createThread (x -> rssSonic .run (), x -> {
281
- log .error ("Failed to run RSS Feed Stream!" , x );
282
- Sentry .captureException (x );
283
- }, Duration .ofMinutes (3 ), true , true );
284
-
285
- log .info ("Creating TikTok Streams..." );
286
- tikTokSonic = new TikTokSonic ();
287
- ThreadUtil .createThread (x -> tikTokSonic .run (), x -> {
288
- log .error ("Failed to run TikTok Stream!" , x );
289
- Sentry .captureException (x );
290
- }, Duration .ofMinutes (5 ), true , true );
291
-
292
- log .info ("Creating Instagram Streams..." );
293
- ThreadUtil .createThread (x -> instagramSonic .run (), x -> {
294
- log .error ("Failed to run Instagram Stream!" , x );
295
- Sentry .captureException (x );
296
- }, Duration .ofMinutes (5 ), true , true );
297
-
298
- log .info ("Creating Reddit Streams..." );
299
- ThreadUtil .createThread (x -> redditSonic .run (), x -> {
300
- log .error ("Failed to run Reddit Stream!" , x );
301
- Sentry .captureException (x );
302
- }, Duration .ofMinutes (5 ), true , true );
303
-
304
- // Use 1 day instead of minutes, because Spotify release date is at max precise to the day
305
- log .info ("Creating Spotify Streams..." );
306
- ThreadUtil .createThread (x -> spotifySonic .run (), x -> {
307
- log .error ("Failed to run Spotify Stream!" , x );
308
- Sentry .captureException (x );
309
- }, Duration .ofDays (1 ), true , true );
272
+ try {
273
+ log .info ("Creating YouTube Streams..." );
274
+ youTubeSonic = new YouTubeSonic ();
275
+ ThreadUtil .createThread (x -> youTubeSonic .run (), x -> {
276
+ log .error ("Failed to run YouTube Stream!" , x );
277
+ Sentry .captureException (x );
278
+ }, Duration .ofMinutes (5 ), true , true );
279
+ } catch (Exception exception ) {
280
+ log .error ("Failed to create YouTube Streams." , exception );
281
+ }
282
+
283
+ try {
284
+ log .info ("Creating Twitter Streams..." );
285
+ ThreadUtil .createThread (x -> twitterSonic .run (), x -> {
286
+ log .error ("Failed to run Twitter Follower count checker!" , x );
287
+ Sentry .captureException (x );
288
+ }, Duration .ofMinutes (5 ), true , true );
289
+ } catch (Exception exception ) {
290
+ log .error ("Failed to create Twitter Streams." , exception );
291
+ }
292
+
293
+ try {
294
+ log .info ("Creating RSS Streams..." );
295
+ rssSonic = new RSSSonic ();
296
+ ThreadUtil .createThread (x -> rssSonic .run (), x -> {
297
+ log .error ("Failed to run RSS Feed Stream!" , x );
298
+ Sentry .captureException (x );
299
+ }, Duration .ofMinutes (3 ), true , true );
300
+ } catch (Exception exception ) {
301
+ log .error ("Failed to create RSS Streams." , exception );
302
+ }
303
+
304
+ try {
305
+ log .info ("Creating TikTok Streams..." );
306
+ tikTokSonic = new TikTokSonic ();
307
+ ThreadUtil .createThread (x -> tikTokSonic .run (), x -> {
308
+ log .error ("Failed to run TikTok Stream!" , x );
309
+ Sentry .captureException (x );
310
+ }, Duration .ofMinutes (5 ), true , true );
311
+ } catch (Exception exception ) {
312
+ log .error ("Failed to create TikTok Streams." , exception );
313
+ }
314
+
315
+ try {
316
+ log .info ("Creating Instagram Streams..." );
317
+ ThreadUtil .createThread (x -> instagramSonic .run (), x -> {
318
+ log .error ("Failed to run Instagram Stream!" , x );
319
+ Sentry .captureException (x );
320
+ }, Duration .ofMinutes (5 ), true , true );
321
+ } catch (Exception exception ) {
322
+ log .error ("Failed to create Instagram Streams." , exception );
323
+ }
324
+
325
+ try {
326
+ log .info ("Creating Reddit Streams..." );
327
+ ThreadUtil .createThread (x -> redditSonic .run (), x -> {
328
+ log .error ("Failed to run Reddit Stream!" , x );
329
+ Sentry .captureException (x );
330
+ }, Duration .ofMinutes (5 ), true , true );
331
+ } catch (Exception exception ) {
332
+ log .error ("Failed to create Reddit Streams." , exception );
333
+ }
334
+
335
+ try {
336
+ // Use 1 day instead of minutes, because Spotify release date is at max precise to the day
337
+ log .info ("Creating Spotify Streams..." );
338
+ ThreadUtil .createThread (x -> spotifySonic .run (), x -> {
339
+ log .error ("Failed to run Spotify Stream!" , x );
340
+ Sentry .captureException (x );
341
+ }, Duration .ofDays (1 ), true , true );
342
+ } catch (Exception exception ) {
343
+ log .error ("Failed to create Spotify Streams." , exception );
344
+ }
310
345
}
311
346
}
0 commit comments