kunt

golang IRC bot
git clone git://git.2f30.org/kunt
Log | Files | Refs | LICENSE

commit 40b636f3a31144d31b7daea6f269eebaa1ea9093
parent 44ef6c70d2d788acdef1a77c2613bd8e22147973
Author: lostd <lostd@2f30.org>
Date:   Thu, 27 Feb 2014 13:37:24 +0200

Handle the whole radio info at the server side

Diffstat:
Msrc/kunt/kunt.go | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/kunt/kunt.go b/src/kunt/kunt.go @@ -235,16 +235,20 @@ func cmdCountUrls(msg irc.Message) { } func cmdRadio(msg irc.Message) { - np, e := http.Get("http://radio.2f30.org:8000/npsong.xsl") + np, e := http.Get("http://radio.2f30.org:8000/") if e != nil { kunt.ircCtx.Privmsg(msg.Args[0], "Is radio broken?") } else { defer np.Body.Close() - song, _ := ioutil.ReadAll(np.Body) - r := fmt.Sprintf("%s", song) - kunt.ircCtx.Privmsg(msg.Args[0], r) - r = "http://radio.2f30.org:8000/live.ogg" - kunt.ircCtx.Privmsg(msg.Args[0], r) + info, _ := ioutil.ReadAll(np.Body) + lines := strings.Split(string(info), "\n") + for _, i := range lines { + if i == "" { + continue + } + kunt.ircCtx.Privmsg(msg.Args[0], i) + time.Sleep(512 * time.Millisecond) + } } }