예제 #1
0
 /// <summary>
 /// Ensures that the <see cref="BotRoutingContext.ProcessTimes"/> has at least one segment.
 /// </summary>
 public static void EnsureSegment(this BotRoutingContext context)
 {
     if (context.ProcessTimes.Count == 0)
     {
         context.RecordGenerationSegmentTime();
     }
 }
예제 #2
0
        public override async Task ProcessAsync(BotRoutingContext context)
        {
            var results = context
                          .SearchByCommand()
                          .Select(x => InlineQueryResponseComposer.GetArticleResult(x, true))
                          .AddSearchTips(ResultType.SearchShort)
                          .Take(50);

            context.RecordGenerationSegmentTime();
            await context.AnswerInlineQueryAsync(results);
        }
예제 #3
0
        public override async Task ProcessAsync(BotRoutingContext context)
        {
            var results = context
                          .SearchByCommand()
                          .OrderByDescending(x => x.DateClose - x.DateOpen)
                          .Select(x => InlineQueryResponseComposer.GetArticleResult(x))
                          .AddSearchTips(ResultType.Oldest)
                          .Take(50);

            context.RecordGenerationSegmentTime();
            await context.AnswerInlineQueryAsync(results);
        }
예제 #4
0
 public override async Task ProcessAsync(BotRoutingContext context)
 {
     if (context.IsFromAdmin())
     {
         var sb = new StringBuilder();
         sb.Append("Hello! You're seeing this message because you're recognized as an *administrator*.\n");
         sb.Append($"Bot *version* is `{Program.Version} ({Program.InternalVersion})`\n");
         sb.Append($"*Uptime*: `{DateTime.UtcNow:hh:mm}, up {Program.AppStopwatch.Elapsed:d' day(s) 'hh':'mm}`\n\n");
         sb.Append("*Stats*:\n");
         foreach (var tag in context.Stats.RegisteredSafeInts)
         {
             sb.Append($"- *{tag.DisplayName}* (`{tag.Id}`): {tag.SafeInt}\n");
         }
         context.RecordGenerationSegmentTime();
         await context.ReplyTextMessageAsync(sb.ToString(), ParseMode.Markdown);
     }
     else
     {
         await context.ReplyTextMessageAsync("Hello! Command features are not developed yet but stay tuned there!");
     }
 }