Implemented away_only condition

This commit is contained in:
John Reese 2011-01-14 09:45:47 -05:00
parent 9f89dc5c9c
commit 307f17e493
2 changed files with 32 additions and 2 deletions

View File

@ -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.

View File

@ -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()));