Commit Graph

41 Commits

Author SHA1 Message Date
John Reese a69ec09d6b Rebrand project as ZNC Push
Issue #226
2011-09-29 09:30:08 -04:00
John Reese 60632d42fb Implement save/load for user options
In preparation for renaming the project and supparting multiple
notification services, there needs to be a simple method for migrating
user options to the new module name.  Using the built-in dictionary
read/write mechanism, migrating to a new module name would be as simple
as issuing `/msg *notifo save foo` and `/msg *notify load foo`.
2011-09-28 16:28:10 -04:00
John Reese 94ad55784e Implement notification uri keyword expansion
Resolves #198.  Four keywords are supported: context, nick, datetime,
and unixtime.
2011-03-09 11:02:34 -05:00
John Reese df891c0c69 Issue #198: Implement dictionary string expansion 2011-03-09 10:44:52 -05:00
John Reese a70ff4a364 Fix logic error in eval_tokens and add debug output
When faced with sub-expressions, the parser was not correctly advancing
its iterator to the sub-expression's matching end parenthesis, causing
it to evaluate inner conditions twice, and incorrectly terminate early
when it reached the first end parenthesis.

Added preprocessor flag NOTIFO_DEBUG to generate debug output to
PutModule() to validate the expression parsing logic.
2011-02-15 10:18:13 -05:00
John Reese 33b381eb87 Implemented custom expression evaluation options
This option allows customization of the boolean logic used to
determine how conditional values are used to filter notifications for
channel messages.  It evaluates as a full boolean logic expression,
including the use of sub-expressions.  The default value of "all" will
bypass this evaluation and simply require all conditions to be true.

The expression consists of space-separated tokens in the following grammar:

* expression = expression operator expression | "(" expression ")" | value
* operator = "and" | "or"
* value = "true" | "false" | condition
* condition = <any condition option>

Also implemented EVAL command for testing purposes.
2011-02-14 14:27:18 -05:00
John Reese c462f15201 Fix client_count condition not applying to queries 2011-02-14 10:20:56 -05:00
John Reese 5b24f18c37 Fix bug in replied condition
For any channel/PM where the user hasn't yet sent a message, the replied
condition would always return false due to failing a `0 < 0`
expression.  The fix special-cases last_notification_time values of 0 to
always return true.
2011-01-26 21:09:37 -05:00
John Reese 5c5c198ab7 Implemented replied condition, defaulted to yes
If set to "yes", notifications will only be sent if you have replied to the
channel or query window more recently than the last time a notification was
sent for that context.
2011-01-26 13:09:55 -05:00
John Reese 06fac8b254 Implemented configurable highlight terms 2011-01-19 13:48:43 -05:00
John Reese 74c813a656 Implemented PREPEND command for modifying config values 2011-01-19 12:54:05 -05:00
John Reese f2de10139c Implemented APPEND command for modifying config values 2011-01-19 11:36:07 -05:00
John Reese d4fd3ce741 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().
2011-01-19 09:27:39 -05:00
John Reese de4c84a36b Added context parameter to STATUS command 2011-01-18 16:14:16 -05:00
John Reese c85cb39c12 Implemented idle condition
Time in seconds since the last activity by the user on any channel or query
window, including joins, parts, messages, and actions.  Notifications will
only be sent if the elapsed time is greater than this value.  A value of
0 (zero) will disable this condition.
2011-01-18 15:24:50 -05:00
John Reese c9cac29c0e Implemented last_active condition
Time in seconds since the last message sent by the user on that channel or
query window. Notifications will only be sent if the elapsed time is greater
than this value.  A value of 0 (zero) will disable this condition.

Note that this condition keeps track of the last message sent to each channel
and query window separately, so a recent PM to Joe will not affect a
notification sent from channel #foo.
2011-01-18 13:06:07 -05:00
John Reese 16f28cb04a Implemented nick_blacklist condition
Space-separated list of nicks.  Applies to both channel mentions and
query windows. Notifications will only be sent for messages from nicks
that are not present in this list, using a case-insensitive comparison.

