blob: b8587594a5c231fa69b8982b8e3deb3b15c46575 (
plain)
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
|
#pragma once
#include <memory>
#include <sol/sol.hpp>
#include <sol/state.hpp>
#include <sol/table.hpp>
#include <sol/types.hpp>
#include <string>
#include <vector>
#include "commands/command.hpp"
#include "commands/response.hpp"
#include "schemas/user.hpp"
void print_lua_object_type(const sol::object &obj);
namespace bot::command::lua {
namespace library {
void add_bot_library(std::shared_ptr<sol::state> state);
void add_time_library(std::shared_ptr<sol::state> state);
}
class LuaCommand : public Command {
public:
LuaCommand(std::shared_ptr<sol::state> luaState,
const std::string &content);
~LuaCommand() = default;
Response run(const InstanceBundle &bundle,
const Request &request) const override;
std::string get_name() const override { return this->name; }
int get_delay_seconds() const override { return this->delay; }
schemas::PermissionLevel get_permission_level() const override {
return this->level;
}
std::vector<std::string> get_subcommand_ids() const override {
return this->subcommands;
}
private:
std::string name;
int delay;
schemas::PermissionLevel level;
std::vector<std::string> subcommands;
sol::function handle;
std::shared_ptr<sol::state> luaState;
};
}
|