Example #1
0
        /// <summary>
        /// Pass messages to receive message event
        /// </summary>
        private async void HandleMessages()
        {
            while (true)
            {
                var updates = await PollMessages();

                foreach (Update update in updates)
                {
                    if (update.Message != null)
                    {
                        OnMessage?.Invoke(update.Message);
                        continue;
                    }

                    if (update.InlineQuery != null)
                    {
                        OnInlineQuery?.Invoke(update.InlineQuery);
                        continue;
                    }

                    if (update.ChosenInlineResult != null)
                    {
                        OnChooseInlineResult?.Invoke(update.ChosenInlineResult);
                    }
                    if (update.CallbackQuery != null)
                    {
                        OnCallbackQuery?.Invoke(update.CallbackQuery);
                    }
                }
            }
        }
Example #2
0
        private void HandleMessage(Update update)
        {
            if (update.Message != null)
            {
                OnMessage?.Invoke(update.Message);
                return;
            }

            if (update.InlineQuery != null)
            {
                OnInlineQuery?.Invoke(update.InlineQuery);
                return;
            }

            if (update.ChosenInlineResult != null)
            {
                OnChooseInlineResult?.Invoke(update.ChosenInlineResult);
            }
            if (update.CallbackQuery != null)
            {
                OnCallbackQuery?.Invoke(update.CallbackQuery);
            }
        }