Add proper cycki plugin.

configurable-file-paths
Robert Gerus 2015-11-19 17:39:59 +01:00 committed by Robert Gerus
parent 57280448c2
commit 32e7422459
1 changed files with 7 additions and 6 deletions

View File

@ -6,13 +6,14 @@ package bot
import (
"fmt"
"math/rand"
"regexp"
"strings"
"time"
"github.com/arachnist/gorepost/irc"
)
var stripCycki *regexp.Regexp
func cycki(output chan irc.Message, msg irc.Message) {
var rmsg string
@ -20,17 +21,17 @@ func cycki(output chan irc.Message, msg irc.Message) {
return
}
img, err := httpGetXpath("http://www.bonjourmadame.fr/page/"+string(rand.Intn(2370)+1), "//div[@class='photo post']//img/@src")
img, err := httpGetXpath("http://oboobs.ru/random/", "//img/@src")
if err != nil {
rmsg = fmt.Sprint("error:", err)
} else {
rmsg = "bonjour (nsfw): " + img
rmsg = "bonjour (nsfw): " + string(stripCycki.ReplaceAll([]byte(img), []byte("")))
}
output <- reply(msg, rmsg)
}
func init() {
rand.Seed(time.Now().UnixNano())
addCallback("PRIVMSG", "bonjour", cycki)
stripCycki, _ = regexp.Compile("_preview")
addCallback("PRIVMSG", "cycki", cycki)
}