Add year as argument
This commit is contained in:
parent
be18316c16
commit
3bddd7cf44
14
aocbot.go
14
aocbot.go
@ -18,12 +18,13 @@ const programName = "aocbot"
|
||||
|
||||
var db *boltease.DB
|
||||
var boardID string
|
||||
var aocYear int
|
||||
|
||||
var slackChannel string
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 4 {
|
||||
fmt.Fprintf(os.Stderr, "usage: "+programName+" <slack-bot-token> <slack-channel-id> <aoc-leaderboard-number>\n")
|
||||
if len(os.Args) != 5 {
|
||||
fmt.Fprintf(os.Stderr, "usage: "+programName+" <slack-bot-token> <slack-channel-id> <aoc-leaderboard-number> <aoc-year>\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@ -43,6 +44,11 @@ func main() {
|
||||
// DevICT Leaderboard: 3549
|
||||
boardID = os.Args[3]
|
||||
|
||||
yearStr := os.Args[4]
|
||||
if aocYear, err = strconv.Atoi(yearStr); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if slack, err = CreateSlack(os.Args[1]); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -69,7 +75,7 @@ func aocBotMain(slack *Slack) {
|
||||
var mbr *Member
|
||||
if mbr, err = getAoCUser(v.ID); err != nil {
|
||||
// Member doesn't exist in db, add it
|
||||
// Notify br0xen ( U030RD9NU )
|
||||
// Notify br0xen ( U030RD9NU, DM: D0D793N5R )
|
||||
m := new(Message)
|
||||
m.Type = "message"
|
||||
m.Channel = "D0D793N5R"
|
||||
@ -245,7 +251,7 @@ func getAoCLeaderboard(boardId string) (*Leaderboard, error) {
|
||||
leaderboard := new(Leaderboard)
|
||||
|
||||
client := &http.Client{}
|
||||
boardString := "http://adventofcode.com/2016/leaderboard/private/view/" + boardId + ".json"
|
||||
boardString := fmt.Sprintf("http://adventofcode.com/%d/leaderboard/private/view/%s.json", aocYear, boardId)
|
||||
|
||||
req, err = http.NewRequest("GET", boardString, nil)
|
||||
// Read in cookies
|
||||
|
Reference in New Issue
Block a user