private void _processEvents(BotsLongPollHistoryResponse pollResponse) { foreach (var update in pollResponse.Updates) { OnGroupUpdateReceived?.Invoke(this, new GroupUpdateReceivedEventArgs(update)); if (update.Type == GroupUpdateType.MessageNew) { OnMessageReceived?.Invoke(this, new MessageReceivedEventArgs(update.MessageNew?.Message)); } } }
private void ProcessLongPollEvents(BotsLongPollHistoryResponse pollResponse) { foreach (GroupUpdate update in pollResponse.Updates) { OnGroupUpdateReceived?.Invoke(this, new GroupUpdateReceivedEventArgs(update)); if (update.Type == GroupUpdateType.MessageNew) { OnMessageReceived?.Invoke(this, new MessageReceivedEventArgs(update.Message)); SearchPhraseAndHandle(update.Message); } } }
private void ProcessLongPollEvents(BotsLongPollHistoryResponse pollResponse) { foreach (GroupUpdate update in pollResponse.Updates) { OnGroupUpdateReceived?.Invoke(this, new GroupUpdateReceivedEventArgs(update, this.PeerContextManager.GlobalVars)); if (update.Type == GroupUpdateType.MessageNew) { long peerId = update.Message.PeerId.Value; PeerContext peerContext = null; if (!this.PeerContextManager.Peers.TryGetValue(peerId, out peerContext)) { peerContext = new PeerContext(this.PeerContextManager.GlobalVars); this.PeerContextManager.Peers.Add(peerId, peerContext); } OnMessageReceived?.Invoke(this, new MessageReceivedEventArgs(update.Message, peerContext)); this.SearchTemplatesMatchingMessageAndHandle(update.Message, peerContext); } } }