Compare commits
No commits in common. "13eec0fb33e0e2d566fa33e669b78adc161c7ff6" and "8d7e2a1ddcdbaabc3830d2b725dcc984a15ba627" have entirely different histories.
13eec0fb33
...
8d7e2a1ddc
76
main.go
76
main.go
|
@ -430,79 +430,9 @@ func main() {
|
|||
case !isChannel && strings.EqualFold(cmd.Name, "updatetopics"):
|
||||
updateTopicsChan <- nil
|
||||
|
||||
case strings.EqualFold(cmd.Name, "!country"),
|
||||
strings.EqualFold(cmd.Name, "!team"):
|
||||
teamList, err := footballData.TeamsOfCompetition(Competition).Do()
|
||||
if err != nil {
|
||||
conn.Noticef(sender, "Sorry, can't display team information at this moment.")
|
||||
log.Print(err)
|
||||
}
|
||||
|
||||
// find correct team
|
||||
name := strings.Join(cmd.Arguments, " ")
|
||||
for _, competitionTeam := range teamList.Teams {
|
||||
if strings.EqualFold(competitionTeam.Name, name) ||
|
||||
// strings.EqualFold(team.Code, name) ||
|
||||
strings.EqualFold(competitionTeam.ShortName, name) {
|
||||
// found matching team
|
||||
if competitionTeam.Id == 0 {
|
||||
conn.Noticef(sender, "Sorry, something went horribly wrong here.")
|
||||
log.Print("Returned team ID of a team in competition was 0...")
|
||||
}
|
||||
|
||||
fixtures, err := footballData.FixturesOfTeam(competitionTeam.Id).
|
||||
// Season(Competition).
|
||||
Do()
|
||||
if err != nil {
|
||||
conn.Noticef(sender, "Sorry, could not fetch fixtures information at this moment.")
|
||||
log.Print(err)
|
||||
return
|
||||
}
|
||||
outputs := []string{}
|
||||
for _, fixture := range fixtures.Fixtures {
|
||||
homeTeam := fixture.HomeTeamName
|
||||
awayTeam := fixture.AwayTeamName
|
||||
var vs string
|
||||
switch fixture.Status {
|
||||
case footballdata.FixtureStatus_InPlay,
|
||||
footballdata.FixtureStatus_Canceled,
|
||||
footballdata.FixtureStatus_Finished:
|
||||
// finished, display score
|
||||
vs = fmt.Sprintf("%d:%d",
|
||||
fixture.Result.GoalsHomeTeam,
|
||||
fixture.Result.GoalsAwayTeam)
|
||||
default:
|
||||
// upcoming, display time
|
||||
vs = fmt.Sprintf("[%s]",
|
||||
fixture.Date.Format("Jan 02 @ 15:04 MST"))
|
||||
}
|
||||
outputs = append(outputs,
|
||||
fmt.Sprintf("%s %s %s",
|
||||
homeTeam, vs, awayTeam))
|
||||
}
|
||||
|
||||
conn.Privmsg(target, strings.Join(outputs, " | "))
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
conn.Noticef(sender, "Sorry, I don't know this team.")
|
||||
|
||||
// Not implemented - football-data api data not reliable enough?
|
||||
case strings.EqualFold(cmd.Name, "!player"):
|
||||
// TODO
|
||||
conn.Noticef(sender, "Sorry, this isn't implemented yet.")
|
||||
|
||||
// Currently implemented:
|
||||
// - !group / !group <Group name> (for example !group a)
|
||||
// Not implemented yet:
|
||||
// - !group <Country name>
|
||||
case strings.EqualFold(cmd.Name, "!group"),
|
||||
strings.EqualFold(cmd.Name, "!table"):
|
||||
case strings.EqualFold(cmd.Name, "!table"):
|
||||
if leagueTable, err := footballData.LeagueTableOfCompetition(Competition).Do(); err != nil {
|
||||
var s string
|
||||
if s, err = tplString("error", err); err != nil {
|
||||
if s, err := tplString("error", err); err != nil {
|
||||
log.Print(err)
|
||||
} else {
|
||||
conn.Privmsg(target, s)
|
||||
|
@ -562,7 +492,7 @@ func main() {
|
|||
actualStanding = v.TeamLeagueStatistics
|
||||
}
|
||||
|
||||
var goalDiffPrefix string
|
||||
goalDiffPrefix := ""
|
||||
if actualStanding.GoalDifference > 0 {
|
||||
goalDiffPrefix = "+"
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue