Lua SDK migration for openilink-sdk-go.
Current Lua parity covers the main Go SDK workflow:
- QR login flow (
fetchQRCode,pollQRStatus,loginWithQR) - QR redirect handling (
scaned_but_redirect) and fixedloginBaseURL - Long polling (
getUpdates,monitor) with retry/backoff - Message send path (
sendMessage,sendText,push) - Config and typing (
getConfig,sendTyping) - MIME helper and text extraction helper
- Media send helpers (
sendImage,sendVideo,sendFileAttachment,sendMediaFile) - CDN upload/download helpers (
uploadFile,downloadMedia,downloadMediaRaw,downloadFile,downloadRaw) - AES-128-ECB + PKCS#7 helpers
- Voice download + WAV wrapping (
downloadVoice,BuildWAV) - Constant parity additions (
Media*,EncryptAES128ECB,VoiceFormat*) - Attachment filename mode: default keeps legacy
file_name; opt-in basename viauseBasenameForAttachmentName = true
lua/openilink/*.lua: SDK sourceexamples/echo_bot.lua: echo bot exampletests/*.lua: mock-based regression scripts
package.path = "./lua/?.lua;./lua/?/init.lua;" .. package.path
local ilink = require("openilink")
local client = ilink.newClient("")
local result, err = client:loginWithQR({
onQRCode = function(img) print(img) end,
})
assert(result and result.connected, err or result.message)local ilink = require("openilink")
local client = ilink.newClient("token", {
silkDecoder = function(data, sampleRate)
-- return PCM bytes for the decrypted voice payload
end,
})
local uploaded = assert(client:uploadFile("hello", "user-id", ilink.MediaFile))
assert(uploaded.download_encrypted_query_param ~= "")Default transport uses curl command line (openilink.http.CurlAdapter).
Requirements:
curlexecutable inPATHmd5sumexecutable inPATHforuploadFile
Voice decoding also requires a caller-provided silkDecoder callback. The SDK
downloads and decrypts the voice payload, then passes the raw bytes to that
callback and wraps the returned PCM bytes as WAV.
You can inject your own adapter with the same interface:
local client = ilink.newClient("token", {
useBasenameForAttachmentName = true, -- optional: align with Go basename behavior
httpAdapter = {
request = function(_, opts)
-- return { status = 200, body = "{}", headers = {} }, nil
end,
},
})lua tests/run.luaIf Lua runtime is unavailable in your environment, install Lua first and then run the same command.
See MIGRATION_STATUS.md for module-by-module parity with the Go SDK.