blob: 09c2f93f2e536ed394b04becc28f3f1edbab69eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#lang racket/base
(require irc/command
racket/sequence racket/function racket/format)
(provide (all-defined-out))
(define (short-arg? v)
(or (string? v) (symbol? v) (number? v)))
(define (ensure-all-short v)
(unless (andmap short-arg? v)
(error-user "You may only supply short (string, symbol, number) arguments")))
(define (stringify v)
(cond [(string? v) (clean-control v)]
[(symbol? v) (clean-control (symbol->string v))]
[(number? v) (~a v)]
[else "<invalid>"]))
(define (clean-control s)
(list->string
(sequence->list
(sequence-filter (negate char-iso-control?)
(in-string s)))))
; insert zero-width space to prevent clients from notifying a user
(define (break-highlight s)
(if (zero? (string-length s))
s
(string-append
(substring s 0 1)
"\u200B"
(substring s 1))))
|