diff --git a/mods/unsplash.go b/mods/unsplash.go index dba2976..1ba99ca 100644 --- a/mods/unsplash.go +++ b/mods/unsplash.go @@ -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