aboutsummaryrefslogtreecommitdiff
path: root/telegram_bot.go
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2020-04-11 22:56:44 +0700
committerShulhan <m.shulhan@gmail.com>2020-04-11 22:56:44 +0700
commit3db6e6d9bd92ccfcdb5e3c1e899b731affbaa1eb (patch)
tree0c55187c3ae7be66533f5972d292530747220aa4 /telegram_bot.go
parent892b1f8bde127915e210a49997102bc9a98794e4 (diff)
downloadkamusku-3db6e6d9bd92ccfcdb5e3c1e899b731affbaa1eb.tar.xz
telegram_bot: tangani perintah yang tidak dikenal
Selain itu sederhanakan deskripsi dari perintah "definisi".
Diffstat (limited to 'telegram_bot.go')
-rw-r--r--telegram_bot.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/telegram_bot.go b/telegram_bot.go
index e8ae294..cf023ab 100644
--- a/telegram_bot.go
+++ b/telegram_bot.go
@@ -18,6 +18,7 @@ const (
commandBantuan = "bantuan"
commandDefinisi = "definisi"
+ commandStart = "start"
)
//
@@ -38,8 +39,8 @@ func NewTelegramBot(token, webhookURL string) (tgbot *TelegramBot, err error) {
var commands = []bot.Command{{
Command: commandDefinisi,
- Description: "Cari definisi dari satu atau lebih kata." +
- " Pisahkan antara kata dengan koma.",
+ Description: `Cari definisi dari kata.` +
+ ` Contoh: "/definisi kamus,bahasa"`,
Handler: tgbot.handleCommandDefinisi,
}}
@@ -72,7 +73,15 @@ func (tgbot *TelegramBot) handleUpdate(update bot.Update) {
if update.Message == nil {
return
}
- fmt.Printf("update.Message: %+v\n", update.Message)
+
+ msg := update.Message
+
+ if len(msg.Command) != 0 {
+ text := fmt.Sprintf(`Perintah tidak dikenal %q. Contoh: "/definisi kamus,bahasa"`,
+ msg.Command)
+
+ tgbot.sendError(update.Message, "", text)
+ }
}
//