Exemplo n.º 1
0
        public async Task HandleChosenInlineResult(QueryResult.ChosenInlineResult result)
        {
            if (result?.Query == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            Exception exception = null;

            try
            {
                var service = Methods.SearchServiceByUserId(result.From);
                if (!service.FullUserAccess)
                {
                    return;
                }
                foreach (var rule in _rules)
                {
                    var del = rule.Handle(result, service, this);
                    if (del == null)
                    {
                        continue;
                    }
                    LogMaker.Log(Logger, $"{result.Query} command received from user with id {result.From.Id}, resultId={result.ResultId}", false);
                    if (result.ResultId == CallbackCommand.IGNORE_COMMAND)
                    {
                        return;
                    }
                    await del.Invoke();
                }
            }
            catch (ServiceNotFoundException ex)
            {
                exception = ex;
                await _botActions.WrongCredentialsMessage(result.From);
            }
            catch (DbDataStoreException ex)
            {
                exception = ex;
                await _botActions.WrongCredentialsMessage(result.From);
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            finally
            {
                if (exception != null)
                {
                    LogMaker.Log(Logger, exception, $"An exception has been thrown in processing InlineQuery with query: {result.Query}");
                }
            }
        }
Exemplo n.º 2
0
        public HandleChosenInlineResultCommand Handle(QueryResult.ChosenInlineResult result, Service service, ChosenInlineResultHandler handler)
        {
            HandleChosenInlineResultCommand del = async() =>
            {
                await handler.HandleSetBccChosenInlineResult(result);
            };

            if (result.Query.StartsWith(InlineQueryCommand.BCC_RECIPIENTS_COMMAND, StringComparison.CurrentCultureIgnoreCase))
            {
                return(del);
            }
            return(null);
        }
Exemplo n.º 3
0
        public HandleChosenInlineResultCommand Handle(QueryResult.ChosenInlineResult result, Service service, ChosenInlineResultHandler handler)
        {
            HandleChosenInlineResultCommand del = async() =>
            {
                await handler.HandleGetMesssagesChosenInlineResult(result, service);
            };

            if (result.Query.StartsWith(InlineQueryCommand.INBOX_COMMAND, StringComparison.CurrentCultureIgnoreCase))
            {
                return(del);
            }
            return(null);
        }