xbot/bot.hpp

37 lines
797 B
C++
Raw Normal View History

2025-01-25 21:24:33 -08:00
#pragma once
2025-01-26 19:35:56 -08:00
#include "client.hpp"
2025-01-25 21:24:33 -08:00
#include <boost/signals2.hpp>
#include <memory>
struct Command
{
std::string_view source;
std::string_view target;
std::string_view oper;
std::string_view account;
std::string_view command;
std::string_view arguments;
};
struct Bot : std::enable_shared_from_this<Bot>
{
2025-01-26 19:35:56 -08:00
std::shared_ptr<Client> self_;
2025-01-25 21:24:33 -08:00
char command_prefix_;
2025-01-26 19:35:56 -08:00
boost::signals2::signal<void(const Command &)> sig_command;
Bot(std::shared_ptr<Client> self)
2025-01-25 21:24:33 -08:00
: self_{std::move(self)}
, command_prefix_{'!'}
{}
2025-01-27 17:46:07 -08:00
auto on_chat(const Chat &) -> void;
auto process_command(std::string_view message, const Chat &msg) -> void;
2025-01-26 19:35:56 -08:00
static auto start(std::shared_ptr<Client>) -> std::shared_ptr<Bot>;
auto shutdown() -> void;
2025-01-25 21:24:33 -08:00
};