diff --git a/MessageHeightTwitch.cs b/MessageHeightTwitch.cs index 6422851..ee2a43e 100644 --- a/MessageHeightTwitch.cs +++ b/MessageHeightTwitch.cs @@ -26,9 +26,9 @@ public CharacterProperty(float Width, bool CharWrapping) public static CharacterProperty[] CharacterProperties; public delegate bool Fx3rdPartyEmote(string Name, out SizeF Size); - private readonly Fx3rdPartyEmote BTTVGetEmote; - private readonly Fx3rdPartyEmote FFZGetEmote; - private readonly Fx3rdPartyEmote SevenTVGetEmote; + private readonly Fx3rdPartyEmote BTTVGetEmote = (string __, out SizeF _) => { _ = default; return false; }; + private readonly Fx3rdPartyEmote FFZGetEmote = (string __, out SizeF _) => { _ = default; return false; }; + private readonly Fx3rdPartyEmote SevenTVGetEmote = (string __, out SizeF _) => { _ = default; return false; }; private readonly Func TwitchGetEmote; private readonly Func BTTVIsEmojiSupported; @@ -70,19 +70,29 @@ public MessageHeightTwitch(string Channel, string ChannelId, int TimeoutMs, bool { var cts = new CancellationTokenSource(TimeoutMs); FFZEmoteProvider = new FFZEmoteProvider(); - FFZEmoteProvider.Initialize(Channel, cts.Token).GetAwaiter().GetResult(); + try { + FFZEmoteProvider.Initialize(Channel, cts.Token).GetAwaiter().GetResult(); + this.FFZGetEmote = FFZEmoteProvider.TryGetEmote; + } catch (Exception ex) { + Console.WriteLine("Failed to initialize FFZ: " + ex.ToString()); + } BTTVEmoteProvider = new BTTVEmoteProvider(); - BTTVEmoteProvider.Initialize(ChannelId, cts.Token).GetAwaiter().GetResult(); + try { + BTTVEmoteProvider.Initialize(ChannelId, cts.Token).GetAwaiter().GetResult(); + this.BTTVGetEmote = BTTVEmoteProvider.TryGetEmote; + } catch (Exception ex) { + Console.WriteLine("Failed to initialize BTTV: " + ex.ToString()); + } if (Enable7TVEmotes) { SevenTVEmoteProvider = new SevenTVEmoteProvider(); - SevenTVEmoteProvider.Initialize(ChannelId, cts.Token).GetAwaiter().GetResult(); - SevenTVGetEmote = SevenTVEmoteProvider.TryGetEmote; - } else { - SevenTVGetEmote = (string __, out SizeF _) => { _ = default; return false; }; + try { + SevenTVEmoteProvider.Initialize(ChannelId, cts.Token).GetAwaiter().GetResult(); + SevenTVGetEmote = SevenTVEmoteProvider.TryGetEmote; + } catch (Exception ex) { + Console.WriteLine("Failed to initialize 7TV: " + ex.ToString()); + } } TwitchEmotes = new TwitchEmotes(); - this.BTTVGetEmote = BTTVEmoteProvider.TryGetEmote; - this.FFZGetEmote = FFZEmoteProvider.TryGetEmote; this.TwitchGetEmote = TwitchEmotes.GetEmote; this.BTTVIsEmojiSupported = (e) => BTTVEmoteProvider.IsEmojiSupported(e); this.FFZIsEmojiSupported = (e) => FFZEmoteProvider.IsEmojiSupported(e);