mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-04 22:40:05 +00:00
dongresource
a1145aced4
* Only plain, printable ASCII is allowed for now. * Local chat is now printed to the server console, but group chat is still private * Added a helper function to print character names and IDs
32 lines
1011 B
C++
32 lines
1011 B
C++
#pragma once
|
|
|
|
#include "CNShardServer.hpp"
|
|
|
|
#define CMD_PREFIX '/'
|
|
|
|
typedef void (*CommandHandler)(std::string fullString, std::vector<std::string>& args, CNSocket* sock);
|
|
|
|
struct ChatCommand {
|
|
int requiredAccLevel;
|
|
std::string help;
|
|
CommandHandler handlr;
|
|
|
|
ChatCommand(int r, CommandHandler h): requiredAccLevel(r), handlr(h) {}
|
|
ChatCommand(int r, CommandHandler h, std::string str): requiredAccLevel(r), help(str), handlr(h) {}
|
|
ChatCommand(): ChatCommand(0, nullptr) {}
|
|
};
|
|
|
|
namespace ChatManager {
|
|
extern std::map<std::string, ChatCommand> commands;
|
|
void init();
|
|
|
|
void registerCommand(std::string cmd, int requiredLevel, CommandHandler handlr, std::string help = "");
|
|
|
|
void chatHandler(CNSocket* sock, CNPacketData* data);
|
|
void emoteHandler(CNSocket* sock, CNPacketData* data);
|
|
void menuChatHandler(CNSocket* sock, CNPacketData* data);
|
|
void sendServerMessage(CNSocket* sock, std::string msg); // uses MOTD
|
|
|
|
std::string sanitizeText(std::string text);
|
|
}
|