Added missing XML summaries
This commit is contained in:
@@ -33,6 +33,10 @@ namespace Telegrator.Handlers
|
||||
/// <inheritdoc/>
|
||||
public IAwaitingProvider AwaitingProvider { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes new instance of <see cref="AbstractHandlerContainer{TUpdate}"/>
|
||||
/// </summary>
|
||||
/// <param name="handlerInfo"></param>
|
||||
public AbstractHandlerContainer(DescribedHandlerInfo handlerInfo)
|
||||
{
|
||||
ActualUpdate = handlerInfo.HandlingUpdate.GetActualUpdateObject<TUpdate>();
|
||||
@@ -43,6 +47,15 @@ namespace Telegrator.Handlers
|
||||
AwaitingProvider = handlerInfo.AwaitingProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes new instance of <see cref="AbstractHandlerContainer{TUpdate}"/>
|
||||
/// </summary>
|
||||
/// <param name="actualUpdate"></param>
|
||||
/// <param name="handlingUpdate"></param>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="extraData"></param>
|
||||
/// <param name="filters"></param>
|
||||
/// <param name="awaitingProvider"></param>
|
||||
public AbstractHandlerContainer(TUpdate actualUpdate, Update handlingUpdate, ITelegramBotClient client, Dictionary<string, object> extraData, CompletedFiltersList filters, IAwaitingProvider awaitingProvider)
|
||||
{
|
||||
ActualUpdate = actualUpdate;
|
||||
@@ -53,6 +66,11 @@ namespace Telegrator.Handlers
|
||||
AwaitingProvider = awaitingProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new container of specific update type from thos contatiner
|
||||
/// </summary>
|
||||
/// <typeparam name="QUpdate"></typeparam>
|
||||
/// <returns></returns>
|
||||
public AbstractHandlerContainer<QUpdate> CreateChild<QUpdate>() where QUpdate : class
|
||||
{
|
||||
return new AbstractHandlerContainer<QUpdate>(
|
||||
@@ -61,6 +79,12 @@ namespace Telegrator.Handlers
|
||||
CompletedFilters, AwaitingProvider);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new container of specific update type from existing container
|
||||
/// </summary>
|
||||
/// <typeparam name="QUpdate"></typeparam>
|
||||
/// <param name="other"></param>
|
||||
/// <returns></returns>
|
||||
public static AbstractHandlerContainer<TUpdate> From<QUpdate>(IAbstractHandlerContainer<QUpdate> other) where QUpdate : class
|
||||
{
|
||||
return new AbstractHandlerContainer<TUpdate>(
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace Telegrator.Handlers
|
||||
/// </summary>
|
||||
public string ReceivedCommand { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Message text splited by space characters
|
||||
/// </summary>
|
||||
public string[]? Arguments { get; internal set; } = null;
|
||||
|
||||
/// <summary>
|
||||
@@ -32,7 +35,10 @@ namespace Telegrator.Handlers
|
||||
if (commandEntity.Type != MessageEntityType.BotCommand)
|
||||
return false;
|
||||
|
||||
ReceivedCommand = message.Text.Substring(commandEntity.Offset + 1, commandEntity.Length - 1);
|
||||
if (commandEntity.Offset != 0)
|
||||
return false;
|
||||
|
||||
ReceivedCommand = message.Text.Substring(1, commandEntity.Length - 1);
|
||||
if (ReceivedCommand.Contains('@'))
|
||||
{
|
||||
string[] split = ReceivedCommand.Split('@');
|
||||
|
||||
@@ -7,21 +7,41 @@ using Telegrator.Handlers.Components;
|
||||
|
||||
namespace Telegrator.Handlers
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute that marks a handler to process inline queries.
|
||||
/// </summary>
|
||||
public class InlineQueryHandlerAttribute(int importance = 0) : UpdateHandlerAttribute<InlineQueryHandler>(UpdateType.InlineQuery, importance)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override bool CanPass(FilterExecutionContext<Update> context) => context.Input.InlineQuery is { } | context.Input.ChosenInlineResult is { };
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Abstract base class for handlers that process inline queries.
|
||||
/// </summary>
|
||||
public abstract class InlineQueryHandler() : AbstractUpdateHandler<Update>(UpdateType.InlineQuery)
|
||||
{
|
||||
/// <summary>
|
||||
/// Handler container for the current <see cref="InlineQuery"/> update.
|
||||
/// </summary>
|
||||
protected IAbstractHandlerContainer<InlineQuery> QueryContainer { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Handler container for the current <see cref="ChosenInlineResult"/> update.
|
||||
/// </summary>
|
||||
protected IAbstractHandlerContainer<ChosenInlineResult> ChosenContainer { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Incoming update of type <see cref="InlineQuery"/>.
|
||||
/// </summary>
|
||||
protected InlineQuery InputQuery { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Incoming update of type <see cref="ChosenInlineResult"/>.
|
||||
/// </summary>
|
||||
protected ChosenInlineResult InputChosen { get; private set; } = null!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task<Result> Execute(IAbstractHandlerContainer<Update> container, CancellationToken cancellation)
|
||||
{
|
||||
switch (container.HandlingUpdate.Type)
|
||||
@@ -30,14 +50,14 @@ namespace Telegrator.Handlers
|
||||
{
|
||||
QueryContainer = AbstractHandlerContainer<InlineQuery>.From(container);
|
||||
InputQuery = QueryContainer.ActualUpdate;
|
||||
return await Requested(QueryContainer, cancellation);
|
||||
return await Requested(QueryContainer, cancellation).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
case UpdateType.ChosenInlineResult:
|
||||
{
|
||||
ChosenContainer = AbstractHandlerContainer<ChosenInlineResult>.From(container);
|
||||
InputChosen = ChosenContainer.ActualUpdate;
|
||||
return await Chosen(ChosenContainer, cancellation);
|
||||
return await Chosen(ChosenContainer, cancellation).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -45,10 +65,32 @@ namespace Telegrator.Handlers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes handler logic if received update is <see cref="UpdateType.InlineQuery"/>
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="cancellation"></param>
|
||||
/// <returns></returns>
|
||||
public abstract Task<Result> Requested(IAbstractHandlerContainer<InlineQuery> container, CancellationToken cancellation);
|
||||
|
||||
/// <summary>
|
||||
/// Executes handler logic if received update is <see cref="UpdateType.ChosenInlineResult"/>
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="cancellation"></param>
|
||||
/// <returns></returns>
|
||||
public abstract Task<Result> Chosen(IAbstractHandlerContainer<ChosenInlineResult> container, CancellationToken cancellation);
|
||||
|
||||
/// <summary>
|
||||
/// Answers inline query
|
||||
/// </summary>
|
||||
/// <param name="results"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
/// <param name="isPersonal"></param>
|
||||
/// <param name="nextOffset"></param>
|
||||
/// <param name="button"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
protected async Task Answer(
|
||||
IEnumerable<InlineQueryResult> results,
|
||||
int? cacheTime = null,
|
||||
|
||||
Reference in New Issue
Block a user