Created
February 9, 2019 13:17
-
-
Save isdaviddong/34a6b63ca029c2c2b467752b5bcb7a1d to your computer and use it in GitHub Desktop.
ProcessCommand(...)方法中新增的部分
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //如果是 '/add'開頭 | |
| if (msg.ToLower().StartsWith("/add")) //表單新增 | |
| { | |
| //以 '/' 分割收到的字串 | |
| var words = msg.Split('/'); | |
| try | |
| { | |
| //嘗試抓取每一個欄位 | |
| float num = float.Parse(words[2]); | |
| string datetime = words[5]; | |
| string memo = words[4]; | |
| string AccountType = words[3]; | |
| string rep = ""; | |
| //清空狀態,準備新增 | |
| Utility.SetState(e.source.userId, ""); | |
| //紀錄 | |
| if (Utility.SaveToDB(e.source.userId, num, AccountType, memo)) | |
| rep = $"${num} 已記錄為 {AccountType}"; | |
| else | |
| rep = "記錄失敗"; | |
| //顯示訊息 | |
| isRock.LineBot.Bot b = new isRock.LineBot.Bot(); | |
| isRock.LineBot.TextMessage TextMessage = new isRock.LineBot.TextMessage(rep); | |
| b.ReplyMessage(e.replyToken, TextMessage); | |
| return true; | |
| } | |
| catch (Exception ex) | |
| { | |
| //回覆QuickReply | |
| isRock.LineBot.Bot b = new isRock.LineBot.Bot(); | |
| isRock.LineBot.TextMessage TextMessage = new isRock.LineBot.TextMessage("新增失敗..."); | |
| b.ReplyMessage(e.replyToken, TextMessage); | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment