Пример #1
0
        public static InlineEvent From(Update update)
        {
            var result = new InlineEvent
            {
                UpdateId = update.UpdateId
            };

            if (update.InlineQuery != null)
            {
                result.UpdateType  = InlineUpdateType.InlineQuery;
                result.InlineQuery = update.InlineQuery;
            }

            if (update.ChosenInlineResult != null)
            {
                result.UpdateType         = InlineUpdateType.ChosenInlineResult;
                result.ChosenInlineResult = update.ChosenInlineResult;
            }

            if (update.CallbackQuery != null)
            {
                result.UpdateType    = InlineUpdateType.CallbackQuery;
                result.CallbackQuery = update.CallbackQuery;
            }

            return(result);
        }
Пример #2
0
        internal bool ExtractUpdate(string requestBody)
        {
            var update = DeserializeUpdate(requestBody);

            if (update == null)
            {
                return(false);
            }

            if (update.Message != null || update.EditedMessage != null ||
                update.ChannelPost != null || update.EditedChannelPost != null)
            {
                messageSubject.OnNext(MessageEvent.From(update));
            }

            if (update.InlineQuery != null || update.ChosenInlineResult != null ||
                update.CallbackQuery != null)
            {
                inlineSubject.OnNext(InlineEvent.From(update));
            }

            if (false && update.Message != null)
            {
                paymentSubject.OnNext(PaymentEvent.From(update));
            }

            return(true);
        }