~williewillus/public-inbox

r16: Replace hardcoded admin check with administrator + manage guild v1 APPLIED

Vincent Lee: 1
 Replace hardcoded admin check with administrator + manage guild

 1 files changed, 11 insertions(+), 9 deletions(-)
#442472 linux_buildtest.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~williewillus/public-inbox/patches/20655/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH r16] Replace hardcoded admin check with administrator + manage guild Export this patch

---
Reply with ok/lgtm and I'll apply :wacko:

 r16.rkt | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/r16.rkt b/r16.rkt
index 97a4910..bc6e918 100755
--- a/r16.rkt
+++ b/r16.rkt
@@ -7,10 +7,8 @@
  (prefix-in db: "trick-db.rkt")

  (only-in racket/serialize serializable-struct/versions)
  (only-in "evaluator.rkt" (run ev:run)))

; williewillus#8490, maintainer, & Vazkii#0999, whose server we hope to run this in
(define bot-admins '("132691314784337920" "156785583723642881"))
  (only-in "evaluator.rkt" (run ev:run))
  threading)

(define prefix "!rkt ")
(define trick-prefix "!!")
@@ -44,13 +42,17 @@
    #f]))

(define (can-modify? message trick)
  (let ([author-id (message-author-id message)])
  (let ([author-id (message-author-id message)]
        [perms (bitwise-ior rc:permission-administrator
                            rc:permission-manage-guild)])
    (or
      (equal? (trick-author trick) author-id)
      ; TODO: Put a check here for Administrator/Manage Members:
      ; Use HTTP to turn message to channel to guild obj, search author ID to get member
      ; Then iter owned roles and lookup in guild to bit-check perms
      (member author-id bot-admins))))
      (let ([memb (rc:message-member message)])
        (and~> memb
               rc:guild-member-permissions
               string->number
               (bitwise-and perms)
               ((compose1 not zero?)))))))

(define (strip-backticks code)
  (let ([groups (regexp-match #px"```(\\w+\n)?(.+)```" code)])
-- 
2.30.1
builds.sr.ht
r16/patches/linux_buildtest.yml: SUCCESS in 1m46s

[Replace hardcoded admin check with administrator + manage guild][0] from [Vincent Lee][1]

[0]: https://lists.sr.ht/~williewillus/public-inbox/patches/20655
[1]: mailto:vincent@vincent-lee.net

✓ #442472 SUCCESS r16/patches/linux_buildtest.yml https://builds.sr.ht/~williewillus/job/442472