diff options
| author | Andrei <andreisva2023@gmail.com> | 2026-02-13 20:57:05 -0800 |
|---|---|---|
| committer | Andrei <andreisva2023@gmail.com> | 2026-02-13 20:57:05 -0800 |
| commit | 0fa9f69a97b9f695936b907424e4c3d1af6f7452 (patch) | |
| tree | 9a471d3ab005105e8bfcff73184f6beef5dbfa1c /src/main.lisp | |
Initial Commit
Diffstat (limited to 'src/main.lisp')
| -rw-r--r-- | src/main.lisp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main.lisp b/src/main.lisp new file mode 100644 index 0000000..ee37ddc --- /dev/null +++ b/src/main.lisp @@ -0,0 +1,37 @@ +(defpackage nullbot + (:use #:cl + #:cl-hash-util) + (:local-nicknames + (:jzon :com.inuoe.jzon) + (:mapi :nullbot/matrix-api) + (:sseq :split-sequence)) + (:export + #:start)) +(in-package #:nullbot) + +(defclass nullbot (mapi:matrix-bot) ()) +(defparameter *bot* (make-instance 'nullbot + :token (uiop:getenv "NULLBOT_TOKEN") + :homeserver "matrix.nullring.xyz")) + +(defun process-roommsg + (content room-id sender + &aux + (msgtype (gethash "msgtype" content)) + (body (gethash "body" content)) + (split-body (sseq:split-sequence #\Space body)) + (command (car split-body))) + (format t "processing msg~%") + (when (and (> (length body) 0) (equal (aref (car split-body) 0) #\$)) + (cond + ((string= command "$help") + (mapi:sendmsg *bot* room-id "Unlike some other bots, I'm nice :3"))))) + +(defmethod mapi:on-event + ((obj nullbot) event room-id + &aux + (msgtype (gethash "type" event)) + (sender (gethash "sender" event))) + (cond + ((string= msgtype "m.room.message") + (process-roommsg (gethash "content" event) room-id sender)))) |
