Logging of the messages, customizable replies, assigning groups
This commit is contained in:
parent
f03f392cee
commit
7f57cd3bf6
21 changed files with 288 additions and 62 deletions
|
@ -3,20 +3,36 @@
|
|||
|
||||
#include "actor.h"
|
||||
|
||||
Module::Actor::Actor(const std::shared_ptr<Core>& core, const std::shared_ptr<Connection>& connection, const Permissions& permissions):
|
||||
Module(core, connection, permissions)
|
||||
Module::Actor::Actor(const std::shared_ptr<Core>& core, const Shared::Permissions& permissions):
|
||||
Module(core, permissions)
|
||||
{}
|
||||
|
||||
Module::Actor::~Actor() noexcept {}
|
||||
|
||||
void Module::Actor::message(const std::shared_ptr<::Actor>& actor, const Module::Module::Tokens& args) {
|
||||
Shared::Result Module::Actor::message(const std::shared_ptr<::Actor>& actor, const Shared::Strings& args) {
|
||||
std::string result;
|
||||
|
||||
if (args.front() == "list")
|
||||
result = hasPermission("read", actor) ? list() : "Can not tell you that";
|
||||
if (args.front() == "list") {
|
||||
if (!hasPermission("read", actor))
|
||||
return Shared::forbidden;
|
||||
|
||||
result = list();
|
||||
} else if (args.front() == "set") {
|
||||
if (!hasPermission("write", actor))
|
||||
return Shared::forbidden;
|
||||
|
||||
if (args.size() < 3)
|
||||
return Shared::error;
|
||||
|
||||
if (!result.empty())
|
||||
connection->send(actor->jid, result);
|
||||
result = set(args[1], args[2]);
|
||||
}
|
||||
|
||||
if (!result.empty()) {
|
||||
core->send(actor->jid, result);
|
||||
return Shared::success;
|
||||
}
|
||||
|
||||
return Shared::unhandled;
|
||||
}
|
||||
|
||||
std::string Module::Actor::list() {
|
||||
|
@ -33,3 +49,9 @@ std::string Module::Actor::list() {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string Module::Actor::set(const std::string& jid, const std::string& group) {
|
||||
core->setGroup(jid, group);
|
||||
|
||||
return jid + " is now " + core->router.getGroup(jid);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue