diff options
| author | rebecca <ubq323@ubq323.website> | 2026-09-24 18:14:39 +0100 |
|---|---|---|
| committer | rebecca <ubq323@ubq323.website> | 2026-09-24 18:55:05 +0100 |
| commit | 0f7b2979cc6547d00d11ca63fd0a0cc6ea542c25 (patch) | |
| tree | b8255fbc87833aee3c16bdf8431eacb7a2c9faa2 /message.lua | |
| parent | 71cee0014368f5d83fe94989526a4ffb2824f50c (diff) | |
actually add Message class
Diffstat (limited to 'message.lua')
| -rw-r--r-- | message.lua | 19 |
1 files changed, 19 insertions, 0 deletions
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 |
