Compare commits

..

No commits in common. "2201a35120fa87f750397e822fff615dbd38a59b" and "feacda166a89ad3fec2e2ac2b2fc6d3ca5f1f220" have entirely different histories.

2 changed files with 1 additions and 27 deletions

3
.gitignore vendored
View File

@ -1,2 +1 @@
.env .env
hop.yml

25
main.go
View File

@ -8,8 +8,6 @@ import (
"syscall" "syscall"
"strings" "strings"
"regexp" "regexp"
"io"
"net/http"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/spf13/viper" "github.com/spf13/viper"
@ -75,29 +73,6 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf(":whale2: :dash: %s", c[1])) s.ChannelMessageSend(m.ChannelID, fmt.Sprintf(":whale2: :dash: %s", c[1]))
} }
return return
} else if strings.HasPrefix(m.Content, "!weather") {
c := strings.Fields(m.Content)
if len(c) == 2 {
// contact wttr.in
url := fmt.Sprintf("https://wttr.in/%s?0QAT", c[1])
resp, err := http.Get(url)
if err != nil {
fmt.Printf("ERROR while running $weather: %s", err)
return
}
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("ERROR while running $weather: %s", err)
return
}
body_string := string(body[:])
if strings.Contains(body_string, "404 UNKNOWN") {
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("That's not a city, silly!"))
return
}
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("```%s```", body_string))
}
return
} }
// check for reddit/twitter links and replace them with open source frontends // check for reddit/twitter links and replace them with open source frontends