summaryrefslogtreecommitdiff
path: root/irc/users.rkt
blob: 330b965f7f0ec8bc5fc3b09aee3f74f5b082880f (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
33
34
35
36
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))