diff --git a/README.md b/README.md index afeb918..4bc83ea 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,10 @@ Configuration ### Conditions +* `away_only = "no"` + + If set to "yes", notifications will only be sent if the user has set their `/away` status. + * `client_count_less_than = 0` Notifications will only be sent if the number of connected IRC clients is less than this @@ -105,8 +109,6 @@ Roadmap ### Conditions -* Away: Whether the user has set their /away status. - * User inactivity: How long, in seconds, since the last action made by user, in any channel or query window. diff --git a/notifo.cpp b/notifo.cpp index f6a13d6..a3e442f 100644 --- a/notifo.cpp +++ b/notifo.cpp @@ -65,6 +65,7 @@ class CNotifoMod : public CModule defaults["secret"] = ""; // Notification conditions + defaults["away_only"] = "no"; defaults["client_count_less_than"] = "0"; // Notification settings @@ -139,6 +140,19 @@ class CNotifoMod : public CModule AddSocket(sock); } + protected: + + /** + * Check if the away status condition is met. + * + * @return True if away_only is not "yes" or away status is set + */ + bool away_only() + { + CString value = options["away_only"].AsLower(); + return value != "yes" || user->IsIRCAway(); + } + /** * Check how many clients are connected to ZNC. * @@ -193,6 +207,11 @@ class CNotifoMod : public CModule return false; } + if (!away_only()) + { + return false; + } + if (!client_count_less_than()) { return false; @@ -209,6 +228,11 @@ class CNotifoMod : public CModule */ bool notify_pm(const CNick& nick) { + if (!away_only()) + { + return false; + } + return true; } @@ -437,6 +461,10 @@ class CNotifoMod : public CModule table.AddColumn("Condition"); table.AddColumn("Status"); + table.AddRow(); + table.SetCell("Condition", "away"); + table.SetCell("Status", user->IsIRCAway() ? "yes" : "no"); + table.AddRow(); table.SetCell("Condition", "client_count"); table.SetCell("Status", CString(client_count()));