From 0f7b2979cc6547d00d11ca63fd0a0cc6ea542c25 Mon Sep 17 00:00:00 2001 From: rebecca Date: Thu, 24 Sep 2026 18:14:39 +0100 Subject: actually add Message class --- message.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 message.lua (limited to 'message.lua') diff --git a/message.lua b/message.lua new file mode 100644 index 0000000..092f332 --- /dev/null +++ b/message.lua @@ -0,0 +1,19 @@ +local class = require'r.class' + +local BasePylon = require 'pylon' +local Thing = require 'thing' + +local Message = class() +-- since this is the beating heart of wilson, it pays to do some validation +function Message.make(cls, self) + setmetatable(self,cls) + for k,v in pairs{ + pylon=BasePylon, + channel=Thing, + author=Thing, + } do assert(class.is(self[k],v), 'field '..k..' missing or wrong') end + assert(type(self.body)=='string','field body missing or wrong') + assert(self.pylon == self.channel.pylon and self.pylon == self.author.pylon, + "inconsistent pylons!") + return self end +return Message -- cgit v1.2.3