From dc3de32a2c819069400ce0bb5ff4600b97495917 Mon Sep 17 00:00:00 2001 From: Scott Date: Fri, 12 Aug 2016 22:33:44 +1000 Subject: [PATCH] Shortens notification time Separates bot configuration to its own method to allow for repeat use. Also main.go should be small Now reloads bot configuration on the save post. Active changes! --- configRoutes.go | 1 + main.go | 20 ++++++++++++++++++++ web/app/app.js | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/configRoutes.go b/configRoutes.go index c3b5240a..9e34216f 100644 --- a/configRoutes.go +++ b/configRoutes.go @@ -43,6 +43,7 @@ func SaveAllSettings(w http.ResponseWriter, r *http.Request) { log.Println("Fatal error checking config values. Error:", err) panic(err) } + setupBotExchanges() //Return response status w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) diff --git a/main.go b/main.go index 2504976e..a6a567c7 100644 --- a/main.go +++ b/main.go @@ -40,6 +40,24 @@ type Bot struct { var bot Bot +func setupBotExchanges() { + for _, exch := range bot.config.Exchanges { + for i := 0; i < len(bot.exchanges); i++ { + if bot.exchanges[i] != nil { + if bot.exchanges[i].GetName() == exch.Name { + bot.exchanges[i].Setup(exch) + if bot.exchanges[i].IsEnabled() { + log.Printf("%s: Exchange support: %s (Authenticated API support: %s - Verbose mode: %s).\n", exch.Name, IsEnabled(exch.Enabled), IsEnabled(exch.AuthenticatedAPISupport), IsEnabled(exch.Verbose)) + bot.exchanges[i].Start() + } else { + log.Printf("%s: Exchange support: %s\n", exch.Name, IsEnabled(exch.Enabled)) + } + } + } + } + } +} + func main() { HandleInterrupt() log.Println("Loading config file config.json..") @@ -103,6 +121,8 @@ func main() { } } + setupBotExchanges() + err = RetrieveConfigCurrencyPairs(bot.config) if err != nil { diff --git a/web/app/app.js b/web/app/app.js index c3760c57..d3f7c4d0 100644 --- a/web/app/app.js +++ b/web/app/app.js @@ -11,7 +11,7 @@ angular.module('myApp', [ ]). config(['$locationProvider', '$routeProvider' ,'NotificationProvider', function($locationProvider, $routeProvider, NotificationProvider) { NotificationProvider.setOptions({ - delay: 10000, + delay: 5000, startTop: 60, startRight: 10, verticalSpacing: 10,