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 db *boltease.DB
|
||||||
var boardID string
|
var boardID string
|
||||||
|
var aocYear int
|
||||||
|
|
||||||
var slackChannel string
|
var slackChannel string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) != 4 {
|
if len(os.Args) != 5 {
|
||||||
fmt.Fprintf(os.Stderr, "usage: "+programName+" <slack-bot-token> <slack-channel-id> <aoc-leaderboard-number>\n")
|
fmt.Fprintf(os.Stderr, "usage: "+programName+" <slack-bot-token> <slack-channel-id> <aoc-leaderboard-number> <aoc-year>\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +44,11 @@ func main() {
|
|||||||
// DevICT Leaderboard: 3549
|
// DevICT Leaderboard: 3549
|
||||||
boardID = os.Args[3]
|
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 {
|
if slack, err = CreateSlack(os.Args[1]); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -69,7 +75,7 @@ func aocBotMain(slack *Slack) {
|
|||||||
var mbr *Member
|
var mbr *Member
|
||||||
if mbr, err = getAoCUser(v.ID); err != nil {
|
if mbr, err = getAoCUser(v.ID); err != nil {
|
||||||
// Member doesn't exist in db, add it
|
// Member doesn't exist in db, add it
|
||||||
// Notify br0xen ( U030RD9NU )
|
// Notify br0xen ( U030RD9NU, DM: D0D793N5R )
|
||||||
m := new(Message)
|
m := new(Message)
|
||||||
m.Type = "message"
|
m.Type = "message"
|
||||||
m.Channel = "D0D793N5R"
|
m.Channel = "D0D793N5R"
|
||||||
@ -245,7 +251,7 @@ func getAoCLeaderboard(boardId string) (*Leaderboard, error) {
|
|||||||
leaderboard := new(Leaderboard)
|
leaderboard := new(Leaderboard)
|
||||||
|
|
||||||
client := &http.Client{}
|
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)
|
req, err = http.NewRequest("GET", boardString, nil)
|
||||||
// Read in cookies
|
// Read in cookies
|
||||||
|
Reference in New Issue
Block a user