From 84ff5418808b90381bf30927e1a0746cee8fd7f3 Mon Sep 17 00:00:00 2001 From: Ryan Yeske Date: Wed, 6 Nov 2024 08:51:51 -0700 Subject: [PATCH] lol america --- handlers.go | 3 -- handlers/usvote2024/usvote2024.go | 78 ------------------------------- 2 files changed, 81 deletions(-) delete mode 100644 handlers/usvote2024/usvote2024.go diff --git a/handlers.go b/handlers.go index 40f5646..635f9c1 100644 --- a/handlers.go +++ b/handlers.go @@ -17,7 +17,6 @@ import ( "goirc/handlers/kinfonet" "goirc/handlers/linkpool" "goirc/handlers/mlb" - "goirc/handlers/usvote2024" "goirc/handlers/weather" db "goirc/model" "goirc/web" @@ -69,8 +68,6 @@ func addHandlers(b *bot.Bot) { b.Handle(`^!election`, election.Handle) b.Handle(`^annie:?(.+)$`, annie.Handle) b.Handle(`^(.+),? annie.?$`, annie.Handle) - b.Handle(`^!trump`, usvote2024.HandleTrump) - b.Handle(`^!harris`, usvote2024.HandleHarris) b.Repeat(10*time.Second, handlers.DoRemind) b.IdleRepeatAfterReset(8*time.Hour, handlers.POM) diff --git a/handlers/usvote2024/usvote2024.go b/handlers/usvote2024/usvote2024.go deleted file mode 100644 index 964ebb0..0000000 --- a/handlers/usvote2024/usvote2024.go +++ /dev/null @@ -1,78 +0,0 @@ -package usvote2024 - -import ( - "fmt" - "goirc/bot" - "strings" - - "github.com/gocolly/colly" -) - -type party struct { - Name string - Tally string - Votes string -} - -func (p party) String() string { - return fmt.Sprintf("%s %s (%s)", p.Tally, p.Name, p.Votes) -} - -type results struct { - Rep party - Dem party -} - -func count() (*results, error) { - base := "https://www.reuters.com/graphics/USA-ELECTION/RESULTS/zjpqnemxwvx/" - c := colly.NewCollector() - - results := results{} - - c.OnHTML("div.div-rep", func(e *colly.HTMLElement) { - results.Rep.Tally = e.ChildText("div.tally-numbers") - results.Rep.Name = e.ChildText("div.tally-party") - }) - c.OnHTML("p.div-rep", func(e *colly.HTMLElement) { - results.Rep.Votes = strings.TrimSpace(e.Text) - }) - - c.OnHTML("div.div-dem", func(e *colly.HTMLElement) { - results.Dem.Tally = e.ChildText("div.tally-numbers") - results.Dem.Name = e.ChildText("div.tally-party") - }) - c.OnHTML("p.div-dem", func(e *colly.HTMLElement) { - results.Dem.Votes = strings.TrimSpace(e.Text) - }) - - err := c.Visit(base) - if err != nil { - return nil, err - } - - return &results, nil -} - -func HandleTrump(params bot.HandlerParams) error { - results, err := count() - if err != nil { - return err - } - - params.Privmsgf(params.Target, "%s", results.Rep) - params.Privmsgf(params.Target, "%s", results.Dem) - - return nil -} - -func HandleHarris(params bot.HandlerParams) error { - results, err := count() - if err != nil { - return err - } - - params.Privmsgf(params.Target, "%s", results.Dem) - params.Privmsgf(params.Target, "%s", results.Rep) - - return nil -}