Fix #191: ZNC < 0.090 does not support IsIRCAway()

To maintain compatibility with ZNC < 0.090 (such as 0.078 used by
Ubuntu), we need to conditionally disable the away_only condition when
compiled against versions that don't support CUser->IsIRCAway().
This commit is contained in:
John Reese 2011-01-19 09:27:37 -05:00
parent de4c84a36b
commit d4fd3ce741
2 changed files with 27 additions and 0 deletions

View File

@ -9,6 +9,11 @@ for everyday usage. Users are more than welcome to submit feature requests or p
discussion or inclusion. Bug reports and feature requests can be submitted to
[my bug tracker][mantis] or sent via email.
For full functionality, this module requires ZNC version 0.090 or newer, but should compile
and run with a reduced feature set on versions as old as 0.078, the current version used by
Ubuntu. However, development and testing is done exclusively against the latest source
distribution, so feedback on older releases of ZNC is needed to continue supporting them.
ZNC to Notifo was created by [John Reese](http://johnmreese.com) and designed to fill a
personal need. It may not fit your use cases, but any and all feedback would be greatly
appreciated.
@ -17,6 +22,12 @@ appreciated.
Compiling
---------
If you have installed ZNC from a Linux distribution's repository, you will most likely
need to install the development package before building this module. On Ubuntu, this can
be installed with:
$ sudo aptitude install znc-dev
If you have `make` installed, you can compile the module with:
$ make
@ -86,6 +97,9 @@ Configuration
If set to "yes", notifications will only be sent if the user has set their `/away` status.
This condition requires version 0.090 of ZNC to operate, and will be disabled when
compiled against older versions.
* `client_count_less_than = 0`
Notifications will only be sent if the number of connected IRC clients is less than this

View File

@ -20,6 +20,11 @@
#error This module needs ZNC 0.072 or newer.
#endif
// Handle versions of ZNC older than 0.090 by disabling the away_only condition
#if VERSION_MAJOR == 0 && VERSION_MINOR >= 90
#define NOTIFO_AWAY
#endif
class CNotifoMod : public CModule
{
protected:
@ -76,7 +81,9 @@ class CNotifoMod : public CModule
defaults["secret"] = "";
// Notification conditions
#ifdef NOTIFO_AWAY
defaults["away_only"] = "no";
#endif
defaults["client_count_less_than"] = "0";
defaults["idle"] = "0";
defaults["last_active"] = "180";
@ -168,8 +175,12 @@ class CNotifoMod : public CModule
*/
bool away_only()
{
#ifdef NOTIFO_AWAY
CString value = options["away_only"].AsLower();
return value != "yes" || user->IsIRCAway();
#else
return true
#endif
}
/**
@ -612,9 +623,11 @@ class CNotifoMod : public CModule
table.AddColumn("Condition");
table.AddColumn("Status");
#ifdef NOTIFO_AWAY
table.AddRow();
table.SetCell("Condition", "away");
table.SetCell("Status", user->IsIRCAway() ? "yes" : "no");
#endif
table.AddRow();
table.SetCell("Condition", "client_count");