Exemple #1
0
        /// <summary>
        /// Get sender classification flags.
        /// </summary>
        public static SenderClassification GetSenderClassification(this BotRoutingContext context)
        {
            var result = SenderClassification.None;

            if (context.IsFromBot())
            {
                result |= SenderClassification.Bot;
            }
            if (context.IsFromRealPerson())
            {
                result |= SenderClassification.User;
            }
            if (context.IsFromAdmin())
            {
                result |= SenderClassification.Admin;
            }

            return(result);
        }
 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!");
     }
 }