From 38462960d355ca05a819c304c02d1636efaabe79 Mon Sep 17 00:00:00 2001 From: Robert Gerus Date: Tue, 15 Dec 2015 21:40:11 +0100 Subject: [PATCH] Bonjour Madame lives again. --- bot/bonjour.go | 7 ++++--- bot/plugins_test.go | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bot/bonjour.go b/bot/bonjour.go index 28c525c..bf17698 100644 --- a/bot/bonjour.go +++ b/bot/bonjour.go @@ -1,5 +1,3 @@ -// +build bonjourmadame -// // Copyright 2015 Robert S. Gerus. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -22,7 +20,10 @@ func bonjour(output func(irc.Message), msg irc.Message) { return } - img, err := httpGetXpath("http://www.bonjourmadame.fr/page/"+fmt.Sprintf("%d", rand.Intn(2370)+1), "//div[@class='photo post']//img/@src") + t, _ := time.Parse("2006-01-02", "2015-12-01") + max := int(time.Now().Sub(t).Hours())/24 + 1 + + img, err := httpGetXpath("http://ditesbonjouralamadame.tumblr.com/page/"+fmt.Sprintf("%d", rand.Intn(max)+1), "//div[@class='photo post']//a/@href") if err != nil { rmsg = fmt.Sprint("error:", err) } else { diff --git a/bot/plugins_test.go b/bot/plugins_test.go index f05fd05..fedd783 100644 --- a/bot/plugins_test.go +++ b/bot/plugins_test.go @@ -773,6 +773,18 @@ var variableOutputTestEvents = []struct { outRegex: *regexp.MustCompile("^cycki [(]nsfw[)]: http://.*"), function: cycki, }, + { + in: irc.Message{ + Command: "PRIVMSG", + Trailing: ":bonjour", + Params: []string{"#testchan-1"}, + Prefix: &irc.Prefix{ + Name: "idontexist", + }, + }, + outRegex: *regexp.MustCompile("^bonjour [(]nsfw[)]: http://.*"), + function: bonjour, + }, { in: irc.Message{ Command: "PRIVMSG",