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 ( import (
"fmt" "fmt"
"math/rand" "regexp"
"strings" "strings"
"time"
"github.com/arachnist/gorepost/irc" "github.com/arachnist/gorepost/irc"
) )
var stripCycki *regexp.Regexp
func cycki(output chan irc.Message, msg irc.Message) { func cycki(output chan irc.Message, msg irc.Message) {
var rmsg string var rmsg string
@ -20,17 +21,17 @@ func cycki(output chan irc.Message, msg irc.Message) {
return 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 { if err != nil {
rmsg = fmt.Sprint("error:", err) rmsg = fmt.Sprint("error:", err)
} else { } else {
rmsg = "bonjour (nsfw): " + img rmsg = "bonjour (nsfw): " + string(stripCycki.ReplaceAll([]byte(img), []byte("")))
} }
output <- reply(msg, rmsg) output <- reply(msg, rmsg)
} }
func init() { func init() {
rand.Seed(time.Now().UnixNano()) stripCycki, _ = regexp.Compile("_preview")
addCallback("PRIVMSG", "bonjour", cycki) addCallback("PRIVMSG", "cycki", cycki)
} }