diff options
Diffstat (limited to 'irc/users.rkt')
-rw-r--r-- | irc/users.rkt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/irc/users.rkt b/irc/users.rkt new file mode 100644 index 0000000..330b965 --- /dev/null +++ b/irc/users.rkt @@ -0,0 +1,37 @@ +#lang racket/base +(require irc/core irc/bot irc/db + racket/match racket/string + db sql) +(provide (all-defined-out)) + +; Power levels +; 0 untrusted +; 1 trusted +; 2 admin + +(define (user-power user) + (or (query-maybe-value (current-database) + (select power #:from users #:where (= name ,user))) + 0)) + +(define (is-untrusted? user) (= 0 (user-power user))) +(define (is-trusted? user) (= 1 (user-power user))) +(define (is-admin? user) (= 2 (user-power user))) + +; Do VERSION, wait for reply +; Store CASEMAPPING in network storage +; Implement case mapping, dependent on that value, with fallback + +; TODO This can leak on repeated timeouts +(define (is-identified? user) + (send (msg 'WHO '() user)) + (define ch (make-channel)) + (on (command-is '|352|) + (match-define + (list-rest own-nick channel _user host + server nick mode suffix) (params)) + (when (string=? nick user) + (channel-put ch (string-contains? mode "r")) + hook-abort)) + (sync/timeout 15 ch)) + |