summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Gerus <arachnist@i.am-a.cat>2015-12-15 21:40:11 +0100
committerRobert Gerus <arachnist@i.am-a.cat>2015-12-15 21:40:11 +0100
commit38462960d355ca05a819c304c02d1636efaabe79 (patch)
treeae4c07af7eb615f0ef5638c5aa2fd2005f365096
parent945cc314d21629475b4e9831a3b4f582a2cef5bb (diff)
downloadgorepost-38462960d355ca05a819c304c02d1636efaabe79.tar.gz
gorepost-38462960d355ca05a819c304c02d1636efaabe79.tar.bz2
gorepost-38462960d355ca05a819c304c02d1636efaabe79.tar.xz
gorepost-38462960d355ca05a819c304c02d1636efaabe79.zip
Bonjour Madame lives again.
-rw-r--r--bot/bonjour.go7
-rw-r--r--bot/plugins_test.go12
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
@@ -776,6 +776,18 @@ var variableOutputTestEvents = []struct {
{
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",
Trailing: ":at",
Params: []string{"#testchan-1"},
Prefix: &irc.Prefix{