diff options
| author | Shulhan <ms@kilabit.info> | 2021-01-31 04:56:36 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-01-31 06:16:54 +0700 |
| commit | 6c7bfd42bc1128f5969e9e40b23d6b828601f7cb (patch) | |
| tree | 8138149fde47f135b965be0837b4f8b83421728f /telegram_bot.go | |
| parent | 734ce643ecbc992834a8f78b44904b82b09bc84b (diff) | |
| download | kamusku-6c7bfd42bc1128f5969e9e40b23d6b828601f7cb.tar.xz | |
all: rewrite the server
This commit move the directClient to different repository called kamusku
and changes the module name from kamusku to kamusd.
Diffstat (limited to 'telegram_bot.go')
| -rw-r--r-- | telegram_bot.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/telegram_bot.go b/telegram_bot.go index 061bb4c..3892ece 100644 --- a/telegram_bot.go +++ b/telegram_bot.go @@ -1,8 +1,8 @@ -// Copyright 2020, Shulhan <m.shulhan@gmail.com>. All rights reserved. +// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package kamusku +package kamusd import ( "bytes" @@ -11,6 +11,7 @@ import ( "os" "strings" + "git.sr.ht/~shulhan/kamusku" "github.com/shuLhan/share/api/telegram/bot" ) @@ -110,7 +111,7 @@ func (tgbot *TelegramBot) handleCommandDefinisi(update bot.Update) { daftarKata := strings.Split(msgReq.CommandArgs, ",") - def, err := tgbot.apiClient.CariDefinisi(daftarKata) + def, err := tgbot.apiClient.Lookup(daftarKata) if err != nil { tgbot.sendError(msgReq, "", err.Error()) return @@ -164,34 +165,33 @@ dan bebas dipakai oleh publik. } } -func formatText(definisiKata DefinisiResponse) string { +func formatText(wordDef kamusku.LookupResponse) string { buf := &bytes.Buffer{} - for k, kata := range definisiKata { + for k, kata := range wordDef { fmt.Fprintf(buf, "<b>%s</b>\n", k) - if len(kata.Pesan) > 0 { - fmt.Fprintln(buf, " "+kata.Pesan) + if len(kata.Message) > 0 { + fmt.Fprintln(buf, " "+kata.Message) fmt.Fprintln(buf, "") continue } - if len(kata.Dasar) > 0 { - fmt.Fprintf(buf, " Kata dasar: <i>%s</i>\n\n", - kata.Dasar) + if len(kata.Root) > 0 { + fmt.Fprintf(buf, " Kata dasar: <i>%s</i>\n\n", kata.Root) } - for x, def := range kata.Definisi { - fmt.Fprintf(buf, "‣ Definisi #%d: %s\n", x+1, def.Isi) + for x, def := range kata.Definition { + fmt.Fprintf(buf, "‣ Definisi #%d: %s\n", x+1, def.Value) - if len(def.Kelas) > 0 { + if len(def.Classes) > 0 { fmt.Fprintln(buf, " Kelas kata,") - for _, kelas := range def.Kelas { + for _, kelas := range def.Classes { fmt.Fprintln(buf, " • "+kelas) } } - if len(def.Contoh) > 0 { + if len(def.Examples) > 0 { fmt.Fprintln(buf, " Contoh,") - for _, contoh := range def.Contoh { + for _, contoh := range def.Examples { fmt.Fprintln(buf, " • "+contoh) } } |
