|
|
|
@ -5,6 +5,7 @@ import (
|
|
|
|
|
"fmt" |
|
|
|
|
_ "github.com/mattn/go-sqlite3" |
|
|
|
|
"log" |
|
|
|
|
"strings" |
|
|
|
|
"time" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -85,8 +86,16 @@ func (q *QuoteDB) FindLastQuote(channel string) (*Quote, error) {
|
|
|
|
|
return quote, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func escapeLike(text string) string { |
|
|
|
|
text = strings.ReplaceAll(text, `\`, ``) |
|
|
|
|
text = strings.ReplaceAll(text, `%`, `\%`) |
|
|
|
|
text = strings.ReplaceAll(text, `_`, `\_`) |
|
|
|
|
|
|
|
|
|
return text |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (q QuoteDB) FindQuotesByString(search string, channel string) ([]*Quote, error) { |
|
|
|
|
term := fmt.Sprintf("%%%s%%", search) |
|
|
|
|
term := fmt.Sprintf("%%%s%%", escapeLike(search)) |
|
|
|
|
|
|
|
|
|
rows, err := q.DB.Query(findQuotesByTerm, channel, term) |
|
|
|
|
|
|
|
|
|