#include #include #include struct UserEvent {}; auto Test() -> boost::asio::awaitable { try { auto executor = co_await boost::asio::this_coro::executor; // NOLINTNEXTLINE auto sock = co_await yail::Socks5ProxyConnect("127.0.0.1", 4447, "irc.ilita.i2p", 6667); auto client = yail::IrcClient, utempl::Tuple{}, std::tuple<>>{// clangd bug :( .socket = std::move(sock), .nick = "sha512sum_bot", .server = "irc.ilita.i2p"} .AddState, "ruUsers">() // NOLINTNEXTLINE .With([](auto& self, yail::event::AnyMessage message) -> boost::asio::awaitable { std::println("Readed message: {}", message.data); co_return; }) // NOLINTNEXTLINE .With([](auto& self, UserEvent event) -> boost::asio::awaitable { std::println("User event!"); co_return; }) // NOLINTNEXTLINE .With([](auto& self, yail::event::Ping ping) -> boost::asio::awaitable { co_await self.Pong(ping.data); }) // NOLINTNEXTLINE .With([](auto& self, yail::event::Welcome message) -> boost::asio::awaitable { std::println("Welcome: {}", message.message); co_await self.Join("#ru"); co_await self.SendEvent(UserEvent{}); co_await self.SendMessage("#ru", "Hello from yet another irc library"); }) // NOLINTNEXTLINE .With([](auto& self, yail::event::ChannelUsers event) -> boost::asio::awaitable { std::unordered_set& ruUsers = self.template GetState<"ruUsers">(); for(yail::UserView view : event.users) { ruUsers.emplace(view); } co_return; }); co_await client.Connect("sha512sum_bot"); co_await client.Loop(); } catch(const std::exception& err) { std::println("Err: {}", err.what()); } }; auto main() -> int { boost::asio::io_context context; boost::asio::co_spawn(context, Test(), boost::asio::detached); context.run(); };