From a7ba295ba905597d5ab5efdfd46339428a95ee87 Mon Sep 17 00:00:00 2001 From: Jacques Supcik Date: Thu, 11 Aug 2016 23:44:55 +0200 Subject: [PATCH] WIP --- .travis.yml | 27 ++++++++++++++++++++++----- telecom-tower-telegram-bot.go | 22 +++++++++++----------- telecom-tower-telegram-bot.ini | 1 - 3 files changed, 33 insertions(+), 17 deletions(-) delete mode 100644 telecom-tower-telegram-bot.ini diff --git a/.travis.yml b/.travis.yml index 813495e..4eae93f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,23 @@ language: go -notifications: - email: - recipients: jacques@supcik.net - on_success: change - on_failure: always + +go: +- 1.6 + +install: +- go get ./... +- go build + +script: +- file telecom-tower-telegram-bot +- true + +deploy: + provider: releases + api_key: + secure: HFrfvOaH8FU91LXYN1/ocn42pt/Bvsbzt+EQXhZ7Kg9mF+9eN3p+91+5GgxeEJNvVamO8g5trJzI/E0rToPye0/5PTK3RoVz6lBREsOP6tzSqjMMhyYLoFQ2eUcKt9yelZfILdLr8OmVRpHIx139Owz694ndNwzY48iJHqnUDVDKONuax9HbMkLIymgzYXga92UVTqGOcCLpvcE9Nk1KhE4FV8aVa8493wzYc/oF3w2vtvSx4FY5tWvqq42VL0tlxf2gbK9dFsF1nk9yPKaaIhxmaKIBFlylLAA5jvpOEtI++xR2orXv8C3UvQK6d9nJmuba3L1WKuk0wmNu8y2eMO5MPIBYugDvD4hsGEz3rRrcJoGzBYp61KqDFoSS6736pPFm3pRMwsi3ZI7/FHy+VQZKPcOc1MChcQ7bv03TRc1dKcaiOudpFJc2fI3Nd1AUCr6tvBKeJi3Y+YNDMrQHMJkF63x094Zi2cQOci1vXKetdXyAU1LFBn/SmQwlJRBVSShikYZh1ChxeHyk3IbHvD+mg6Dhf+mAxFw8qKfeQtamjgtzZsGTas3wNRdE+K0jFBWO4Ox3DV7wkEb5oSeJhHP3DhjWxDmasPxBEB8kJp0jz+0j8AQIciaXY8iBP0/+kw6xBxqcTDR+w9QGZGCD9CjX3euYi7xcSBxibQ7O5HA= + file: telecom-tower-telegram-bot + skip_cleanup: true + overwrite: true + on: + repo: heia-fr/telecom-tower-telegram-bot + tags: true diff --git a/telecom-tower-telegram-bot.go b/telecom-tower-telegram-bot.go index 3f24081..b58d979 100644 --- a/telecom-tower-telegram-bot.go +++ b/telecom-tower-telegram-bot.go @@ -48,7 +48,7 @@ import ( "github.com/nats-io/nats" "github.com/tucnak/telebot" "github.com/vharitonsky/iniflags" - "github.com/zabawaba99/firego" + "github.com/BlueMasters/firebasedb" "net/http" "strings" "time" @@ -75,7 +75,7 @@ var notificationChannels = [...]string{"telecom_tower_notifications"} var bot *telebot.Bot var sessions = make(map[string]*session) // the key is the telegram chat ID and the user ID -var fbase *firego.Firebase +var fbase firebasedb.Reference func dispatchMessage(sender, text, color string) { msg := rollrenderer.TextMessage{ @@ -104,14 +104,11 @@ func dispatchMessage(sender, text, color string) { saveMessage(msg) bitmap := rollrenderer.RenderMessage(&msg) - fbaseData := make(map[string]interface{}) - - fbaseData["currentMessage"] = msg - fbaseData["currentBitmap"] = bitmap - fbaseData["Coucou"] = "C'est nous." - + if err := fbase.Ref("currentMessage").Set(&msg); err != nil { + log.Info(err) + } - if err := fbase.Set(fbaseData); err != nil { + if err := fbase.Ref("currentBitmap").Set(&bitmap); err != nil { log.Info(err) } @@ -240,8 +237,11 @@ func main() { } // Connect to Firebase Database - fbase = firego.New(*fireBaseURL, nil) - fbase.Auth(*fireBaseToken) + fbase, err = firebasedb.NewFirebaseDB(*fireBaseURL) + if err != nil { + log.Fatalf("Error opening firebase: %s", err) + } + fbase = fbase.Auth(*fireBaseToken) bot, err = telebot.NewBot(*token) if err != nil { diff --git a/telecom-tower-telegram-bot.ini b/telecom-tower-telegram-bot.ini deleted file mode 100644 index b451328..0000000 --- a/telecom-tower-telegram-bot.ini +++ /dev/null @@ -1 +0,0 @@ -telegram-token = YOUR_PRIVATE_TELEGRAM_TOKEN \ No newline at end of file