將讀取出來的資料,宣告為變數 msgDataList
val msgDataList = File("src/main/resources/dataList.txt").readLines()
用一個 function 來處理這件事情
fun msgRan(): String {
val msgDataList = File("src/main/resources/dataList.txt").readLines()
return msgDataList.toString()
}
原本收到 hoppscotch 送出的訊息時,ktor 都會這樣回覆
send("You said: $receivedText")
把它改成
send("You said: $receivedText, i say: $msgRan()")