make forwarding configurable
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / windows (push) Has been cancelled
ContinuousIntegration / linux (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / windows (push) Has been cancelled
ContinuousIntegration / linux (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
This commit is contained in:
parent
f69923cbbb
commit
6aa90a1852
@ -17,6 +17,7 @@ void Factorio::sendToLinked(const std::string& message) {
|
||||
}
|
||||
|
||||
Factorio::Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageModelI& rmm, FactorioLogParser& flp) :
|
||||
_conf(conf),
|
||||
_cr(cr),
|
||||
_rmm(rmm),
|
||||
_rmm_sr(_rmm.newSubRef(this)),
|
||||
@ -72,6 +73,10 @@ bool Factorio::onEvent(const Message::Events::MessageConstruct& e) {
|
||||
bool Factorio::onEvent(const FactorioLog::Events::Join& e) {
|
||||
std::cout << "Factorio: event join " << e.player_name << "\n";
|
||||
|
||||
if (!_conf.get_bool("Factorio", "forward", "join").value_or(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string message{e.player_name};
|
||||
message += " joined";
|
||||
|
||||
@ -83,6 +88,10 @@ bool Factorio::onEvent(const FactorioLog::Events::Join& e) {
|
||||
bool Factorio::onEvent(const FactorioLog::Events::Leave& e) {
|
||||
std::cout << "Factorio: event leave " << e.player_name << " " << e.reason << "\n";
|
||||
|
||||
if (!_conf.get_bool("Factorio", "forward", "leave").value_or(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string message{e.player_name};
|
||||
message += " left";
|
||||
|
||||
@ -94,6 +103,10 @@ bool Factorio::onEvent(const FactorioLog::Events::Leave& e) {
|
||||
bool Factorio::onEvent(const FactorioLog::Events::Chat& e) {
|
||||
std::cout << "Factorio: event chat " << e.player_name << ": " << e.message << "\n";
|
||||
|
||||
if (!_conf.get_bool("Factorio", "forward", "chat").value_or(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ignore pings
|
||||
constexpr std::string_view ping_prefix{"[gps="};
|
||||
if (e.message.size() > ping_prefix.size() && e.message.substr(0, ping_prefix.size()) == ping_prefix) {
|
||||
@ -113,6 +126,10 @@ bool Factorio::onEvent(const FactorioLog::Events::Chat& e) {
|
||||
bool Factorio::onEvent(const FactorioLog::Events::Died& e) {
|
||||
std::cout << "Factorio: event died " << e.player_name << ": " << e.reason << "\n";
|
||||
|
||||
if (!_conf.get_bool("Factorio", "forward", "died").value_or(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string message{e.player_name};
|
||||
message += " died from ";
|
||||
message += e.reason;
|
||||
@ -124,17 +141,31 @@ bool Factorio::onEvent(const FactorioLog::Events::Died& e) {
|
||||
|
||||
bool Factorio::onEvent(const FactorioLog::Events::Evolution& e) {
|
||||
std::cout << "Factorio: event evolution " << e.evo << "\n";
|
||||
|
||||
//if (!_conf.get_bool("Factorio", "forward", "evolution").value_or(true)) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Factorio::onEvent(const FactorioLog::Events::ResearchStarted& e) {
|
||||
std::cout << "Factorio: event research started " << e.name << "\n";
|
||||
|
||||
//if (!_conf.get_bool("Factorio", "forward", "research_started").value_or(true)) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Factorio::onEvent(const FactorioLog::Events::ResearchFinished& e) {
|
||||
std::cout << "Factorio: event research finished " << e.name << "\n";
|
||||
|
||||
if (!_conf.get_bool("Factorio", "forward", "research_finished").value_or(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string message{"Research "};
|
||||
message += e.name;
|
||||
message += " finished!";
|
||||
@ -146,6 +177,11 @@ bool Factorio::onEvent(const FactorioLog::Events::ResearchFinished& e) {
|
||||
|
||||
bool Factorio::onEvent(const FactorioLog::Events::ResearchCancelled& e) {
|
||||
std::cout << "Factorio: event research cancelled " << e.name << "\n";
|
||||
|
||||
//if (!_conf.get_bool("Factorio", "forward", "research_cancelled").value_or(true)) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
struct ConfigModelI;
|
||||
|
||||
class Factorio : public RegistryMessageModelEventI, public FactorioLogParserEventI {
|
||||
ConfigModelI& _conf;
|
||||
Contact3Registry& _cr;
|
||||
RegistryMessageModelI& _rmm;
|
||||
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user