├── .gitignore ├── README.md ├── info.rkt ├── LICENSE.txt └── main.rkt /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | \#* 3 | .\#* 4 | .DS_Store 5 | compiled/ 6 | /doc/ 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | rot13bot 2 | ======== 3 | 4 | Very simple braidbot that replies to messages sent to it with `rot13(message)` 5 | -------------------------------------------------------------------------------- /info.rkt: -------------------------------------------------------------------------------- 1 | #lang info 2 | (define collection "rot13bot") 3 | (define deps '("base" 4 | "https://github.com/braidchat/braidbot.git#v1.1")) 5 | (define build-deps '("scribble-lib" "racket-doc" "rackunit-lib")) 6 | (define scribblings '(("scribblings/rot13bot.scrbl" ()))) 7 | (define pkg-desc "Description Here") 8 | (define version "0.0") 9 | (define pkg-authors '(james)) 10 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | rot13bot 2 | Copyright (c) 2018 james 3 | 4 | This package is distributed under the GNU Lesser General Public 5 | License (LGPL). This means that you can link rot13bot into proprietary 6 | applications, provided you follow the rules stated in the LGPL. You 7 | can also modify this package; if you distribute a modified version, 8 | you must distribute it under the terms of the LGPL, which in 9 | particular means that you must release the source code for the 10 | modified software. See http://www.gnu.org/copyleft/lesser.html 11 | for more information. 12 | -------------------------------------------------------------------------------- /main.rkt: -------------------------------------------------------------------------------- 1 | #lang braidbot/insta 2 | 3 | (require braidbot/util) 4 | 5 | (define (rot13-ch ch) 6 | (let ([c (char->integer ch)]) 7 | (cond 8 | [(<= (char->integer #\A) c (char->integer #\Z)) 9 | (-> c 10 | (- (char->integer #\A)) 11 | (+ 13) 12 | (modulo 26) 13 | (+ (char->integer #\A)) 14 | integer->char)] 15 | [(<= (char->integer #\a) c (char->integer #\z)) 16 | (-> c 17 | (- (char->integer #\a)) 18 | (+ 13) 19 | (modulo 26) 20 | (+ (char->integer #\a)) 21 | integer->char)] 22 | [else ch]))) 23 | 24 | (define (rot13 txt) 25 | (->> txt 26 | string->list 27 | (map rot13-ch) 28 | list->string)) 29 | 30 | (define bot-id (or (getenv "BOT_ID") "5a5021d0-c517-4e27-ac1e-12a7b3d7a6c6")) 31 | (define bot-token (or (getenv "BOT_TOKEN") "91nPY7IFP5W68SCk3p0zoCCSCKeduLHnIJfZG2ou")) 32 | (define braid-url (or (getenv "BRAID_URL") "http://localhost:5557")) 33 | 34 | (listen-port 9988) 35 | 36 | (define (act-on-message msg) 37 | (reply-to msg (-> msg 38 | (hash-ref '#:content) 39 | (string-replace "/rot13" "" #:all? #f) 40 | rot13) 41 | #:bot-id bot-id 42 | #:bot-token bot-token 43 | #:braid-url braid-url)) 44 | --------------------------------------------------------------------------------