Skip to content

MOLi Bot API docs

richegg Tsai edited this page Jan 3, 2017 · 3 revisions

POST /messages

讓 MOLi Bot 傳送訊息到指定對話、群組、channel

  • Authorization: "(token)"
  • Content-Type: "application/json"
  • Accept: "application/json"

Parameter

{
    "chat_id": (string),
    "text": (string),
    "disable_notification": (boolean) Optional
}

Example response

  • Status: 200
  • Content-Type: "application/json"
{
    "ok": true,
    "result": {
        "message_id": 1,
        "from": {
            "id": 12345678,
            "first_name": "YourBot",
            "username": "YourBot"
        },
        "chat": {
            "id": 1234567890,
            "first_name": "John",
            "last_name": "Doe",
            "username": "JohnDoe",
            "type": "private"
        },
        "date": 1459958199,
        "text": "Hello from Bot!"
    }
}
  • Status: 400
  • Content-Type: "application/json"
{
    "ok": false,
    "error_code": 400,
    "description": "[Error]: Bad Request: chat_id is empty"
}

POST /photos

讓 MOLi Bot 傳送圖片到指定對話、群組、channel

  • Authorization: "(token)"
  • Content-Type: "application/json"
  • Accept: "application/json"

Parameter

{
    "chat_id": (string),
    "photo": (string) url or file,
    "disable_notification": (boolean) Optional
}

Example response

  • Status: 200
  • Content-Type: "application/json"
{
    "ok": true,
    "result": {
        "message_id": 1,
        "from": {
            "id": 12345678,
            "first_name": "YourBot",
            "username": "YourBot"
        },
        "chat": {
            "id": 123456789,
            "first_name": "John",
            "last_name": "Doe",
            "username": "JohnDoe",
            "type": "private"
        },
        "date": 1459976718,
        "photo": [
            {
                "file_id": "AbCdE123XyZ...",
                "file_size": 1437,
                "width": 70,
                "height": 90
            },
            {
                "file_id": "AbCdE123XyZ...",
                "file_size": 17334,
                "width": 248,
                "height": 320
            }
        ]
    }
}
  • Status: 400
  • Content-Type: "application/json"
{
    "ok": false,
    "error_code": 400,
    "description": "[Error]: Bad Request: there is no photo in request"
}

POST /locations

讓 MOLi Bot 傳送定位到指定對話、群組、channel

  • Authorization: "(token)"
  • Content-Type: "application/json"
  • Accept: "application/json"

Parameter

{
    "chat_id": (string),
    "latitude": (double),
    "longitude": (double),
    "disable_notification": (boolean) Optional
}

Example response

  • Status: 200
  • Content-Type: "application/json"
{
    "ok": true,
    "result": {
        "message_id": 1,
        "from": {
            "id": 12345678,
            "first_name": "YourBot",
            "username": "YourBot"
        },
        "chat": {
            "id": 123456789,
            "first_name": "John",
            "last_name": "Doe",
            "username": "JohnDoe",
            "type": "private"
        },
        "date": 1459976225,
        "location": {
            "latitude": 37.7576793,
            "longitude": -122.5076402
        }
    }
}
  • Status: 400
  • Content-Type: "application/json"
{
    "ok": false,
    "error_code": 400,
    "description": "[Error]: Bad Request: longitude is empty"
}

GET /ncnu-rss

獲得暨大最新公告 RSS 的 JSON 格式版本

原始資料來源:http://www.ncnu.edu.tw/ncnuweb/ann/RSS.aspx

  • Content-Type: "application/json"
  • Accept: "application/json"

Parameter

Example response

  • Status: 200
  • Content-Type: "application/json"
{
    "@attributes": {
        "version": "2.0"
    },
    "channel": {
        "title": "暨大最新公告",
        "link": "http://www.ncnu.edu.tw",
        "description": "包含暨大最新消息、徵人公告、演講及活動、招生資訊、教學卓越、外部公文",
        "language": "zh-tw",
        "image": "http://www.ncnu.edu.tw/ncnuweb/units/share/全校共用/web_material/images/logo/45_45.gif",
        "item": [
            {
                "title": (String),
                "link": (String),
                "description": (String with HTML struct),
                "author": (String),
                "pubDate": (DateTime String),
                "comments": (String),
                "category": (String),
                "guid": (String)
            },
            ...
        ]
    }
}

GET /ncnu-staff-contact/:keyword

搜尋暨大各單位及教職員工聯絡資訊

原始資料來源:http://ccweb1.ncnu.edu.tw/telquery/StaffQuery.asp

  • Content-Type: "application/json"
  • Accept: "application/json"

Parameter

Optional: keyword (String)

Example response

  • Status: 200
  • Content-Type: "application/json"
[
    [
        "單位名稱",
        "英文單位名稱",
        "職稱",
        "英文職稱",
        "姓名",
        "英文姓名",
        "分機號碼",
        "EMail"
    ],
    [
        "校長室",
        "Office of President",
        "校長",
        "President",
        "蘇玉龍",
        "Yuhlong Oliver Su",
        "2000",
        "[email protected]"
    ],
    ...
]