xbot/snote_thread.cpp

24 lines
595 B
C++
Raw Normal View History

2023-11-25 20:09:20 -08:00
#include "snote_thread.hpp"
#include "irc_parse_thread.hpp"
#include "connection.hpp"
#include <cstring>
2023-11-26 15:40:40 -08:00
auto snote_thread(Connection& connection) -> void
2023-11-25 20:09:20 -08:00
{
static char const* const prefix = "*** Notice -- ";
2023-11-26 15:40:40 -08:00
connection.add_listener<IrcMsgEvent>([&connection](IrcMsgEvent& event)
2023-11-25 20:09:20 -08:00
{
2023-11-26 15:14:07 -08:00
auto& args = event.irc.args;
if (IrcCommand::NOTICE == event.command
&& "*" == args[0]
&& args[1].starts_with(prefix))
2023-11-25 20:09:20 -08:00
{
event.handled_ = true;
2023-11-26 15:40:40 -08:00
connection.make_event<SnoteEvent>(args[1].substr(strlen(prefix)));
2023-11-25 20:09:20 -08:00
}
});
}