forked from opq-osc/LuaPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
localPicture.lua
45 lines (44 loc) · 1018 Bytes
/
localPicture.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local log = require("log")
local Api = require("coreApi")
local json = require("json")
local http = require("http")
function ReceiveFriendMsg(CurrentQQ, data)
return 1
end
function ReceiveGroupMsg(CurrentQQ, data)
if string.find(data.Content, "bz") == 1 then
math.randomseed(tonumber(tostring(os.time()):reverse():sub(1, 6)))
local randomNum = math.random(1,40)
-- 图片路径
local path = "/root/img/mmbz/"..randomNum..".png"
res = readImg(path)
base64 = PkgCodec.EncodeBase64(res)
Api.Api_SendMsg(
CurrentQQ,
{
toUser = data.FromGroupId,
sendToType = 2,
sendMsgType = "PicMsg",
groupid = 0,
content = "",
picUrl = "",
picBase64Buf = base64,
fileMd5 = "",
atUser = 0
}
)
end
return 1
end
function ReceiveEvents(CurrentQQ, data, extData)
return 1
end
function readImg(filePath)
local f, err = io.open(filePath, "rb")
if err ~= nil then
return nil, err
end
local content = f:read("*all")
f:close()
return content, err
end