aboutsummaryrefslogtreecommitdiff
path: root/cmd/bot-kbbi/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/bot-kbbi/main.go')
-rw-r--r--cmd/bot-kbbi/main.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/cmd/bot-kbbi/main.go b/cmd/bot-kbbi/main.go
new file mode 100644
index 0000000..66b2edf
--- /dev/null
+++ b/cmd/bot-kbbi/main.go
@@ -0,0 +1,35 @@
+// Copyright 2020, Shulhan <m.shulhan@gmail.com>. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "log"
+ "os"
+ "os/signal"
+
+ "github.com/shuLhan/kbbi"
+)
+
+func main() {
+ log.SetFlags(0)
+
+ // Use the token and Webhook URL from environment variables.
+ tgbot, err := kbbi.NewTelegramBot("", "")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ go func() {
+ err := tgbot.Start()
+ if err != nil {
+ log.Println(err)
+ }
+ }()
+ defer tgbot.Stop()
+
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt)
+ <-c
+}