unsplash: Try to strip unreadable characters
This commit is contained in:
parent
a7768b3ae0
commit
0919398edc
1 changed files with 10 additions and 0 deletions
|
@ -41,6 +41,13 @@ func initunsplash() {
|
||||||
log.Println("[unsplash] Loaded!")
|
log.Println("[unsplash] Loaded!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stripUnreadable(r rune) rune {
|
||||||
|
if r < 32 || r >= 0x1f000 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
func unsplash(broker *tg.Broker, update tg.APIMessage) {
|
func unsplash(broker *tg.Broker, update tg.APIMessage) {
|
||||||
if isCommand(update, "unsplash") {
|
if isCommand(update, "unsplash") {
|
||||||
text := ""
|
text := ""
|
||||||
|
@ -59,6 +66,9 @@ func unsplash(broker *tg.Broker, update tg.APIMessage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup chars
|
||||||
|
text = strings.Map(stripUnreadable, text)
|
||||||
|
|
||||||
author := user.FirstName
|
author := user.FirstName
|
||||||
if user.LastName != "" {
|
if user.LastName != "" {
|
||||||
author = user.FirstName + " " + user.LastName
|
author = user.FirstName + " " + user.LastName
|
||||||
|
|
Reference in a new issue