diff --git a/README.md b/README.md index 6a8da12..8e0ea3c 100644 --- a/README.md +++ b/README.md @@ -27,55 +27,39 @@ bash build.sh ## Parameters -The Scorebord can be configured by command line options, though it's preferred to use a config file instead. (Below). +The Scoreboard can be configured by command line options, though it's preferred to use a config file instead. (Below). ```text -Scorebot Scoreboard v2.0 - -Usage: - -assets string - Secondary Assets Override URL. - -bind string - Address and Port to Listen on. (default "0.0.0.0:8080") - -c string - Scorebot Config File Path. - -cert string - Path to TLS Certificate File. - -d Print Default Config and Exit. - -dir string - Scoreboard HTML Directory Path. - -key string - Path to TLS Key File. - -log string - Scoreboard Log File Path. - -log-level int - Scoreboard Log Level. (default 2) - -sbe string - Scorebot Core Address or URL. - -tick int - Scoreboard Poll Rate. (in seconds) (default 5) - -timeout int - Scoreboard Request Timeout. (in seconds) (default 10) - -tw-ak string - Twitter Access API Key. - -tw-as string - Twitter Access API Secret. - -tw-block-user string - Twitter Blocked Usernames. (comma separated) - -tw-block-words string - Twitter Blocked Words. (comma separated) - -tw-ck string - Twitter Consumer API Key. - -tw-cs string - Twitter Consumer API Secret. - -tw-expire int - Tweet Display Time. (in seconds) (default 45) - -tw-keywords string - Twitter Search Keywords. (comma separated) - -tw-lang string - Twitter Search Language. (comma separated) - -tw-only-users string - Twitter Whitelisted Usernames. (comma separated) +Scorebot Scoreboard v2.0.2 + +Leaving any of the required Twitter options empty in command +line or config will result in Twitter functionality being disabled. +Required Twitter options: 'Consumer Key and Secret', 'Access Key and Secret', +'Twitter Keywords' and 'Twitter Language'. + +Usage of scorebot-scoreboard: + -c Scorebot configuration file path. + -d Print default configuration and exit. + -sbe Scorebot core address or URL (Required without "-c"). + -assets Scoreboard secondary assets override URL. + -dir Scoreboard HTML override directory path. + -log Scoreboard log file path. + -log-level Scoreboard logging level (Default 2). + -tick Scorebot poll tate, in seconds (Default 5). + -timeout Scoreboard request timeout, in seconds (Default 10). + -bind Address and port to listen on (Default "0.0.0.0:8080"). + -cert Path to TLS certificate file. + -key Path to TLS key file. + -tw-ck Twitter Consumer API key. + -tw-cs Twitter Consumer API secret. + -tw-ak Twitter Access API key. + -tw-as Twitter Access API secret. + -tw-keywords Twitter search keywords (Comma separated) + -tw-lang Twitter search language (Comma separated) + -tw-expire Tweet display time, in seconds (Default 45). + -tw-block-words Twitter blocked words (Comma separated). + -tw-block-user Twitter blocked Usernames (Comma separated). + -tw-only-users Twitter whitelisted Usernames (Comma separated). ``` ## Config File @@ -88,7 +72,7 @@ Default Config: ```json { "log": { - "file": "", + "file": "scoreboard.log", "level": 2 }, "tick": 5, @@ -108,7 +92,6 @@ Default Config: "banned_words": [] }, "expire": 45, - "timeout": 10, "auth": { "access_key": "", "consumer_key": "", diff --git a/html/public/script/scoreboard.js b/html/public/script/scoreboard.js index e96cc16..e2d9677 100644 --- a/html/public/script/scoreboard.js +++ b/html/public/script/scoreboard.js @@ -13,7 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program.If not, see . // -// Scoreboard v2.0 +// Scoreboard v2.0.2 // 2019 iDigitalFlame, The Scorebot Project, CTF Factory // // Javascript Main File diff --git a/html/public/style/scoreboard.css b/html/public/style/scoreboard.css index a8a3675..34b26b5 100644 --- a/html/public/style/scoreboard.css +++ b/html/public/style/scoreboard.css @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . - Scoreboard v2.0 + Scoreboard v2.0.2 2020 iDigitalFlame CSS Main File diff --git a/html/template/home.html b/html/template/home.html index c22a562..329b6b5 100644 --- a/html/template/home.html +++ b/html/template/home.html @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . - Scoreboard v2.0 + Scoreboard v2.0.2 2020 iDigitalFlame Games Template List Page diff --git a/html/template/scoreboard.html b/html/template/scoreboard.html index 032630b..0e22e4a 100644 --- a/html/template/scoreboard.html +++ b/html/template/scoreboard.html @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . - Scoreboard v2.0 + Scoreboard v2.0.2 2020 iDigitalFlame Scoreboard HTML Template Page diff --git a/scoreboard/config.go b/scoreboard/config.go index a2d59f8..edd30a2 100644 --- a/scoreboard/config.go +++ b/scoreboard/config.go @@ -72,7 +72,6 @@ type configFilter struct { type configTwitter struct { Filter configFilter `json:"filter"` Expire int `json:"expire"` - Timeout int `json:"timeout"` Credentials configCreds `json:"auth"` } @@ -84,8 +83,8 @@ func defaults() { c.Twitter.Filter.OnlyUsers = []string{} c.Twitter.Filter.Language = []string{"en"} c.Log.File, c.Log.Level = "scoreboard.log", 2 - c.Tick, c.Timeout = defaultTick, defaultTimeout c.Twitter.Filter.Keywords = []string{"pvj", "ctf"} + c.Tick, c.Timeout, c.Twitter.Expire = defaultTick, defaultTimeout, defaultExpire c.Twitter.Filter.BlockedUsers, c.Twitter.Filter.BlockedWords = []string{}, []string{} b, _ := json.MarshalIndent(c, "", " ") fmt.Fprintln(os.Stdout, string(b)) @@ -101,10 +100,10 @@ func split(s string) []string { return o } func (c *config) verify() error { - if c.Tick < 0 { + if c.Tick <= 0 { return fmt.Errorf("tick cannot be less than or equal to zero: %w", errInvalidNumber) } - if c.Timeout < 0 { + if c.Timeout <= 0 { return fmt.Errorf("timeout cannot be less than or equal to zero: %w", errInvalidNumber) } if c.Log.Level < int(logx.Trace) || c.Log.Level > int(logx.Fatal) { @@ -123,6 +122,9 @@ func (c *config) verify() error { if len(c.Twitter.Credentials.ConsumerKey) == 0 || len(c.Twitter.Credentials.ConsumerSecret) == 0 { c.twitter = false } + if c.twitter && c.Twitter.Expire <= 0 { + return fmt.Errorf("tweet expire time cannot be less than or equal to zero: %w", errInvalidNumber) + } return nil } @@ -158,12 +160,12 @@ func Cmdline() (*Scoreboard, error) { args.StringVar(&c.Twitter.Credentials.ConsumerSecret, "tw-cs", "", "Twitter Consumer API secret.") args.StringVar(&c.Twitter.Credentials.AccessKey, "tw-ak", "", "Twitter Access API key.") args.StringVar(&c.Twitter.Credentials.AccessSecret, "tw-as", "", "Twitter Access API secret.") - args.StringVar(&twk, "tw-keywords", "", "Twitter search keywords (Comma seperated)") - args.StringVar(&twl, "tw-lang", "", "Twitter search language (Comma seperated)") + args.StringVar(&twk, "tw-keywords", "", "Twitter search keywords (Comma separated)") + args.StringVar(&twl, "tw-lang", "", "Twitter search language (Comma separated)") args.IntVar(&c.Twitter.Expire, "tw-expire", defaultExpire, "Tweet display time, in seconds (Default 45).") - args.StringVar(&twbWords, "tw-block-words", "", "Twitter blocked words (Comma seperated).") - args.StringVar(&twbUsers, "tw-block-user", "", "Twitter blocked Usernames (Comma seperated).") - args.StringVar(&twoUsers, "tw-only-users", "", "Twitter whitelisted Usernames (Comma seperated).") + args.StringVar(&twbWords, "tw-block-words", "", "Twitter blocked words (Comma separated).") + args.StringVar(&twbUsers, "tw-block-user", "", "Twitter blocked Usernames (Comma separated).") + args.StringVar(&twoUsers, "tw-only-users", "", "Twitter whitelisted Usernames (Comma separated).") if err := args.Parse(os.Args[1:]); err != nil { fmt.Fprintf(os.Stderr, usage, version, os.Args[0]) return nil, flag.ErrHelp diff --git a/scoreboard/scoreboard.go b/scoreboard/scoreboard.go index 7b61bd5..d4c4776 100644 --- a/scoreboard/scoreboard.go +++ b/scoreboard/scoreboard.go @@ -47,7 +47,7 @@ const ( usage = `Scorebot Scoreboard v%.1f Leaving any of the required Twitter options empty in command -line or config will result in Twiter functionality being disabled. +line or config will result in Twitter functionality being disabled. Required Twitter options: 'Consumer Key and Secret', 'Access Key and Secret', 'Twitter Keywords' and 'Twitter Language'. @@ -71,9 +71,9 @@ Usage of %s: -tw-keywords Twitter search keywords (Comma separated) -tw-lang Twitter search language (Comma separated) -tw-expire Tweet display time, in seconds (Default 45). - -tw-block-words Twitter blocked words (Comma seperated). - -tw-block-user Twitter blocked Usernames (Comma seperated). - -tw-only-users Twitter whitelisted Usernames (Comma seperated). + -tw-block-words Twitter blocked words (Comma separated). + -tw-block-user Twitter blocked Usernames (Comma separated). + -tw-only-users Twitter whitelisted Usernames (Comma separated). Copyright (C) 2020 iDigitalFlame @@ -91,7 +91,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . ` - version = 2.0 + version = 2.02 ) var resources = packr.New("html", "../html")