Giter VIP home page Giter VIP logo

rust-server's Introduction

Rocket + MySQL + HTML

카카오톡 챗봇 + Backend + Frontend 프로젝트 in Rust

Structure

chatbot/ : 카카오 챗봇 (actix)

src/routes/ : endpoints

tests/ : unittest

Endpoints

TODO

카카오 챗봇 JSON 로컬에서 미리보는 사이트

어떠한 방식으로? 1번 구현 후 2번 버전 시도가 나을 듯

  1. 자신의 JSON 데이터를 복사해서 입력하면 그걸 메시지로 변환 시키는 방식

(여기서 발화 메시지는 json 해석 후 알맞는 형태로)

(Rust로 메시지 Deserialize 하고 형식에 맞는 HTML 코드 GET return?)

  1. 사이트 자체를 local에 받게한 후 실행 후 POST 방식

gif

GET /front/<nums>

프론트 엔드 테스트

숫자에 맞게 공지사항을 파싱해서 HTML에 전달

error error

GET /db

MySQL 연동 테스트

[
    {
        "id": 1,
        "start_date": "07.06 (화)",
        "end_date": "07.09 (금)",
        "content": "내용"
    },
]

POST /notice

HTML 파싱

[
    {
        "id": 13727,
        "title": "제목",
        "date": "21.07.15",
        "link": "링크",
        "writer": "글쓴이"
    },
]

POST /yesterday

SELECT * FROM notices WHERE date = ? ORDER BY id DESC

=> query

[
    {
        "id": 11111,
        "title": "제목1",
        "date": "21.07.15",
        "link": "링크1",
        "writer": "글쓴이1"
    },
    {
        "id": 11110,
        "title": "제목2",
        "date": "21.07.15",
        "link": "링크2",
        "writer": "글쓴이2"
    },
]

카카오 챗봇 ListCard

#[test]
fn result_json() {
    let mut result = Template::new();
    result.add_qr(QuickReply::new(
        "message".to_string(),
        "라벨".to_string(),
        "메시지".to_string(),
    ));

    let mut list_card = ListCard::new("title".to_string());
    list_card.add_button(Box::new(
        CallButton::new("msg".to_string()).set_number("010-1234-5678".to_string()),
    ));

    list_card.add_button(Box::new(ShareButton::new("msg".to_string())));

    list_card.add_item(ListItem::new("제목".to_string()).set_desc("설명".to_string()));

    result.add_output(json!(list_card));

    println!("Result: {}", serde_json::to_string(&result).expect("Woah"));
}

=>

{
    "template": {
        "outputs": [
            {
                "listCard": {
                    "buttons": [
                        {
                            "action": "phone",
                            "label": "msg",
                            "phoneNumber": "010-1234-5678"
                        },
                        {
                            "action": "share",
                            "label": "msg"
                        }
                    ],
                    "header": {
                        "title": "title"
                    },
                    "items": [
                        {
                            "description": "설명",
                            "title": "제목"
                        }
                    ]
                }
            }
        ],
        "quickReplies": [
            {
                "action": "message",
                "label": "라벨",
                "messageText": "메시지"
            }
        ]
    },
    "version": "2.0"
}

rust-server's People

Contributors

alfex4936 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.