2023-11-25 09:22:55 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "thread.hpp"
|
|
|
|
|
2023-11-26 15:08:55 -08:00
|
|
|
#include <string_view>
|
|
|
|
|
2023-11-25 09:22:55 -08:00
|
|
|
class Connection;
|
|
|
|
|
2023-11-26 15:08:55 -08:00
|
|
|
|
|
|
|
enum class IrcCommand
|
|
|
|
{
|
|
|
|
UNKNOWN,
|
|
|
|
RPL_WELCOME,
|
|
|
|
RPL_YOURHOST,
|
|
|
|
RPL_CREATED,
|
|
|
|
RPL_MYINFO,
|
|
|
|
RPL_ISUPPORT,
|
|
|
|
RPL_SNOMASK,
|
|
|
|
RPL_REDIR,
|
|
|
|
RPL_MAP,
|
|
|
|
RPL_MAPMORE,
|
|
|
|
RPL_MAPEND,
|
|
|
|
RPL_SAVENICK,
|
|
|
|
RPL_TRACELINK,
|
|
|
|
RPL_TRACECONNECTING,
|
|
|
|
RPL_TRACEHANDSHAKE,
|
|
|
|
RPL_TRACEUNKNOWN,
|
|
|
|
RPL_TRACEOPERATOR,
|
|
|
|
RPL_TRACEUSER,
|
|
|
|
RPL_TRACESERVER,
|
|
|
|
RPL_TRACENEWTYPE,
|
|
|
|
RPL_TRACECLASS,
|
|
|
|
RPL_STATSLINKINFO,
|
|
|
|
RPL_STATSCOMMANDS,
|
|
|
|
RPL_STATSCLINE,
|
|
|
|
RPL_STATSNLINE,
|
|
|
|
RPL_STATSILINE,
|
|
|
|
RPL_STATSKLINE,
|
|
|
|
RPL_STATSQLINE,
|
|
|
|
RPL_STATSYLINE,
|
|
|
|
RPL_ENDOFSTATS,
|
|
|
|
RPL_STATSPLINE,
|
|
|
|
RPL_UMODEIS,
|
|
|
|
RPL_STATSFLINE,
|
|
|
|
RPL_STATSDLINE,
|
|
|
|
RPL_SERVLIST,
|
|
|
|
RPL_SERVLISTEND,
|
|
|
|
RPL_STATSLLINE,
|
|
|
|
RPL_STATSUPTIME,
|
|
|
|
RPL_STATSOLINE,
|
|
|
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11-25 09:22:55 -08:00
|
|
|
struct IrcMsgEvent : Event
|
|
|
|
{
|
2023-11-26 15:08:55 -08:00
|
|
|
IrcMsgEvent(IrcCommand command, IrcMsg const& irc)
|
|
|
|
: command{command}, irc{irc} {}
|
|
|
|
IrcCommand command;
|
|
|
|
IrcMsg const& irc;
|
2023-11-25 09:22:55 -08:00
|
|
|
};
|
|
|
|
|
2023-11-25 20:09:20 -08:00
|
|
|
auto irc_parse_thread(Connection * connection) -> void;
|