public override async Task <int> ExecuteAsync(CommandContext context, Settings settings)
        {
            var output = new DirectoryPath(settings.Output);

            if (!_fileSystem.Directory.Exists(settings.Output))
            {
                _fileSystem.Directory.Create(settings.Output);
            }

            var stream = await FetchEmojis(settings);

            var document = await _parser.ParseDocumentAsync(stream);

            var emojis = Emoji.Parse(document).OrderBy(x => x.Name)
                         .Where(emoji => !emoji.HasCombinators)
                         .ToList();

            // Render all templates
            foreach (var(templateFilename, outputFilename) in _templates)
            {
                var result = await RenderTemplate(new FilePath(templateFilename), emojis);

                var outputPath = output.CombineWithFilePath(outputFilename);
                await File.WriteAllTextAsync(outputPath.FullPath, result);
            }

            return(0);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an <see cref="EmbedBuilder"/> object for a <see cref="WorldCurrencyResponse"/>.
        /// </summary>
        /// <param name="worldCurrencyResponse">The world currency response.</param>
        /// <param name="currencyName">The currency name.</param>
        /// <param name="amount">The amount to rate against.</param>
        /// <returns>An <see cref="EmbedBuilder"/> object ready to be built.</returns>
        public async Task <EmbedBuilder> CreateWorldCurrencyEmbedAsync(WorldCurrencyResponse worldCurrencyResponse, string currencyName, decimal amount = 1)
        {
            var    emojis           = Configuration.GetSection("customEmojis");
            Emoji  currencyEmoji    = Emoji.Parse(":flag_ar:");
            Emoji  whatsappEmoji    = new(emojis["whatsapp"]);
            Emoji  amountEmoji      = Emoji.Parse(":moneybag:");
            string currencyImageUrl = Configuration.GetSection("images").GetSection("coins")["64"];
            string footerImageUrl   = Configuration.GetSection("images").GetSection("clock")["32"];

            string       blankSpace    = GlobalConfiguration.Constants.BLANK_SPACE;
            TimeZoneInfo localTimeZone = GlobalConfiguration.GetLocalTimeZoneInfo();
            int          utcOffset     = localTimeZone.GetUtcOffset(DateTime.UtcNow).Hours;
            string       lastUpdated   = worldCurrencyResponse.Fecha.ToString(worldCurrencyResponse.Fecha.Date == TimeZoneInfo.ConvertTime(DateTime.UtcNow, localTimeZone).Date ? "HH:mm" : "dd/MM/yyyy - HH:mm");
            string       amountField   = Format.Bold($"{amountEmoji} {blankSpace} {amount} {worldCurrencyResponse.Code}");

            decimal?valuePrice = decimal.TryParse(worldCurrencyResponse?.Valor, NumberStyles.Any, DolarBotApiService.GetApiCulture(), out decimal v) ? v * amount : null;
            string  value      = valuePrice.HasValue ? valuePrice.Value.ToString("N2", GlobalConfiguration.GetLocalCultureInfo()) : "?";

            string       shareText = $"*{currencyName} ({worldCurrencyResponse.Code})*{Environment.NewLine}{Environment.NewLine}*{amount} {worldCurrencyResponse.Code}*{Environment.NewLine}Valor: \t$ *{value}*{Environment.NewLine}Hora: \t{lastUpdated} (UTC {utcOffset})";
            EmbedBuilder embed     = new EmbedBuilder().WithColor(GlobalConfiguration.Colors.Currency)
                                     .WithTitle($"{currencyName} ({worldCurrencyResponse.Code})")
                                     .WithDescription($"Cotización de {Format.Bold($"{currencyName} ({worldCurrencyResponse.Code})")} expresada en {Format.Bold("pesos argentinos")}.".AppendLineBreak())
                                     .WithThumbnailUrl(currencyImageUrl)
                                     .WithFooter(new EmbedFooterBuilder()
            {
                Text    = $"Ultima actualización: {lastUpdated} (UTC {utcOffset})",
                IconUrl = footerImageUrl
            })
                                     .AddInlineField("Monto", amountField)
                                     .AddInlineField($"Valor", $"{Format.Bold($"{currencyEmoji} ${blankSpace} {value.AppendLineBreak()}")}");

            await embed.AddFieldWhatsAppShare(whatsappEmoji, shareText, Api.Cuttly.ShortenUrl);

            return(embed.AddPlayStoreLink(Configuration));
        }
Esempio n. 3
0
        /// <summary>
        /// Creates an <see cref="EmbedBuilder"/> object for a <see cref="VzlaResponse"/>.
        /// </summary>
        /// <param name="vzlaResponse">The Venezuela response.</param>
        /// <param name="amount">The amount to rate against.</param>
        /// <returns>An <see cref="EmbedBuilder"/> object ready to be built.</returns>
        public async Task <EmbedBuilder> CreateVzlaEmbedAsync(VzlaResponse vzlaResponse, decimal amount = 1)
        {
            var   emojis        = Configuration.GetSection("customEmojis");
            Emoji currencyEmoji = GetEmoji(vzlaResponse.Type);
            Emoji bankEmoji     = new(":bank:");
            Emoji moneyEmoji    = new(":money_with_wings:");
            Emoji whatsappEmoji = new(emojis["whatsapp"]);
            Emoji amountEmoji   = Emoji.Parse(":moneybag:");

            string       blankSpace    = GlobalConfiguration.Constants.BLANK_SPACE;
            TimeZoneInfo localTimeZone = GlobalConfiguration.GetLocalTimeZoneInfo();
            int          utcOffset     = localTimeZone.GetUtcOffset(DateTime.UtcNow).Hours;

            string thumbnailUrl   = Configuration.GetSection("images").GetSection("venezuela")["64"];
            string footerImageUrl = Configuration.GetSection("images").GetSection("clock")["32"];
            string currencyCode   = vzlaResponse.Type switch
            {
                VenezuelaEndpoints.Dollar => "USD",
                VenezuelaEndpoints.Euro => "EUR",
                _ => throw new NotImplementedException(),
            };

            decimal?bancosValue       = decimal.TryParse(vzlaResponse?.Bancos, NumberStyles.Any, DolarBotApiService.GetApiCulture(), out decimal b) ? b * amount : null;
            decimal?paraleloValue     = decimal.TryParse(vzlaResponse?.Paralelo, NumberStyles.Any, DolarBotApiService.GetApiCulture(), out decimal p) ? p * amount : null;
            string  bancosValueText   = bancosValue.HasValue ? Format.Bold($"B$ {bancosValue.Value.ToString("N2", GlobalConfiguration.GetLocalCultureInfo())}") : "No informado";
            string  paraleloValueText = paraleloValue.HasValue ? Format.Bold($"B$ {paraleloValue.Value.ToString("N2", GlobalConfiguration.GetLocalCultureInfo())}") : "No informado";

            string title       = $"{GetName(vzlaResponse.Type).Capitalize()} Venezuela";
            string description = new StringBuilder()
                                 .AppendLine($"Cotizaciones disponibles del {Format.Bold(GetName(vzlaResponse.Type))} expresadas en {Format.Bold("bolívares venezolanos")}.")
                                 .AppendLineBreak()
                                 .AppendLine($"{bankEmoji} {Format.Bold("Bancos")}: {Format.Italics("Promedio de las cotizaciones bancarias")}.")
                                 .Append($"{moneyEmoji} {Format.Bold("Paralelo")}: {Format.Italics($"Cotización del {GetName(vzlaResponse.Type).ToLower()} paralelo")}.")
                                 .ToString();
            string lastUpdated = vzlaResponse.Fecha.ToString(vzlaResponse.Fecha.Date == TimeZoneInfo.ConvertTime(DateTime.UtcNow, localTimeZone).Date ? "HH:mm" : "dd/MM/yyyy - HH:mm");

            string amountField = Format.Bold($"{amountEmoji} {blankSpace} {amount} {currencyCode}").AppendLineBreak();
            string shareText   = $"*{title}*{Environment.NewLine}{Environment.NewLine}*{amount} {currencyCode}*{Environment.NewLine}Bancos: \t\tB$ *{bancosValue.GetValueOrDefault().ToString("N2", GlobalConfiguration.GetLocalCultureInfo())}*{Environment.NewLine}Paralelo: \t\tB$ *{paraleloValue.GetValueOrDefault().ToString("N2", GlobalConfiguration.GetLocalCultureInfo())}*{Environment.NewLine}Hora: \t\t{lastUpdated} (UTC {utcOffset})";

            EmbedBuilder embed = new EmbedBuilder().WithColor(GlobalConfiguration.Colors.Venezuela)
                                 .WithTitle(title)
                                 .WithDescription(description.ToString().AppendLineBreak())
                                 .WithThumbnailUrl(thumbnailUrl)
                                 .WithFooter(new EmbedFooterBuilder()
            {
                Text    = $"Ultima actualización: {lastUpdated} (UTC {utcOffset})",
                IconUrl = footerImageUrl
            })
                                 .AddField("Monto", amountField)
                                 .AddInlineField($"{bankEmoji} Bancos", $"{currencyEmoji} {blankSpace} {bancosValueText} {blankSpace}")
                                 .AddInlineField($"{moneyEmoji} Paralelo", $"{currencyEmoji} {blankSpace} {paraleloValueText} {blankSpace}".AppendLineBreak());

            await embed.AddFieldWhatsAppShare(whatsappEmoji, shareText, Api.Cuttly.ShortenUrl);

            return(embed.AddPlayStoreLink(Configuration));
        }
        private static async Task MessageReceived(SocketMessage msg)
        {
            if (msg.Content == "1")
            {
                await msg.Channel.SendMessageAsync(
                    text : "Заебал. Ну скажи уже блядь по человечески шо ты хочешь, Хлопчик",
                    messageReference : msg.Reference
                    );

                await msg.AddReactionAsync(Emoji.Parse("⚧"));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Creates an <see cref="EmbedBuilder"/> object for a single crypto response.
        /// </summary>
        /// <param name="cryptoResponse">The crypto response object.</param>
        /// <param name="cryptoCurrencyName">A custom cryptocurrency name.</param>
        /// <param name="quantity">The cryptocurrency quantity.</param>
        /// <returns>An <see cref="EmbedBuilder"/> object ready to be built.</returns>
        public async Task <EmbedBuilder> CreateCryptoEmbedAsync(CryptoResponse cryptoResponse, string cryptoCurrencyName, decimal quantity = 1)
        {
            var   emojis         = Configuration.GetSection("customEmojis");
            Emoji cryptoEmoji    = new(emojis["cryptoCoin"]);
            Emoji argentinaEmoji = new(":flag_ar:");
            Emoji usaEmoji       = new(":flag_us:");
            Emoji dollarEmoji    = Emoji.Parse(":dollar:");
            Emoji moneyBagEmoji  = Emoji.Parse(":moneybag:");
            Emoji whatsappEmoji  = new(emojis["whatsapp"]);

            TimeZoneInfo localTimeZone  = GlobalConfiguration.GetLocalTimeZoneInfo();
            int          utcOffset      = localTimeZone.GetUtcOffset(DateTime.UtcNow).Hours;
            string       footerImageUrl = Configuration.GetSection("images").GetSection("clock")["32"];
            string       cryptoCode     = cryptoResponse.Code.Length > 10 ? $"{cryptoResponse.Code[..7]}..." : cryptoResponse.Code;
        public EmojiPipeline()
        {
            InputModules = new ModuleList
            {
                new ExecuteConfig(
                    Config.FromContext(ctx => {
                    return(new ReadEmbedded(
                               typeof(EmojiPipeline).Assembly,
                               "Docs/src/Data/emojis.json"));
                }))
            };

            ProcessModules = new ModuleList
            {
                new ExecuteConfig(
                    Config.FromDocument(async(doc, ctx) =>
                {
                    var data = Emoji.Parse(await doc.GetContentStringAsync());
                    return(data.ToDocument(Constants.Emojis.Root));
                }))
            };
        }
 /// <summary>
 /// Creates a new <see cref="EuroCalculatorButtonBuilder"/>.
 /// </summary>
 /// <param name="tag">A custom tag to identify the component or pass data.</param>
 public EuroCalculatorButtonBuilder(string tag, IEmote emoji = null) : base(null, $"{Id}:{tag}", STYLE, null, emoji ?? Emoji.Parse(DEFAULT_EMOJI), false)
 {
 }
Esempio n. 8
0
 public async Task AddReaction(string emoji)
 {
     await(messageData as IUserMessage).AddReactionAsync(Emoji.Parse(emoji));
 }
Esempio n. 9
0
 public async Task React(string emoji)
 {
     await((SocketUserMessage)_message).AddReactionAsync(Emoji.Parse(emoji));
 }