summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/pylon.lua59
-rw-r--r--discord/the.lua10
-rw-r--r--irc/pylon.lua2
-rw-r--r--wilson.ini5
4 files changed, 56 insertions, 20 deletions
diff --git a/discord/pylon.lua b/discord/pylon.lua
index 705f31d..1ecc042 100644
--- a/discord/pylon.lua
+++ b/discord/pylon.lua
@@ -1,13 +1,24 @@
local consts = require'discord.consts'
local websocket = require'http.websocket'
local json = require 'dkjson'
+local Queue = require 'util.queue'
+local exec_webhook = require'discord.the'
+local cqueues = require 'cqueues'
local Discord = {}
-function Discord.make(wilson,conf)
+function Discord.make(wilson, conf)
+ local self = setmetatable(conf, {__index=Discord})
-end
+ for k,v in pairs {
+ wilson = wilson,
+ inbox = Queue.make(),
+ } do self[k] = v end
+
+ assert(self.token)
+ return self
+end
local function identify_payload(token)
local I = consts.intents
@@ -15,9 +26,7 @@ local function identify_payload(token)
op = consts.opcodes.identify,
d = {
properties = {
- os = "wilson",
- browser = "wilson",
- device = "wilson",
+ os = "wilson", browser = "wilson", device = "wilson",
},
intents = I.guilds + I.guild_messages + I.message_content,
token = token,
@@ -25,16 +34,38 @@ local function identify_payload(token)
}
end
-local token = 'NzY1NTMyNjgzMTQ4MzI4OTcw.GJCRVk.uvplnizyiRKxONvmKD4b8lq7Ju0QSqoPAmqj1w'
-
-local function connect()
+function Discord._connect(self)
local uri = "wss://gateway.discord.gg/?v=10&encoding=json"
- local ws = websocket.new_from_uri(uri)
- print(ws:connect())
- ws:send(identify_payload(token), 'text')
- for a,b in ws:each() do
- print('its',a,b)
+ self.ws = websocket.new_from_uri(uri)
+ assert(self.ws:connect())
+ self.ws:send(identify_payload(self.token), 'text')
+ -- for a,b in self.ws:each() do
+ -- print('its',a,b)
+ -- end
+end
+
+function Discord.run(self)
+ local cq = cqueues.new()
+ self:_connect()
+ cq:wrap(self.recving, self)
+ cq:wrap(self.sending, self)
+ print('discord', cq:loop())
+end
+
+function Discord.recving(self)
+ for event in self.ws:each() do
+ print(event)
+ end
+end
+
+function Discord.sending(self)
+ local i = 1
+ while true do
+ exec_webhook(self.temp_wh, { username = "god", content = "h"..("i"):rep(i) })
+ i = i + 1
+ cqueues.sleep(1)
end
end
--- connect()
+return Discord
+
diff --git a/discord/the.lua b/discord/the.lua
index 27e0644..d3aaf58 100644
--- a/discord/the.lua
+++ b/discord/the.lua
@@ -1,6 +1,5 @@
local http_request = require'http.request'
local dkjson = require'dkjson'
-local url = 'https://discord.com/api/v8/webhooks/1277689699254800436/gzYU3voeunQsEdC797-hgXdTIbJDk09IVuj6l1t2alqbX9xS0d_St7bDWRkagUuQ3sat'
local function exec_webhook(url, payload, debug)
local req = http_request.new_from_uri(url)
@@ -17,8 +16,9 @@ local function exec_webhook(url, payload, debug)
assert(status:sub(1,1) == '2', 'status was '..status..' not 2xx')
end
-return { grom = function(from,body) print(body) exec_webhook(url, {
- content=body,
- username=from,
- }, true) end }
+return exec_webhook
+-- return { grom = function(from,body) print(body) exec_webhook(url, {
+-- content=body,
+-- username=from,
+-- }, true) end }
diff --git a/irc/pylon.lua b/irc/pylon.lua
index 4259f5e..0c898dd 100644
--- a/irc/pylon.lua
+++ b/irc/pylon.lua
@@ -41,7 +41,7 @@ function Irc.run(self)
self:_connect()
cq:wrap(self.recving, self)
cq:wrap(self.sending, self)
- print('irc',cq:loop())
+ print('irc', cq:loop())
end
function Irc.recving(self)
diff --git a/wilson.ini b/wilson.ini
index 8aa1900..e3dba05 100644
--- a/wilson.ini
+++ b/wilson.ini
@@ -11,6 +11,11 @@ server=localhost
component=wilson.ubq323.website
component_secret=super_secret_wilson_password
+[pylon discord]
+type=discord
+token=NzY1NTMyNjgzMTQ4MzI4OTcw.GJCRVk.uvplnizyiRKxONvmKD4b8lq7Ju0QSqoPAmqj1w
+temp_wh=https://discord.com/api/v8/webhooks/1277689699254800436/gzYU3voeunQsEdC797-hgXdTIbJDk09IVuj6l1t2alqbX9xS0d_St7bDWRkagUuQ3sat
+
[bus test]
ubq-xmpp d@conference.ubq323.website
local-irc #test