Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better api #60

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Plugins/lib/_opq_api.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
local M = {}

function M.friend_text(qq, data) end

return M
Empty file added Plugins/lib/_opq_empty.lua
Empty file.
21 changes: 21 additions & 0 deletions Plugins/lib/_opq_util.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local M

---Tests if `s` starts with `prefix`.
---
---@param s string: a string
---@param prefix string: a prefix
---@return boolean: true if `prefix` is a prefix of s
function M.startswith(s, prefix)
return s:sub(1, #prefix) == prefix
end

--- Tests if `s` ends with `suffix`.
---
---@param s string: a string
---@param suffix string: a suffix
---@return boolean: true if `suffix` is a suffix of s
function M.endswith(s, suffix)
return #suffix == 0 or s:sub(-#suffix) == suffix
end

return M
1 change: 1 addition & 0 deletions Plugins/lib/opq.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local opq = {}
34 changes: 34 additions & 0 deletions WebPlugins/Api_LuaCaller.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---@diagnostic disable: unused-local
--[[v6.9.6]]
local API_MODNAME = "_opq_api"
local log = require("log")
local api = require("coreApi")
local ok = pcall(require, "_opq_empty")

local builtin = {
MagicCgiCmd = function(qq, funcname, data)
return api.Api_MagicCgiCmd(qq, data)
end,
--添加定时任务
AddCrons = function(qq, funcname, data)
return api.Api_AddCrons(data)
end,
--添加删除定时任务
DelCrons = function(qq, funcname, data)
return api.Api_DelCrons(data.TaskID)
end,
--获取任务列表
GetCrons = function()
return api.Api_GetCrons()
end,
}

-- CurrentQQ 当前操作的QQ号 /funcName 欲调用LuaApi函数名 /data 组装Json数据
function Api_LuaCaller(CurrentQQ, funcName, data)
log.info("%s", string.format("Api_LuaCaller FuncName %s\n", funcName))
return (builtin[funcName] or (ok and require("_opq_api") or {})[funcName] or api.Api_CallFunc)(
CurrentQQ,
funcName,
data
)
end