summaryrefslogtreecommitdiff
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
parent892b1f8bde127915e210a49997102bc9a98794e4 (diff)
downloadkamusku-3db6e6d9bd92ccfcdb5e3c1e899b731affbaa1eb.tar.xz
telegram_bot: tangani perintah yang tidak dikenal
Selain itu sederhanakan deskripsi dari perintah "definisi".
-rw-r--r--go.mod2
-rw-r--r--go.sum4
-rw-r--r--telegram_bot.go15
3 files changed, 15 insertions, 6 deletions
diff --git a/go.mod b/go.mod
index dd04ad8..cdffb8c 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/shuLhan/kbbi
go 1.13
require (
- github.com/shuLhan/share v0.14.1-0.20200410205026-5378abd1e1f4
+ github.com/shuLhan/share v0.14.1-0.20200411155429-da0578d686d1
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
)
diff --git a/go.sum b/go.sum
index 75c6bb7..cd8dc87 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-github.com/shuLhan/share v0.14.1-0.20200410205026-5378abd1e1f4 h1:NgTmO/2wMlcENPxK3EOIYFfdNEmz5QzcVOkDplxSluI=
-github.com/shuLhan/share v0.14.1-0.20200410205026-5378abd1e1f4/go.mod h1:mpa0ub5qmuko/muUlOROOqLCSHKU76GzuAR/sUaSwRo=
+github.com/shuLhan/share v0.14.1-0.20200411155429-da0578d686d1 h1:x9FznzGdeWfShJEK3oD6LXygNiK06f9szHkm6m87rio=
+github.com/shuLhan/share v0.14.1-0.20200411155429-da0578d686d1/go.mod h1:mpa0ub5qmuko/muUlOROOqLCSHKU76GzuAR/sUaSwRo=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
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)
+ }
}
//