Refactored in a way modules have access to bot infrastructure
This commit is contained in:
parent
c605b3ba93
commit
89c04254b8
25 changed files with 245 additions and 216 deletions
|
@ -3,13 +3,33 @@
|
|||
|
||||
#include "actor.h"
|
||||
|
||||
Module::Actor::Actor(const std::shared_ptr<gloox::Client>& client):
|
||||
Module(client)
|
||||
Module::Actor::Actor(const std::shared_ptr<Core>& core, const std::shared_ptr<Connection>& connection):
|
||||
Module(core, connection)
|
||||
{}
|
||||
|
||||
Module::Actor::~Actor() noexcept {}
|
||||
|
||||
void Module::Actor::message(const std::shared_ptr<::Actor>& actor, const Module::Module::Tokens& args) {
|
||||
std::string result;
|
||||
|
||||
if (args.front() == "list")
|
||||
sendMessage(actor, "Me\nMyself\nI");
|
||||
result = list();
|
||||
|
||||
if (!result.empty())
|
||||
connection->send(actor->jid, result);
|
||||
}
|
||||
|
||||
std::string Module::Actor::list() {
|
||||
std::string result;
|
||||
for (const std::pair<const std::string, std::string>& pair : core->router.getActors()) {
|
||||
if (!result.empty())
|
||||
result.append(1, '\n');
|
||||
|
||||
result += pair.first + ": " + pair.second;
|
||||
}
|
||||
|
||||
if (result.empty())
|
||||
result += "There are no actors currently";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue