unsplash: Try to strip unreadable characters

This commit is contained in:
Hamcha 2017-04-21 10:18:57 +02:00
parent a7768b3ae0
commit 0919398edc

View file

@ -41,6 +41,13 @@ func initunsplash() {
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) {
if isCommand(update, "unsplash") {
text := ""
@ -59,6 +66,9 @@ func unsplash(broker *tg.Broker, update tg.APIMessage) {
}
}
// Cleanup chars
text = strings.Map(stripUnreadable, text)
author := user.FirstName
if user.LastName != "" {
author = user.FirstName + " " + user.LastName