예제 #1
0
        public async static void OnMessageReceived(object sender, MessageEventArgs messageEventArgs)
        {
            var message = messageEventArgs.Message;

            if (message == null || message.Type != MessageType.Text)
            {
                return;
            }

            var chat = ChatController.GetChat(message.Chat.Id, message.From.Id);

            switch (message.Text.Split(' ').First())
            {
            case "/start":
                await ChatController.CreateChat(message.Chat.Id, message.From.Id, message.From.Username);

                await botClient.SendTextMessageAsync(message.Chat.Id, "Started!", replyToMessageId : message.MessageId);

                break;

            case "/create":
                await ChatController.SetStep(1, 1, chat);

                await botClient.SendTextMessageAsync(message.Chat.Id, "Send input message", replyToMessageId : message.MessageId);

                break;

            default:
                switch (chat.Status)
                {
                case 1:
                    CreateMessageDialog(chat, message.Text);
                    break;

                default:
                    var answer = await MessageController.GetAnswer(message.Text);

                    await botClient.SendTextMessageAsync(message.Chat.Id, answer);

                    break;
                }
                break;
            }
        }