2020-08-23 17:14:54 +00:00
|
|
|
#pragma once
|
2020-08-18 20:42:30 +00:00
|
|
|
|
|
|
|
#include "CNShardServer.hpp"
|
|
|
|
|
2020-10-02 23:50:47 +00:00
|
|
|
#define CMD_PREFIX '/'
|
|
|
|
|
2020-10-03 00:20:59 +00:00
|
|
|
typedef void (*CommandHandler)(std::string fullString, std::vector<std::string>& args, CNSocket* sock);
|
2020-10-02 23:50:47 +00:00
|
|
|
|
|
|
|
struct ChatCommand {
|
|
|
|
int requiredAccLevel;
|
2020-10-12 07:08:10 +00:00
|
|
|
std::string help;
|
2020-10-02 23:50:47 +00:00
|
|
|
CommandHandler handlr;
|
|
|
|
|
|
|
|
ChatCommand(int r, CommandHandler h): requiredAccLevel(r), handlr(h) {}
|
2020-10-12 07:08:10 +00:00
|
|
|
ChatCommand(int r, CommandHandler h, std::string str): requiredAccLevel(r), help(str), handlr(h) {}
|
2020-10-02 23:50:47 +00:00
|
|
|
ChatCommand(): ChatCommand(0, nullptr) {}
|
|
|
|
};
|
|
|
|
|
2020-08-18 20:42:30 +00:00
|
|
|
namespace ChatManager {
|
2020-10-02 23:50:47 +00:00
|
|
|
extern std::map<std::string, ChatCommand> commands;
|
2020-08-18 20:42:30 +00:00
|
|
|
void init();
|
|
|
|
|
2020-10-12 07:08:10 +00:00
|
|
|
void registerCommand(std::string cmd, int requiredLevel, CommandHandler handlr, std::string help = "");
|
2020-10-02 23:50:47 +00:00
|
|
|
|
2020-08-18 20:42:30 +00:00
|
|
|
void chatHandler(CNSocket* sock, CNPacketData* data);
|
|
|
|
void emoteHandler(CNSocket* sock, CNPacketData* data);
|
2020-08-22 18:11:47 +00:00
|
|
|
void menuChatHandler(CNSocket* sock, CNPacketData* data);
|
2020-10-02 23:50:47 +00:00
|
|
|
void sendServerMessage(CNSocket* sock, std::string msg); // uses MOTD
|
2020-08-18 20:42:30 +00:00
|
|
|
}
|