Remove nasty chars.
parent
7b7fae25ad
commit
4fea7a0116
|
@ -21,6 +21,8 @@ import (
|
||||||
"github.com/arachnist/gorepost/irc"
|
"github.com/arachnist/gorepost/irc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var trimTitle *regexp.Regexp
|
||||||
|
|
||||||
func getUrlTitle(l string) string {
|
func getUrlTitle(l string) string {
|
||||||
var buf []byte
|
var buf []byte
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
|
@ -60,7 +62,7 @@ func getUrlTitle(l string) string {
|
||||||
sr, err := doc.Root().Search(xpath)
|
sr, err := doc.Root().Search(xpath)
|
||||||
|
|
||||||
if len(sr) > 0 {
|
if len(sr) > 0 {
|
||||||
return sr[0].InnerHtml()
|
return string(trimTitle.ReplaceAll([]byte(sr[0].InnerHtml()), []byte{' '})[:])
|
||||||
} else {
|
} else {
|
||||||
return "no title"
|
return "no title"
|
||||||
}
|
}
|
||||||
|
@ -85,10 +87,7 @@ func linktitle(output chan irc.Message, msg irc.Message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(r) > 0 {
|
if len(r) > 0 {
|
||||||
t := strings.Join(
|
t := cfg.LookupString(msg.Context, "LinkTitlePrefix") + strings.Join(r, cfg.LookupString(msg.Context, "LinkTitleDelimiter"))
|
||||||
append([]string{cfg.LookupString(msg.Context, "LinkTitlePrefix")}, r...),
|
|
||||||
cfg.LookupString(msg.Context, "LinkTitleDelimiter"),
|
|
||||||
)
|
|
||||||
|
|
||||||
if msg.Params[0] == cfg.LookupString(msg.Context, "Nick") {
|
if msg.Params[0] == cfg.LookupString(msg.Context, "Nick") {
|
||||||
output <- irc.Message{
|
output <- irc.Message{
|
||||||
|
@ -107,5 +106,6 @@ func linktitle(output chan irc.Message, msg irc.Message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
trimTitle, _ = regexp.Compile("[\\s]+")
|
||||||
addCallback("PRIVMSG", "LINKTITLE", linktitle)
|
addCallback("PRIVMSG", "LINKTITLE", linktitle)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue