using TightWiki.Engine.Library; using TightWiki.Engine.Library.Interfaces; using TightWiki.Models; using static TightWiki.Engine.Library.Constants; namespace TightWiki.Engine.Implementation { /// /// Handles wiki emojis. /// public class EmojiHandler : IEmojiHandler { /// /// Handles an emoji instruction. /// /// Reference to the wiki state object /// The lookup key for the given emoji. /// The desired 1-100 scale factor for the emoji. public HandlerResult Handle(ITightEngineState state, string key, int scale) { var emoji = GlobalConfiguration.Emojis.FirstOrDefault(o => o.Shortcut == key); if (GlobalConfiguration.Emojis.Exists(o => o.Shortcut == key)) { if (scale != 100 && scale > 0 && scale <= 500) { var emojiImage = $"\"{emoji?.Name}\""; return new HandlerResult(emojiImage); } else { var emojiImage = $"\"{emoji?.Name}\""; return new HandlerResult(emojiImage); } } else { return new HandlerResult(key) { Instructions = [HandlerResultInstruction.DisallowNestedProcessing] }; } } } }