diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..55d1f45 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "multi"] + path = multi + url = https://github.com/rayaman/multi.git +[submodule "bin"] + path = bin + url = https://github.com/rayaman/bin.git diff --git a/bin b/bin new file mode 160000 index 0000000..4eb7d84 --- /dev/null +++ b/bin @@ -0,0 +1 @@ +Subproject commit 4eb7d84e5eb55158f361d2eb9c9a93d9f9960c0b diff --git a/core/channel.lua b/core/channel.lua new file mode 100644 index 0000000..a7b1d8a --- /dev/null +++ b/core/channel.lua @@ -0,0 +1,17 @@ +local cjson = require "cjson" +local channel = {} +channel.__index = channel +channel.TYPES = { + GUILD_TEXT = 0, + DM = 1, + GUILD_VOICE = 2, + GROUP_DM = 3, + GUILD_CATEGORY = 4, + GUILD_ANNOUNCEMENT = 5, + ANNOUNCEMENT_THREAD = 10, + PUBLIC_THREAD = 11, + PRIVATE_THREAD = 12, + GUILD_STAGE_VOICE = 13, + GUILD_DIRECTORY = 14, + GUILD_FORUM = 15 +} diff --git a/core/message.lua b/core/message.lua new file mode 100644 index 0000000..9f6ab54 --- /dev/null +++ b/core/message.lua @@ -0,0 +1,36 @@ +local cjson = require "cjson" +local message = {} +message.__index = message +message.TYPES = { + DEFAULT = {0, true} + RECIPIENT_ADD = {1, false}, + RECIPIENT_REMOVE = {2, false}, + CALL = {3, false}, + CHANNEL_NAME_CHANGE = {4, false}, + CHANNEL_ICON_CHANGE = {5, false}, + CHANNEL_PINNED_MESSAGE = {6, true}, + USER_JOIN = {7, true}, + GUILD_BOOST = {8, true}, + GUILD_BOOST_TIER_1 = {9, true}, + GUILD_BOOST_TIER_2 = {10, true}, + GUILD_BOOST_TIER_3 = {11, true}, + CHANNEL_FOLLOW_ADD = {12, true}, + GUILD_DISCOVERY_DISQUALIFIED = {14, false}, + GUILD_DISCOVERY_REQUALIFIED = {15, false}, + GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = {16, false}, + GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = {17, false}, + THREAD_CREATED = {18, true}, + REPLY = {19, true}, + CHAT_INPUT_COMMAND = {20, true}, + THREAD_STARTER_MESSAGE = {21, false}, + GUILD_INVITE_REMINDER = {22, true}, + CONTEXT_MENU_COMMAND = {3, true}, + AUTO_MODERATION_ACTION = {24, true}, + ROLE_SUBSCRIPTION_PURCHASE = {25, true}, + INTERACTION_PREMIUM_UPSELL = {26, true}, + STAGE_START = {27, true}, + STAGE_END = {28, true}, + STAGE_SPEAKER = {29, true}, + STAGE_TOPIC = {31, true}, + GUILD_APPLICATION_PREMIUM_SUBSCRIPTION = {32, false} +} \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/multi b/multi new file mode 160000 index 0000000..1639de5 --- /dev/null +++ b/multi @@ -0,0 +1 @@ +Subproject commit 1639de5d0f0863a26c576882c8d6b39c46b2f87a diff --git a/rockspecs/lucord-1.0-0.rockspec b/rockspecs/lucord-1.0-0.rockspec new file mode 100644 index 0000000..76a5cf7 --- /dev/null +++ b/rockspecs/lucord-1.0-0.rockspec @@ -0,0 +1,34 @@ +package = "lucord" +version = "1.0-0" +source = { + url = "git://github.com/rayaman/multi.git", + tag = "1.0.0", +} + +description = { + summary = "Lua Multi tasking library", + detailed = [[ + This library contains many methods for multi tasking. Features non coroutine based multi-tasking, coroutine based multi-tasking, and system threading (Requires use of an integration). + Check github for documentation. + ]], + homepage = "https://github.com/rayaman/lucord", + license = "MIT" +} + +dependencies = { + "lua >= 5.1", + "luasocket", + "luasec", + "multi", + "lanes", + "bin", + "lfs" +} + +build = { + type = "builtin", + modules = { + ["multi"] = "init.lua", + ["multi.integration.lanesManager"] = "integration/lanesManager/init.lua", + } +} \ No newline at end of file diff --git a/test.lua b/test.lua new file mode 100644 index 0000000..d67c905 --- /dev/null +++ b/test.lua @@ -0,0 +1,63 @@ +package.path = "?/init.lua;?.lua;"..package.path +local bin = require("bin") +local infinabits = bin.infinabits +local bits = bin.bits + +local chronos = require("chronos") +--infinabits:conv("1") +-- 0000111001000011010011001010001001001110000001000100000001000111 + +function snowflake_timestamp(snowflake) + local snowflake = tostring(infinabits.new(BigNum.new(snowflake))) + local Timestamp = infinabits.new(snowflake:sub(1,42),true) + local WID = bits.new(snowflake:sub(43,47),true) + local PID = bits.new(snowflake:sub(48,52),true) + local Increment = bits.new(snowflake:sub(53,64),true) + local stamp = (Timestamp:tonumber() + BigNum.new("1420070400000"))/1000 + + local date = os.date("*t", tonumber(tostring(stamp))) + + local temp = { + TIMESTAMP = tonumber(tostring(stamp)), + WID = tostring(WID:tonumber()), + PID = tostring(PID:tonumber()), + Increment = tostring(Increment:tonumber()) + } + + for i,v in pairs(date) do + temp[i] = v + end + + return temp +end +local start = chronos.nanotime() +local data = snowflake_timestamp("1027749399947919431") +local stop = chronos.nanotime() +print(("Data took %s seconds"):format(stop - start)) + +local cjson = require "cjson" + +value = cjson.decode([[ +{ + "id": "41771983423143937", + "guild_id": "41771983423143937", + "name": "general", + "type": 0, + "position": 6, + "permission_overwrites": [], + "rate_limit_per_user": 2, + "nsfw": true, + "topic": "24/7 chat about how to gank Mike #2", + "last_message_id": "155117677105512449", + "parent_id": "399942396007890945", + "default_auto_archive_duration": 60 +} +]]) + +for i,v in pairs(value) do + print(i,v) +end + +-- for i, v in pairs(data) do +-- print(i, v) +-- end