X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/ef5fa0787eabd20beef3110c2fe55955d472ddc9..8b5d7715bf0eb81d5627267b7bcb42cbc5d5e2f0:/projects/sgconf/users.cpp?ds=sidebyside diff --git a/projects/sgconf/users.cpp b/projects/sgconf/users.cpp index 680625c2..8b341b6f 100644 --- a/projects/sgconf/users.cpp +++ b/projects/sgconf/users.cpp @@ -216,12 +216,25 @@ return proto.CheckUser(arg, it->second, SimpleCallback, NULL) == STG::st_ok; } bool SendMessageFunction(const SGCONF::CONFIG & config, - const std::string & arg, + const std::string & /*arg*/, const std::map & options) { -// TODO -std::cerr << "Unimplemented.\n"; -return false; +std::map::const_iterator it(options.find("logins")); +if (it == options.end()) + throw SGCONF::ACTION::ERROR("Logins are not specified."); +std::string logins = it->second; +for (size_t i = 0; i < logins.length(); ++i) + if (logins[i] == ',') + logins[i] = ':'; +it = options.find("text"); +if (it == options.end()) + throw SGCONF::ACTION::ERROR("Message text is not specified."); +std::string text = it->second; +STG::SERVCONF proto(config.server.data(), + config.port.data(), + config.userName.data(), + config.userPass.data()); +return proto.SendMessage(logins, text, SimpleCallback, NULL) == STG::st_ok; } } // namespace anonymous