Yessiest
2 years ago
12 changed files with 642 additions and 735 deletions
-
116libraries/classes/acl.lua
-
50libraries/classes/baseclass.lua
-
120libraries/classes/command-acl.lua
-
164libraries/classes/command-handler.lua
-
260libraries/classes/command.lua
-
122libraries/classes/emitter-proxy.lua
-
12libraries/classes/interfaces/discord.lua
-
90libraries/classes/monitor.lua
-
192libraries/classes/plugin-handler.lua
-
70libraries/classes/plugin.lua
-
156libraries/classes/server-handler.lua
-
25plugins/debug/init.lua
@ -1,32 +1,32 @@ |
|||
--class generator (for the purpose of creating classes) |
|||
return function(name) |
|||
local new_class = {} |
|||
new_class.__classname = name or "Object" |
|||
new_class.__index = new_class |
|||
new_class.__new = function(self,...) |
|||
local obj = {} |
|||
--set metamethod proetection measures |
|||
setmetatable(obj,{__index = function(obj,key) |
|||
if key:find("^__") then |
|||
return nil |
|||
else |
|||
return self[key] |
|||
end |
|||
end, |
|||
__name = new_class.__classname}) |
|||
if self.__init then |
|||
self.__init(obj,...) |
|||
end |
|||
return obj |
|||
end |
|||
new_class.extend = function(self,name) |
|||
local new_class = {} |
|||
new_class.__classname = name or "Object" |
|||
new_class.__index = new_class |
|||
setmetatable(new_class,{__index = self,__call = function(...) return new_class.__new(...) end, __name = new_class.__classname.." (class)"}) |
|||
new_class.__new = function(self,...) |
|||
local obj = {} |
|||
--set metamethod proetection measures |
|||
setmetatable(obj,{__index = function(obj,key) |
|||
if key:find("^__") then |
|||
return nil |
|||
else |
|||
return self[key] |
|||
end |
|||
end, |
|||
__name = new_class.__classname}) |
|||
if self.__init then |
|||
self.__init(obj,...) |
|||
end |
|||
return obj |
|||
end |
|||
new_class.extend = function(self,name) |
|||
local new_class = {} |
|||
new_class.__classname = name or "Object" |
|||
new_class.__index = new_class |
|||
setmetatable(new_class,{__index = self,__call = function(...) return new_class.__new(...) end, __name = new_class.__classname.." (class)"}) |
|||
return new_class |
|||
end |
|||
--make our class callable; on call, it will initialize a new instance of itself |
|||
setmetatable(new_class,{__call = function(...) return new_class.__new(...) end, __name = new_class.__classname.." (class)"}) |
|||
return new_class |
|||
end |
|||
--make our class callable; on call, it will initialize a new instance of itself |
|||
setmetatable(new_class,{__call = function(...) return new_class.__new(...) end, __name = new_class.__classname.." (class)"}) |
|||
return new_class |
|||
end |
@ -1,12 +0,0 @@ |
|||
local interface = {} |
|||
interface.wrapper = function(client,guild_id) |
|||
local new_i = {} |
|||
new_i.message = {} |
|||
new_i.message.get = function(channel,id) |
|||
local new_m = {} |
|||
local message = client.getMessage(id) |
|||
local new_m.content = message.content |
|||
local new_m.created_at = message.createdAt |
|||
local new_m.attachments = {} |
|||
for k,v in pairs(message.attachments) do |
|||
table.insert(new_m |
@ -1,90 +0,0 @@ |
|||
local RPC_server = import("classes.RPC-server") |
|||
local class = import("classes.baseclass") |
|||
local monitor = class("Monitor") |
|||
|
|||
--we only generate proxies as far as 1 object deep. |
|||
--to provide seamlessness, metamethods that request object proxies from their |
|||
--pointers may be used on the client side |
|||
|
|||
--pointers here mean tables that contain the __id and __type properties. |
|||
--they do not hold any info on the object besides its class name and id |
|||
|
|||
--a lookup table of all classes that we do not ignore. we exclude client and containers |
|||
--because they might break the sandboxing. we *do not* want that. |
|||
local allowed_types = { |
|||
["guild"] = true, |
|||
["member"] = true, |
|||
["emoji"] = true, |
|||
["message"] = true, |
|||
["channel"] = true, |
|||
["role"] = true, |
|||
["user"] = true, |
|||
["invite"] = true, |
|||
["guildtextchannel"] = true, |
|||
["textchannel"] = true, |
|||
["iterable"] = true, |
|||
["cache"] = true, |
|||
["arrayiterable"] = true, |
|||
["filteretediterable"] = true, |
|||
["secondarycache"] = true, |
|||
["weakcache"] = true, |
|||
["tableiterable"] = true, |
|||
} |
|||
|
|||
--a lookup table of classes that can be explicitly converted to arrays. |
|||
local iterable_types = { |
|||
["iterable"] = true, |
|||
["cache"] = true, |
|||
["arrayiterable"] = true, |
|||
["filteretediterable"] = true, |
|||
["secondarycache"] = true, |
|||
["weakcache"] = true, |
|||
["tableiterable"] = true, |
|||
} |
|||
|
|||
local comprehend_object = function(object) |
|||
local output |
|||
if (type(object) == "table") and (object.__class) then |
|||
--our object is an instance of a class |
|||
local class = object.__class.__name:lower() |
|||
if allowed_types[class] and (not iterable_types[class]) then |
|||
--our object can only be pointed to |
|||
output = {__id = object[k].id, __type = class} |
|||
else |
|||
--our object can be converted to an array |
|||
|
|||
end |
|||
else |
|||
--our object is either an atomic data type, a string or a table. |
|||
|
|||
end |
|||
end |
|||
|
|||
local create_proxy = function(object) |
|||
local output = {} |
|||
for k,v in pairs(getmetatable(object).__getters) do |
|||
end |
|||
end |
|||
|
|||
local proto_api = { |
|||
msg = { |
|||
get = function(channel,id) |
|||
channel:getMessage(id) |
|||
end, |
|||
}, |
|||
guild = { |
|||
|
|||
}, |
|||
member = { |
|||
|
|||
}, |
|||
channel = { |
|||
|
|||
} |
|||
} |
|||
|
|||
function monitor:__init(guild,options) |
|||
assert(guild,"No guild provided") |
|||
assert(options,"No options provided (arg 2)") |
|||
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue