Link weather module, changed shortcuts to "!weather" and "!wetter"

This commit is contained in:
Andreas Neue 2016-02-06 23:30:34 +01:00
parent cde6e49baa
commit 69e8ef85b1
4 changed files with 13 additions and 5 deletions

View File

@ -3,7 +3,7 @@ export GOPATH
default: build default: build
build: test genversion genbuilddate build: genversion genbuilddate test
go build -v flokatirc go build -v flokatirc
build-win: test genversion build-win: test genversion

View File

@ -1,4 +1,5 @@
## flokatirc ## flokatirc
*an incredibly friendly, silver-tongued, and elegantly proportioned IRC community bot* *an incredibly friendly, silver-tongued, and elegantly proportioned IRC community bot*
#### LICENSE #### LICENSE
@ -7,5 +8,5 @@ See `LICENSE` file.
#### QUICK INSTALL #### QUICK INSTALL
`# go build flokatirc` `# make build`

11
main.go
View File

@ -24,6 +24,7 @@ import (
modsc "flokatirc/modules/sc" modsc "flokatirc/modules/sc"
modstoll "flokatirc/modules/stoll" modstoll "flokatirc/modules/stoll"
modtwitch "flokatirc/modules/twitch" modtwitch "flokatirc/modules/twitch"
modweather "flokatirc/modules/weather"
) )
var ( var (
@ -77,6 +78,9 @@ func main() {
if strings.Contains(*modules, "twitch") { if strings.Contains(*modules, "twitch") {
go modtwitch.Init(sayCh) go modtwitch.Init(sayCh)
} }
if strings.Contains(*modules, "weather") {
go modweather.Init(sayCh)
}
go func() { go func() {
for { for {
@ -130,7 +134,8 @@ func ConnectHandler(s ircx.Sender, m *irc.Message) {
}) })
} }
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
sayCh <- fmt.Sprintf("%s\n\x01ACTION running on %s", "*", SoftwareInfo()) //sayCh <- fmt.Sprintf("%s\n\001ACTION running on %s", "*", SoftwareInfo())
sayCh <- fmt.Sprintf("%s\n%s", "*", SoftwareInfo())
} }
func PingHandler(s ircx.Sender, m *irc.Message) { func PingHandler(s ircx.Sender, m *irc.Message) {
@ -150,6 +155,7 @@ func PrivmsgHandler(s ircx.Sender, m *irc.Message) {
modstoll.HandleMessage(m) modstoll.HandleMessage(m)
modsaytime.HandleMessage(m) modsaytime.HandleMessage(m)
modtwitch.HandleMessage(m) modtwitch.HandleMessage(m)
modweather.HandleMessage(m)
} }
func HandleMessage(m *irc.Message) { func HandleMessage(m *irc.Message) {
@ -159,7 +165,8 @@ func HandleMessage(m *irc.Message) {
} }
switch tok[0] { switch tok[0] {
case "!version": case "!version":
sayCh <- fmt.Sprintf("%s\n\x01ACTION running on %s", "*", SoftwareInfo()) //sayCh <- fmt.Sprintf("%s\n\001ACTION running on %s", "*", SoftwareInfo())
sayCh <- fmt.Sprintf("%s\n%s", "*", SoftwareInfo())
default: default:
} }
} }

View File

@ -80,7 +80,7 @@ func HandleMessage(m *irc.Message) {
return return
} }
switch tok[0] { switch tok[0] {
case "!w": case "!weather", "!wetter":
switch len(tok) { switch len(tok) {
case 1: case 1:
sayCh <- fmt.Sprintf("*\n%s", weatherPrefix+"Usage: !w <zip/city/state/country>") sayCh <- fmt.Sprintf("*\n%s", weatherPrefix+"Usage: !w <zip/city/state/country>")