contributed by <yanjiun
>
https://github.com/yanjiuntw/ninja-hattori
index.js
需要填上自己的資料庫(後面會申請)
...
.connect(
'請輸入資料庫網址(mongo)',
{ useNewUrlParser: true }
)
...
bot.config.js
需要修改自己的 LINE 機器人資料(後面會申請)
...
channelId: '請輸入',
channelSecret: '請輸入',
channelAccessToken: '請輸入',
...
https://www.mongodb.com/cloud/atlas
沒有 MongoDB Atlas 帳號可能需要申請一個。
建一個新專案create project
建立叢集build cluster
,選擇 Shared Clusters
可以免費試用。
create cluster
。新增資料庫帳號與密碼。
點選 connect
後選擇 connect your applaction
,點選 copy
並貼到自己 Github 專案內的 index.js
中。並修改貼上文字中的<password>
為剛剛設定的密碼,再修改 <dbname>
為自己想要的資料庫名稱。
完成後類似這樣
...
.connect(
'mongodb+srv://test:U0PA9tAz5vV5k6Xz@cluster0.aslrj.mongodb.net/test?retryWrites=true&w=majority',
{ useNewUrlParser: true }
)
...
https://developers.line.biz/en/
bot.config.js
所需要的三個東西,將其複製到檔案中。
channelId
與 channelSecret
可以在 Basic setting 下方可以找到channelAccessToken
在 Messaging API 最下面,需點選 issue
才會產生。New
-> Create new app
,並完成建立。deploy
頁面下,選擇 Github
並登入,完成後輸入專案名稱並搜尋,找到後點 connect
。deploy branch
並稍待片刻,完成後會看到綠色打勾。setting
頁面下,複製 domain
後方網址(LINE 要用)到剛剛 Line Developr 網頁
Webhook settings
,將剛剛 Heroku app 的網址貼上。Allow bot to join group chats
打開