跳到主要内容

· 阅读需 1 分钟
Lessica
pop3-example.lua
local pop3 = require "pop3"

local some_mail = {
host = os.getenv("LUA_MAIL_HOST") or '127.0.0.1';
username = os.getenv("LUA_MAIL_USER") or 'me@host.local';
password = os.getenv("LUA_MAIL_PASS") or 'mypassword';
}

local function print_msg(msg, indent)
indent = indent or ''
print(indent .. "----------------------------------------------")
print(indent .. "ID: ", msg:id())
print(indent .. "subject: ", msg:subject())
print(indent .. "to: ", msg:to())
print(indent .. "from: ", msg:from())
print(indent .. "from addr: ", msg:from_address())
print(indent .. "reply: ", msg:reply_to())
print(indent .. "reply addr: ", msg:reply_address())
print(indent .. "trunc: ", msg:is_truncated())
for i,v in ipairs(msg:full_content()) do
if v.text then print(indent .. " ", i , "TEXT : ", v.type, #v.text)
elseif v.data then print(indent .. " ", i , "FILE : ", v.type, v.disposition, v.file_name or v.name, #v.data)
elseif v.message then print(indent .. " ", i , "RFC822: ", v.type, v.disposition, v.file_name or v.name)
print_msg(v.message, indent .. '\t\t\t')
end
end
end

local mbox = pop3.new()

mbox:open(some_mail.host, some_mail.port or '110')
print('open :', mbox:is_open())

mbox:auth(some_mail.username, some_mail.password)
print('auth :', mbox:is_auth())

for k, msg in mbox:messages() do
print(string.format(" *** MESSAGE NO %d ***", k))
print_msg(msg)
end

· 阅读需 1 分钟
Lessica
#define WEBSERV_PORT 46952
#define WEBSERV_PORT_V1 46059 /* TouchSprite / XXTouch Legacy IDE */
#define WEBSERV_BROADCAST_PORT 46953
#define WEBSERV_BROADCAST_PORT_V1 14099 /* TouchSprite & TouchElf */

#define WEBSERV_LOGGING_UDP_RECV_PORT 46956
#define WEBSERV_LOGGING_SERVER_PORT 46957
  • WEBSERV_PORT: XXTouchNG OpenAPI 协议端口、IDE 服务端口
  • WEBSERV_PORT_V1: 触动精灵、XXTouch 旧版 IDE 服务端口
  • WEBSERV_BROADCAST_PORT: XXTouchNG 广播端口
  • WEBSERV_BROADCAST_PORT_V1: 触动精灵、触摸精灵广播端口
  • WEBSERV_LOGGING_UDP_RECV_PORT: 本地日志接收端口
  • WEBSERV_LOGGING_SERVER_PORT: 外部日志传输端口

· 阅读需 1 分钟
Lessica

适用于 XXTouchNG 和 VSCode 集成开发环境的多功能开发辅助插件,具备如下功能:

  • 浏览设备的文件系统
  • 上传、下载、删除设备上的文件
  • 查看设备的运行状态及信息摘要
  • 基于 WebSocket 的实时网络日志服务
  • 广播扫描局域网内的 XXTouchNG 设备
  • 远程截图、取色并通过模版生成代码片段
  • Lua 语法检查、提示、自动补全
  • 远程运行、调试、停止脚本
下载地址

· 阅读需 4 分钟
Lessica
webview-alert.lua
local function html_escape(value)
value = tostring(value)
local charmap = {
['&'] = '&',
['<'] = '&lt;',
['>'] = '&gt;',
['"'] = '&quot;',
["'"] = '&apos;',
['\n'] = '&#10;',
[' '] = '&nbsp;',
}
value = string.gsub(value, '[ &<>"\'\n]', function(c)
return charmap[c]
end)
return value
end

function alert(message,timeout,title,cancelbutton,button)
local w, h = screen.size()
local buttons = {}
local button_index = 0
if button then
for k, v in ipairs(button or {}) do
button_index = button_index + 1
table.insert(buttons,
string.format('<button type="button" class="mui-btn mui-btn-primary mui-btn-outlined" onclick="CallButton(%s)">%s</button>',button_index,html_escape(v))
)
end
else
button_index = button_index + 1
table.insert(buttons,'<button type="button" class="mui-btn mui-btn-primary mui-btn-outlined" onclick="CallButton(1)">确定</button>')
end
if cancelbutton then
button_index = button_index + 1
table.insert(buttons,'<button type="button" class="mui-btn mui-btn-danger mui-btn-outlined" onclick="CallButton(0)">'..html_escape(cancelbutton)..'</button>')
end
message = html_escape(message)
local but_width, webview_height, webview_bottom
if button_index > 2 then
but_width = "90"
webview_height = 460 + (80 * (button_index - 1))
webview_bottom = 60 + (40 * (button_index - 1))
elseif button_index == 2 then
but_width = "45"
webview_height = 480
webview_bottom = 60
elseif button_index == 1 then
but_width = "90"
webview_height = 480
webview_bottom = 60
end
if #(message:split('<br>')) > 6 then
webview_height = webview_height + ((#(message:split('<br>')) - 6) * 45)
end
if webview_height > h - 100 then webview_height = h - 100 end
local html = [=[<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=]=]..(w/15)..[=[, height=]=]..(h/15)..[=[, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="/mui/css/mui.min.css">
<script src="/mui/js/mui.min.js"></script>
<style>
.mui-control-content{
margin: 10px;
}
.buttons{
padding-top: 3px;
padding-bottom: 13px;
}
.mui-btn{
width: ]=]..but_width..[=[%;
height: 35px;
margin: 3px;
}
.mui-content{
height: 100px;
}
.mui-bar-nav{
box-shadow: 0 1px 6px #FFFFFF;
}
.mui-active{
padding-bottom: ]=]..webview_bottom..[=[px;
}

</style>
<script>
function CallButton(b) {
var RetMessage = JSON.stringify(
{
key:"alert-webview",
value:JSON.stringify(
{
Submit:true,
Data:b
}
)
}
);
console.log(RetMessage);
mui.ajax('/proc_queue_push',{
data:RetMessage,
dataType:'json',
type:'post',
timeout:10000,
success:function(request){
console.log(request.code);
},
error:function(xhr,type,errorThrown){
console.log(type);
}
});
};
var _TimeOut = ]=] .. tonumber(timeout or '0') .. [=[;
function TimeOut(){
_TimeOut = _TimeOut - 1;
if(_TimeOut==0){
CallButton(-1);
}
};
setInterval(TimeOut,1000);
</script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<h1 class="mui-title">]=]..(html_escape(title) or 'XXTouch')..[=[</h1>
</header>
<nav class="mui-bar mui-bar-tab">
<center class="buttons">
]=]..table.concat(buttons,'\r\n')..[=[
</center>
</nav>
<div class="mui-content">
<div id="tabbar" class="mui-control-content mui-active">
<center><p>]=]..message..[=[</p></center>
</div>
</div>
</body>
</html>]=]
local ret = ''
webview.show {
id = 2,
x = 0,
y = 0,
width = w,
height = h,
alpha = 0,
animation_duration = 0,
level = 1995.1
}
local hhh = (h - webview_height) / 2
webview.show {
id = 1,
html = html,
x = (w - 600) / 2,
y = -hhh,
width = 600,
height = webview_height,
alpha = 0,
animation_duration = 0,
level = 1995.2
}
webview.show {
id = 2,
x = 0,
y = 0,
width = w,
height = h,
alpha = 0.4,
animation_duration = 0.2,
level = 1995.1,
html = [[<html><body style="background:#000000"></body></html>]]
}
webview.show {
id = 1,
html = html,
x = (w - 600) / 2,
y = hhh,
width = 600,
height = webview_height,
corner_radius = 2,
alpha = 1,
animation_duration = 0.2,
rotate = rotate_ang,
level = 1995.2
}
sys.msleep(200)
proc_queue_clear("alert-webview")
while(ret=='')do
ret = proc_queue_pop("alert-webview")
sys.msleep(1)
end
webview.show {
id = 1,
x = (w - 600) / 2,
y = h,
width = 600,
height = webview_height,
alpha = 0,
animation_duration = 0.2,
}
webview.show {
id = 2,
x = 0,
y = 0,
width = w,
height = h,
alpha = 0,
animation_duration = 0.2
}
sys.msleep(200)
webview.destroy(1)
webview.destroy(2)
return json.decode(ret).Data
end

---[[
while true do
nLog('alert("aasdas",0,"啦啦啦","关闭",{"按钮1"})')
nLog(alert("aasdas",0,"啦啦啦","关闭",{"按钮1","按钮2","按钮3","按钮4","按钮5"}))
nLog('alert("aas\r\n\r\n\r\n",0,"啦啦啦","关闭",{"按钮1"})')
nLog(alert("aas\r\n\r\n\r\nasd",0,"啦啦啦","关闭",{"按钮1"}))
nLog('alert("aas\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nxxx",0,"啦啦啦","关闭",{"按钮1"})')
nLog(alert("aas\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nxxx",0,"啦啦啦","关闭",{"按钮1"}))
end
--]]