forked from Workbench-Team/natsuki-ggproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnatsuki.lua
executable file
·77 lines (67 loc) · 2.39 KB
/
natsuki.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
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
_G.core = require("core")
_G.disc = require('discordia')
_G.cl = _G.disc.Client()
_G.http = require('coro-http')
_G.qs = require('querystring')
_G.json = require('json')
_G.timer = require('timer')
_G.server = '606961070212644894'
_G.mysql = require('./third_party/luajit_mysql.lua')
require('./third_party/embed.lua')
_G.uv = require('uv')
disc.extensions()
_G.pref = 'n/'
file_config = io.open("config.json", "r")
_G.config = json.decode(file_config:read("*a"))
file_config:close()
token = config["token"]
cl:run('Bot '..token)
_G.backend_token = config["backend_token"]
_G.backend_url = config["backend_url"]
_G.data = {["token"] = backend_token}
_G.data_backup = {["token"] = backend_token}
require('groups')
require('modules')
for i = 1,#config.modules do
local func, err = loadfile(string.format("modules/%s.lua", config.modules[i]))
if func == nil then print(string.format("Module %s load failed with error %s", config.modules[i], err)) end
local result, err = pcall(func)
if result == false then print(string.format("Module %s load failed with error %s", config.modules[i], err)) end
end
cl:on('ready', function()
cl:setGame {
type = 3,
name = pref..'help'
}
cl:setStatus('online')
end)
cl:on('messageCreate', function(msg)
local logs = cl:getChannel('661166664104148993')
if msg.channel.type == 1 or msg.channel.type == 3 then
local cont = msg.content
cont = string.gsub(cont, '@', '')
logs:send{content='*'..msg.channel.name..'*\n**'..msg.author.tag..'** сказал:\n> '..cont..'\nID автора: '..msg.author.id..'\nID сообщения: '..msg.id, embed=msg.embed}
if msg.attachment then
for i,v in ipairs(msg.attachments) do
logs:send{content=v.url}
end
end
end
if msg.channel.id == logs.id then
if msg.author.id == cl.user.id then return end
local tbl = msg.content:split(' ')
if not tbl[1] then return end
local channel = cl:getUser(tbl[1])
if not channel then return end
table.remove(tbl, 1)
channel:send(table.concat(tbl, ' '))
end
end)
cl:on('messageUpdate', function(msg)
local logs = cl:getChannel('661166664104148993')
if msg.channel.type == 1 or msg.channel.type == 3 then
local cont = msg.content
string.gsub(cont, '@', '`@`')
logs:send{content='*'..msg.channel.name..'*\n**'..msg.author.tag..'** изменил сообщение:\n> '..cont..'\nID автора: '..msg.author.id..'\nID сообщения: '..msg.id, embed=msg.embed}
end
end)