Created
May 13, 2015 14:41
-
-
Save AmandaCameron/e320558f7a44b680831a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/drone/drone-plugin-go/plugin" | |
"github.com/thoj/go-ircevent" | |
) | |
func main() { | |
repo := plugin.Repo{} | |
build := plugin.Build{} | |
var params struct { | |
Nick string `json:"nick"` | |
Server string `json:"server"` | |
Channel string `json:"channel"` | |
} | |
plugin.Param("repo", &repo) | |
plugin.Param("build", &build) | |
plugin.Param("vargs", ¶ms) | |
if err := plugin.Parse(); err != nil { | |
log.Fatal(err) | |
} | |
client := irc.IRC(params.Nick, params.Nick) | |
if client == nil { | |
log.Fatal("Failed to make IRC Client.") | |
} | |
err := client.Connect(params.Server) | |
if err != nil { | |
log.Fatal(err) | |
} | |
msg := fmt.Sprintf("[%s/%s] Build %d: %s", repo.Owner, repo.Name, build.Number, build.State) | |
client.AddCallback("001", func(_ *irc.Event) { | |
client.Notice(params.Channel, msg) | |
client.Quit() | |
}) | |
client.Loop() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment