When calling GetUpdates method on TelegramBotClient, this object will be returned.
Esempio n. 1
0
        private void updateTimer_Callback(object state)
        {
            GetUpdatesResult updates           = null;
            bool             getUpdatesSuccess = false;

            try
            {
                if (lastUpdateId == 0)
                {
                    updates = GetUpdates();
                }
                else
                {
                    updates = GetUpdates(lastUpdateId + 1);
                }
                getUpdatesSuccess = true;
            }
            catch (Exception ex)
            {
                OnGetUpdatesError(ex);
            }
            if (getUpdatesSuccess)
            {
                if (updates.Ok && updates.Result != null && updates.Result.Any())
                {
                    lastUpdateId = updates.Result.Last().UpdateId;
                    OnUpdatesReceived(updates.Result);
                }
            }
            updateTimer.Change(CheckInterval, Timeout.Infinite);
        }
Esempio n. 2
0
        private void UpdateReceived(GetUpdatesResult updates)
        {
            if (!updates.Ok ||
                updates.Result == null ||
                !updates.Result.Any())
            {
                return;
            }

            mLastUpdateId = updates.Result.Last().UpdateId;
            OnUpdatesReceived(updates.Result);
        }
Esempio n. 3
0
        private void UpdateTimerCallback(object state)
        {
            AllowedUpdates[] allowedUpdateses = (AllowedUpdates[])state;

            try
            {
                GetUpdatesResult updates = mLastUpdateId == 0
                    ? GetUpdates()
                    : GetUpdates(mLastUpdateId + 1, allowedUpdates: allowedUpdateses);

                UpdateReceived(updates);
            }
            catch (Exception ex)
            {
                OnGetUpdatesError(ex);
            }

            mUpdateTimer?.Change(CheckInterval, Timeout.Infinite);
        }