Added websocket login server and botserver

This commit is contained in:
OTCv8
2019-11-28 12:14:43 +01:00
parent ddb155333d
commit cf8b21263d
12 changed files with 371 additions and 263 deletions

View File

@@ -3,13 +3,10 @@ local context = G.botContext
-- MAIN BOT FUNCTION
-- macro(timeout, callback)
-- macro(timeout, name, callback)
-- macro(timeout, name, callback, parent)
-- macro(timeout, name, hotkey, callback)
-- macro(timeout, name, hotkey, callback, parent)
context.macro = function(timeout, name, hotkey, callback, parent)
if not parent then
parent = context.panel
end
if type(timeout) ~= 'number' or timeout < 1 then
error("Invalid timeout for macro: " .. tostring(timeout))
end
@@ -18,8 +15,9 @@ context.macro = function(timeout, name, hotkey, callback, parent)
name = ""
hotkey = ""
elseif type(hotkey) == 'function' then
parent = callback
callback = hotkey
hotkey = ""
hotkey = ""
elseif type(callback) ~= 'function' then
error("Invalid callback for macro: " .. tostring(callback))
end
@@ -29,6 +27,9 @@ context.macro = function(timeout, name, hotkey, callback, parent)
if type(name) ~= 'string' or type(hotkey) ~= 'string' then
error("Invalid name or hotkey for macro")
end
if not parent then
parent = context.panel
end
if hotkey:len() > 0 then
hotkey = retranslateKeyComboDesc(hotkey)
end
@@ -63,16 +64,18 @@ context.macro = function(timeout, name, hotkey, callback, parent)
end
-- hotkey(keys, callback)
-- hotkey(keys, callback, parent)
-- hotkey(keys, name, callback)
-- hotkey(keys, name, callback, parent)
context.hotkey = function(keys, name, callback, single, parent)
if not parent then
parent = context.panel
end
context.hotkey = function(keys, name, callback, parent, single)
if type(name) == 'function' then
parent = callback
callback = name
name = ""
end
if not parent then
parent = context.panel
end
keys = retranslateKeyComboDesc(keys)
if not keys or #keys == 0 then
return context.error("Invalid hotkey keys " .. tostring(name))
@@ -107,14 +110,16 @@ context.hotkey = function(keys, name, callback, single, parent)
end
-- singlehotkey(keys, callback)
-- singlehotkey(keys, callback, parent)
-- singlehotkey(keys, name, callback)
-- singlehotkey(keys, name, callback, parent)
context.singlehotkey = function(keys, name, callback, parent)
if type(name) == 'function' then
parent = callback
callback = name
name = ""
end
return context.hotkey(keys, name, callback, true, parent)
return context.hotkey(keys, name, callback, parent, true)
end
-- schedule(timeout, callback)