Note that wildcard patterns can be used to match multiple nicks with
a single blacklist entry. For example, `set nick_blacklist *bot` will
not send notifications from nicks like "channelbot", "FooBot", or
"Robot".  Care must be used to not accidentally blacklist legitimate
nicks with wildcards.
2011-01-18 11:12:58 -05:00
John Reese 6fb80cff1f Modify SET command to accept space-separated values
In preparation for nick_blacklist, which needs to allow input of a
space-separated list of nicks to ignore, the SET command shouldn't be
requirement an exact number of tokens.  Any tokens past the first three
should be included in the option's new value, such that a command like
"set nick_blacklist nick1 nick2 nick3" will be accepted.
2011-01-18 10:44:23 -05:00
John Reese 798a50f3a8 Implemented last_notification condition
Time in seconds since the last notification sent from that channel or query
window. Notifications will only be sent if the elapsed time is greater than
this value. A value of 0 (zero) will disable this condition.

Note that this condition keeps track of the last notification sent from each
channel and query window separately, so a recent PM from Joe will not affect a
notification sent from channel #foo.
2011-01-14 10:49:08 -05:00
John Reese dbd442b931 Compact condition checking 2011-01-14 09:48:56 -05:00
John Reese 307f17e493 Implemented away_only condition 2011-01-14 09:45:47 -05:00
John Reese cbcaeaa9c8 Removed debug sections 2011-01-13 23:01:27 -05:00
John Reese 828b51bb32 Copout HELP command 2011-01-13 22:58:49 -05:00
John Reese 3aaafb7ffb Implemented UNSET command to restore default values 2011-01-13 22:56:15 -05:00
John Reese 6c191f6471 Rearrange commands 2011-01-13 22:51:53 -05:00
John Reese 563b52bab7 Added message_length option 2011-01-13 22:46:02 -05:00
John Reese c749f4874b Added message_uri option 2011-01-13 22:43:02 -05:00
John Reese 1c2e9b019b Added STATUS command to check current conditions 2011-01-13 22:03:49 -05:00
John Reese 01885f39f4 Modify GET command to optionally list all values 2011-01-13 22:03:30 -05:00
John Reese db077ea78a Implemented client_count condition
Config option client_count_less_than (uint) determines if notifications
will be sent based on how many IRC clients are connected to ZNC.  A
value of zero disables this condition (always met), otherwise only sends
notifications if the number of connected clients is less than the
configured threshold.

Personal use case is client_count_less_than = 2, in that I always have
Irssi connected from my server, but if also connected from my phone, I
don't want duplicate notifications.
2011-01-13 22:00:24 -05:00
John Reese 7bcae40012 Fix error when sending commind with zero tokens 2011-01-13 22:00:08 -05:00
John Reese 0c5829ff0e Don't override default option values with empty strings 2011-01-13 21:59:44 -05:00
John Reese 6f10bb19f6 Implemented basic highlight matching against nick 2011-01-13 20:58:13 -05:00
John Reese c4d4718709 Implemented handling of channel messages and actions 2011-01-13 20:39:08 -05:00
John Reese 304bef93f0 Switch to using an MCString to track config options 2011-01-13 19:53:22 -05:00
John Reese 5c12abe602 Make notify_pm() only decide on sending notification
In order to better abstract and handle the difference between messages
and actions, notify_pm() is changed to only determine whether a private
message or action should send a notification to the user, and leave
sending the notification to the calling method.  This allows PM's and
PA's to have different notification text formats, while still
centralizing the logic to decide when to send them.

TODO: Make notify_pm() actually use logic instead of blindly saying yes.
2011-01-13 19:15:17 -05:00
John Reese f5590832cc Implemented PM notifications 2011-01-13 17:40:41 -05:00
John Reese 31541dda0a Factored out auth string encoding
Rather than re-encoding the auth string for every message, factored it into a
separate method that only gets called when the username or password is changed,
or the plugin is loaded/reloaded.
2011-01-13 17:16:43 -05:00
John Reese 042ade55da Added configurable message title to send_message()
Also abstracted out app name to object-level CString rather than building it
every time send_message() is executed.
2011-01-13 17:09:17 -05:00
John Reese 0baa7d866d Proof of concept completed
User can set and retrieve config values for their Notifo account name
and API secret.  The SEND command allows the user to send an arbitrary
notification to their account.

Fixed issue with encoding credentials in request headers.

Tested against official API and notification succeeded.
2011-01-13 16:28:58 -05:00
John Reese 80e0da5708 Initial commit, any command triggers HTTP POST
Currently the plugin waits for any command to be sent to *notifo, at
which point it triggers a canned HTTP request to a test URL.  This
canned request will be replaced soon with a proper, authenticated
request to the official Notifo service URL.
2011-01-10 22:33:13 -05:00