-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.lua
More file actions
88 lines (82 loc) · 3.18 KB
/
Copy pathmain.lua
File metadata and controls
88 lines (82 loc) · 3.18 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require("data.init")
Event.subscribe("GroupMessageEvent", function(event)
local type = EventType.GroupMessage
local uid = tostring(event.group):match([[%d+]])
if Config[uid] ~= nil then
local cfg = Config[uid]
Self = cfg.Self
print("change group cache to:" .. uid ..", info:")
for _, value in pairs(Self) do
print("|"..value)
end
local data = cfg.DataBase
local serv = cfg.Service
local sets = cfg.Setting
local lgcs = cfg.Logic
local ctls = cfg.Control
local tsks = cfg.TaskQueue
for name, idxs in pairs(serv) do
print("change service cache to:"..name)
local page = data[idxs.DataPage]
local set = sets[idxs.Setting]
local ctrl = ctls[idxs.Control]
local logic = lgcs[idxs.Logic]
local tasks = tsks[idxs.TaskQueue]
-- ring check needed here
for index, cond in ipairs(ctrl.Condition) do
if cond(type, event, set, page, ctrl, logic, tasks) then
print("admin command trigged in service:" .. name ..
" index:" .. index)
ctrl.Reaction[index](type, event, set, page, ctrl, logic, tasks)
return nil
end
end
if set.Running then
print("filiting ...")
local flag = false
if logic[type].Filiter(event, page, tasks) then
print("command trigged in service:" .. name)
flag = true
logic[type].Actor(event, page, tasks)
logic[type].After(event, page, tasks)
local log = logic[type].Log(event, page, tasks) or ""
print("[log] service:" .. name .. "|" .. log)
if not ctrl.Record then
if ctrl.Terminal then
print("terminal trig, skip following services")
end
end
end
if not flag then print("not trig any service") end
else
print("skip stopped service: " .. name)
end
end
else
print("Unregisted group")
end
if tostring(event.sender):find("2821006329") then
if tostring(event.message):find("./do ") then
local cmd = tostring(event.message):gsub("./do ", ""):gsub("\n", "")
cmd = cmd:gsub("\\", "")
print("super user do:"..cmd)
local sender = function (...)
event.group:sendMessage(...)
end
load(cmd, "_", "t", {
math = _ENV.math,
string = _ENV.string,
pairs = _ENV.pairs,
ipairs = _ENV.ipairs,
type = _ENV.type,
tostring = _ENV.tostring,
tonumber = _ENV.tonumber,
coroutine = _ENV.coroutine,
table = _ENV.table,
Config = _ENV.Config,
print = sender,
})()
end
end
end)
-- local sets = require(Self.File..Self.FileOffset)