Exemplo n.º 1
0
        private static async Task <SimplePost> WriteText(Graphics context, bool suppressLog)
        {
            const int verticalMargin = 100;
            const int lineWidth      = 30;
            const int lineSpacing    = 15;

            var post = await MemesRepository.GetRandom();

            var quote = HttpUtility.HtmlDecode(post.Text)?.Replace("<br>", "\n").Replace("\n", " ");

            if (!suppressLog)
            {
                Logger.Info($"Generated grekan with text: {post.Text}\n Original text was created in: {post.Date}");
            }

            var chunks = quote.SplitByLength(lineWidth).Reverse().ToArray();

            for (var i = 0; i < chunks.Length; i++)
            {
                context.DrawOutlinedString(chunks[i], Font, LineFormat, Brushes.Black, Brushes.White,
                                           new PointF(_imageWidth / 2, _imageHeight - verticalMargin - i * (Font.Size + lineSpacing)));
            }

            context.Save();

            return(post);
        }
Exemplo n.º 2
0
        public async void Execute(IJobExecutionContext context)
        {
            var config = new MongoClient().GetDatabase("grekileaks")
                         .GetCollection <dynamic>("configs")
                         .Find(FilterDefinition <dynamic> .Empty)
                         .First();

            var telega = new TelegramBotClient((string)config.telegram.grekaneveryday.token);

            var post = await MemesRepository.GetRandom();

            var text = $"[{post.Date}] {post.Text}";

            await telega.SendTextMessageAsync("@grekileaks", text);
        }