From f665b166adbf28b9170288fb2d00b2637ae6f3e1 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Tue, 17 May 2016 22:16:00 -0400 Subject: [PATCH 1/2] Add regexp to clean ugly Slack URLs --- slack/slack.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/slack/slack.go b/slack/slack.go index ead635f..cf453e5 100644 --- a/slack/slack.go +++ b/slack/slack.go @@ -11,6 +11,7 @@ import ( "log" "net/http" "net/url" + "regexp" "strconv" "strings" "sync/atomic" @@ -158,11 +159,16 @@ func (s *Slack) Serve() { } } +var urlDetector = regexp.MustCompile(`<(.+)://([^|^>]+).*>`) + // Convert a slackMessage to a msg.Message func (s *Slack) buildMessage(m slackMessage) msg.Message { log.Printf("DEBUG: msg: %#v", m) text := html.UnescapeString(m.Text) + // remove <> from URLs, URLs may also be + text = urlDetector.ReplaceAllString(text, "${1}://${2}") + isCmd, text := bot.IsCmd(s.config, text) isAction := strings.HasPrefix(text, "/me ") From 46deb933dadc7af1731e45616570a10ad7922254 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Tue, 17 May 2016 22:19:46 -0400 Subject: [PATCH 2/2] Add some misc little fixes to web views and factoid timing --- plugins/fact/factoid.go | 2 +- plugins/fact/webTemplates.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/fact/factoid.go b/plugins/fact/factoid.go index ef1f1db..a33eb1f 100644 --- a/plugins/fact/factoid.go +++ b/plugins/fact/factoid.go @@ -609,7 +609,7 @@ func (p *Factoid) randomFact() *factoid { // factTimer spits out a fact at a given interval and with given probability func (p *Factoid) factTimer(channel string) { - duration := time.Duration(p.Bot.Config().Factoid.QuoteTime) * time.Second + duration := time.Duration(p.Bot.Config().Factoid.QuoteTime) * time.Minute myLastMsg := time.Now() for { time.Sleep(time.Duration(5) * time.Second) // why 5? diff --git a/plugins/fact/webTemplates.go b/plugins/fact/webTemplates.go index cb56ea8..d3f7ee6 100644 --- a/plugins/fact/webTemplates.go +++ b/plugins/fact/webTemplates.go @@ -12,16 +12,16 @@ var factoidIndex string = ` Factoids - + - + - + - +