Beispiel #1
0
 public void Execute()
 {
     _commandChannelService.Add(new ChannelEntity()
     {
         ChatId = _messageEventArgs.Message.Chat.Id, Name = string.Concat(_messageEventArgs.Message.Chat.Username, "/", _messageEventArgs.Message.Chat.Title), UserId = _messageEventArgs.Message.From.Id, Type = (short)CDO.Enums.Chat.ChatType.Group
     });
     _telegramBotClient.SendTextMessageAsync(_messageEventArgs.Message.Chat.Id, "group added to list.").GetAwaiter();
 }
        public void Execute()
        {
            if (_updateEventArgs.Update.Type.Equals(UpdateType.ChannelPost))
            {
                Session session = SessionHelper.IsCodeExist(_updateEventArgs.Update.ChannelPost.Text);

                if (session != null && session.InstructionId.Equals(NextInstruction.WaitingCode))
                {
                    Response <int> response = _commandChannelService.Add(new ChannelEntity()
                    {
                        ChatId = _updateEventArgs.Update.ChannelPost.Chat.Id, Name = string.Concat(_updateEventArgs.Update.ChannelPost.Chat.Username, "/", _updateEventArgs.Update.ChannelPost.Chat.Title), UserId = session.UserId, Type = (short)CDO.Enums.Chat.ChatType.Channel
                    });
                    if (response.Type.Equals(ResponseType.Success))
                    {
                        _telegramBotClient.SendTextMessageAsync(_updateEventArgs.Update.ChannelPost.Chat.Id, "channel is added to list.").GetAwaiter();
                        session.InstructionId = NextInstruction.CodeValidated;
                        TimerHelper.DataReceived();
                    }
                    else if (response.Type.Equals(ResponseType.AlreadyExist))
                    {
                        _telegramBotClient.SendTextMessageAsync(_updateEventArgs.Update.ChannelPost.Chat.Id, "channel is already exist in list.").GetAwaiter();
                    }
                    else
                    {
                        _telegramBotClient.SendTextMessageAsync(_updateEventArgs.Update.ChannelPost.Chat.Id, "channel is not added to list. User is not found.").GetAwaiter();
                        session.InstructionId = NextInstruction.CodeNotValidated;
                        TimerHelper.DataReceived();
                    }
                }
                else if (session != null && !session.InstructionId.Equals(NextInstruction.WaitingCode))
                {
                    if (session.InstructionId.Equals(NextInstruction.CodeNotValidated))
                    {
                        _telegramBotClient.SendTextMessageAsync(_updateEventArgs.Update.ChannelPost.Chat.Id, "code not validated. call Add Channel again. [SERVER_EXCEPTION]").GetAwaiter();
                    }
                    else if (session.InstructionId.Equals(NextInstruction.CodeNotValidatedTimeOut))
                    {
                        _telegramBotClient.SendTextMessageAsync(_updateEventArgs.Update.ChannelPost.Chat.Id, "code not validated. call Add Channel again. [TIMEOUT]").GetAwaiter();
                    }
                    else if (session.InstructionId.Equals(NextInstruction.CodeValidated))
                    {
                        _telegramBotClient.SendTextMessageAsync(_updateEventArgs.Update.ChannelPost.Chat.Id, "code is already used. please call Add Channel again.").GetAwaiter();
                    }
                }
                else
                {
                    _telegramBotClient.SendTextMessageAsync(_updateEventArgs.Update.ChannelPost.Chat.Id, "wrong code is entered. try again.").GetAwaiter();
                }
            }
        }