Skip to content

Commit

Permalink
Fix #191: ZNC < 0.090 does not support IsIRCAway()
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
amyreese committed Jan 19, 2011
1 parent de4c84a commit d4fd3ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions notifo.cpp
Expand Up @@ -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:
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
}

/**
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit d4fd3ce

Please sign in to comment.