Skip to content

Commit

Permalink
Updated Readme
Browse files Browse the repository at this point in the history
Removed the Twitter.Timeout int
Fixed the default check for expire to be >0
Fixed an issue where 0 values would be valid (when they're not!)
  • Loading branch information
iDigitalFlame committed Apr 5, 2020
1 parent fdf1512 commit 134c273
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 67 deletions.
81 changes: 32 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file> Scorebot configuration file path.
-d Print default configuration and exit.
-sbe <url> Scorebot core address or URL (Required without "-c").
-assets <dir> Scoreboard secondary assets override URL.
-dir <directory> Scoreboard HTML override directory path.
-log <file> Scoreboard log file path.
-log-level <number [0-5]> Scoreboard logging level (Default 2).
-tick <seconds> Scorebot poll tate, in seconds (Default 5).
-timeout <seconds> Scoreboard request timeout, in seconds (Default 10).
-bind <socket> Address and port to listen on (Default "0.0.0.0:8080").
-cert <file> Path to TLS certificate file.
-key <file> Path to TLS key file.
-tw-ck <key> Twitter Consumer API key.
-tw-cs <secret> Twitter Consumer API secret.
-tw-ak <key> Twitter Access API key.
-tw-as <secret> Twitter Access API secret.
-tw-keywords <list> Twitter search keywords (Comma separated)
-tw-lang <list> Twitter search language (Comma separated)
-tw-expire <seconds> Tweet display time, in seconds (Default 45).
-tw-block-words <list> Twitter blocked words (Comma separated).
-tw-block-user <list> Twitter blocked Usernames (Comma separated).
-tw-only-users <list> Twitter whitelisted Usernames (Comma separated).
```

## Config File
Expand All @@ -88,7 +72,7 @@ Default Config:
```json
{
"log": {
"file": "",
"file": "scoreboard.log",
"level": 2
},
"tick": 5,
Expand All @@ -108,7 +92,6 @@ Default Config:
"banned_words": []
},
"expire": 45,
"timeout": 10,
"auth": {
"access_key": "",
"consumer_key": "",
Expand Down
2 changes: 1 addition & 1 deletion html/public/script/scoreboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program.If not, see <https://www.gnu.org/licenses/>.
//
// Scoreboard v2.0
// Scoreboard v2.0.2
// 2019 iDigitalFlame, The Scorebot Project, CTF Factory
//
// Javascript Main File
Expand Down
2 changes: 1 addition & 1 deletion html/public/style/scoreboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Scoreboard v2.0
Scoreboard v2.0.2
2020 iDigitalFlame
CSS Main File
Expand Down
2 changes: 1 addition & 1 deletion html/template/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Scoreboard v2.0
Scoreboard v2.0.2
2020 iDigitalFlame
Games Template List Page
Expand Down
2 changes: 1 addition & 1 deletion html/template/scoreboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Scoreboard v2.0
Scoreboard v2.0.2
2020 iDigitalFlame
Scoreboard HTML Template Page
Expand Down
20 changes: 11 additions & 9 deletions scoreboard/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand All @@ -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))
Expand All @@ -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) {
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions scoreboard/scoreboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand All @@ -71,9 +71,9 @@ Usage of %s:
-tw-keywords <list> Twitter search keywords (Comma separated)
-tw-lang <list> Twitter search language (Comma separated)
-tw-expire <seconds> Tweet display time, in seconds (Default 45).
-tw-block-words <list> Twitter blocked words (Comma seperated).
-tw-block-user <list> Twitter blocked Usernames (Comma seperated).
-tw-only-users <list> Twitter whitelisted Usernames (Comma seperated).
-tw-block-words <list> Twitter blocked words (Comma separated).
-tw-block-user <list> Twitter blocked Usernames (Comma separated).
-tw-only-users <list> Twitter whitelisted Usernames (Comma separated).
Copyright (C) 2020 iDigitalFlame
Expand All @@ -91,7 +91,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
`
version = 2.0
version = 2.02
)

var resources = packr.New("html", "../html")
Expand Down

0 comments on commit 134c273

Please sign in to comment.