IRC_SERVER
By @hyunjunk (hyunjun2372@gmail.com)
Loading...
Searching...
No Matches
IrcReplies.hpp
Go to the documentation of this file.
1/** @file Source/Server/IrcReplies.hpp
2 * @see RFC 1459, Chapter 6. Replies.
3 * https://datatracker.ietf.org/doc/html/rfc1459
4 */
5
6#pragma once
7
8#include <string>
9
10namespace IRC
11{
12
13// ---------------------------------------------------------------------------------------------------------------------------------------------------
14/**
15 * @def IRC_REPLY_TUPLE_LIST
16 * @brief Tuple of the IRC replies | IRC_REPLY_X (reply_code, reply_number, (arguments), (reply_string))
17*/
18#define IRC_REPLY_TUPLE_LIST \
19 IRC_REPLY_X(RPL_WELCOME , 001, (PARM_X, const std::string nickname), (":Welcome to the " + serverName + " IRC Network " + nickname + "!")) \
20 IRC_REPLY_X(ERR_NOSUCHNICK , 401, (PARM_X, const std::string nickname), (nickname + " :No such nick/channel")) \
21 IRC_REPLY_X(ERR_NOSUCHSERVER , 402, (PARM_X, const std::string server_name), (server_name + " :No such server")) \
22 IRC_REPLY_X(ERR_NOSUCHCHANNEL , 403, (PARM_X, const std::string channel_name), (channel_name + " :No such channel")) \
23 IRC_REPLY_X(ERR_CANNOTSENDTOCHAN, 404, (PARM_X, const std::string channel_name), (channel_name + " :Cannot send to channel")) \
24 IRC_REPLY_X(ERR_TOOMANYCHANNELS , 405, (PARM_X, const std::string channel_name), (channel_name + " :You have joined too many channels")) \
25 IRC_REPLY_X(ERR_WASNOSUCHNICK , 406, (PARM_X, const std::string nickname), (nickname + " :There was no such nickname")) \
26 IRC_REPLY_X(ERR_TOOMANYTARGETS , 407, (PARM_X, const std::string target), (target + " :Duplicate recipients. No message delivered")) \
27 IRC_REPLY_X(ERR_UNKNOWNCOMMAND , 421, (PARM_X, const std::string command), (command + " :Unknown command")) \
28 IRC_REPLY_X(ERR_NONICKNAMEGIVEN , 431, (PARM_X), (":No nickname given")) \
29 IRC_REPLY_X(ERR_NICKNAMEINUSE , 433, (PARM_X, const std::string nickname), (nickname + " :Nickname is already in use")) \
30 IRC_REPLY_X(ERR_ERRONEUSNICKNAME, 432, (PARM_X, const std::string nickname), (nickname + " :Erroneous nickname")) \
31 IRC_REPLY_X(ERR_NOTREGISTED , 451, (PARM_X), (":You have not registered")) \
32 IRC_REPLY_X(ERR_NEEDMOREPARAMS , 461, (PARM_X, const std::string command), (command + " :Not enough parameters")) \
33 IRC_REPLY_X(ERR_ALREADYREGISTRED, 462, (PARM_X), (":You may not reregister")) \
34 IRC_REPLY_X(ERR_BANNEDFROMCHAN , 474, (PARM_X, const std::string channel_name), (channel_name + " :Cannot join channel (+b)")) \
35 IRC_REPLY_X(ERR_INVITEONLYCHAN , 473, (PARM_X, const std::string channel_name), (channel_name + " :Cannot join channel (+i)")) \
36 IRC_REPLY_X(ERR_BADCHANNELKEY , 475, (PARM_X, const std::string channel_name), (channel_name + " :Cannot join channel (+k)")) \
37 IRC_REPLY_X(ERR_CHANNELISFULL , 471, (PARM_X, const std::string channel_name), (channel_name + " :Cannot join channel (+l)")) \
38 IRC_REPLY_X(ERR_BADCHANMASK , 476, (PARM_X, const std::string channel_name), (channel_name + " :Bad Channel Mask")) \
39 IRC_REPLY_X(ERR_UNKNOWNMODE , 472, (PARM_X, const char mode), (std::string(1, mode) + " :is unknown mode char to me")) \
40 IRC_REPLY_X(ERR_CHANOPRIVSNEEDED, 482, (PARM_X, const std::string channel_name), (channel_name + " :You're not channel operator")) \
41 IRC_REPLY_X(ERR_NORECIPIENT , 411, (PARM_X, const std::string command), (":No recipient given (" + command + ")")) \
42 IRC_REPLY_X(ERR_NOTEXTTOSEND , 412, (PARM_X), (":No text to send")) \
43 IRC_REPLY_X(ERR_NOTONCHANNEL , 442, (PARM_X, const std::string channel_name), (channel_name + " :You're not on that channel")) \
44 IRC_REPLY_X(ERR_USERNOTINCHANNEL, 441, (PARM_X, const std::string nickname, const std::string channel_name), (nickname + " " + channel_name + " :They aren't on that channel")) \
45 IRC_REPLY_X(ERR_USERONCHANNEL , 443, (PARM_X, const std::string nickname, const std::string channel_name), (nickname + " " + channel_name + " :is already on channel")) \
46 IRC_REPLY_X(RPL_NOTOPIC , 331, (PARM_X, const std::string channel_name), (channel_name + " :No topic is set")) \
47 IRC_REPLY_X(RPL_TOPIC , 332, (PARM_X, const std::string channel_name, const std::string topic), (channel_name + " :" + topic)) \
48 IRC_REPLY_X(RPL_LISTSTART , 321, (PARM_X), (":Channel :Users Name")) \
49 IRC_REPLY_X(RPL_LIST , 322, (PARM_X, const std::string channel_name, const std::string visible_user_count, const std::string topic), (channel_name + " " + visible_user_count + " :" + topic)) \
50 IRC_REPLY_X(RPL_LISTEND , 323, (PARM_X), (":End of /LIST")) \
51 IRC_REPLY_X(RPL_NAMREPLY , 353, (PARM_X, const std::string channel_name, const std::string nicknames), (channel_name + " :" + nicknames)) \
52 IRC_REPLY_X(RPL_ENDOFNAMES , 366, (PARM_X, const std::string channel_name), (channel_name + " :End of /NAMES list")) \
53 IRC_REPLY_X(RPL_CHANNELMODEIS , 324, (PARM_X, const std::string channel_name, const std::string mode), (channel_name + " " + mode)) \
54 IRC_REPLY_X(RPL_INVITING , 341, (PARM_X, const std::string nickname, const std::string channel_name), (channel_name + " " + nickname)) \
55
56// ---------------------------------------------------------------------------------------------------------------------------------------------------
57#define IRC_REPLY_X(reply_code, reply_number, arguments, reply_string) reply_code = reply_number,
58
59/** Enum of the IRC reply codes */
64
65#undef IRC_REPLY_X
66
67
68// ---------------------------------------------------------------------------------------------------------------------------------------------------
69#define IRC_REPLY_X(reply_code, reply_number, arguments, reply_string) \
70 inline std::string MakeReplyMsg_##reply_code arguments \
71 { \
72 std::string msg; \
73 msg += std::string() + ":" + serverName + " " + #reply_number + " " + reply_string; \
74 return msg; \
75 } \
76
77
78#define PARM_X \
79 const std::string serverName
80
81/**
82 * @addtogroup ReplyMsgMakingFunctions Reply message making functions
83 * @brief MakeReplyMsg_<reply_code> functions.
84 */
85///@{
86/** Make an IRC reply message.
87 *
88 * @param serverName [in] The server name.
89 * @param ... [in] The arguments of the reply message.
90 * @return The reply message that is not contain CR-LF.
91 */
93///@}
94
95#undef PARM_X
96#undef IRC_REPLY_X
97
98// ---------------------------------------------------------------------------------------------------------------------------------------------------
99
100}
#define IRC_REPLY_TUPLE_LIST
Tuple of the IRC replies | IRC_REPLY_X (reply_code, reply_number, (arguments), (reply_string))
Definition IrcReplies.hpp:18
Definition ChannelControlBlock.hpp:12
EIrcReplyCode
Enum of the IRC reply codes.
Definition IrcReplies.hpp:60
@ IRC_REPLY_ENUM_MAX
Definition IrcReplies.hpp:62