From 0fa9f69a97b9f695936b907424e4c3d1af6f7452 Mon Sep 17 00:00:00 2001 From: Andrei Date: Fri, 13 Feb 2026 20:57:05 -0800 Subject: Initial Commit --- src/main.lisp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main.lisp (limited to 'src/main.lisp') 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)))) -- cgit v1.2.3