mirror of https://github.com/SeanOMik/znc-push.git
parent
60632d42fb
commit
a69ec09d6b
|
@ -1 +1 @@
|
||||||
notifo.so
|
push.so
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -1,5 +1,5 @@
|
||||||
notifo.so: notifo.cpp
|
push.so: push.cpp
|
||||||
znc-buildmod notifo.cpp
|
znc-buildmod push.cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f notifo.so
|
-rm -f push.so
|
||||||
|
|
29
README.md
29
README.md
|
@ -1,13 +1,13 @@
|
||||||
ZNC to Notifo
|
ZNC Push
|
||||||
=============
|
=============
|
||||||
|
|
||||||
ZNC to Notifo is a module for [ZNC][] that will send notifications to a [Notifo][] account
|
ZNC Push is a module for [ZNC][] that will send notifications to a [Notifo][] account
|
||||||
for any private message or channel highlight that matches a configurable set of conditions.
|
for any private message or channel highlight that matches a configurable set of conditions.
|
||||||
|
|
||||||
This project is still a Work In Progress, but should be functional enough and stable enough
|
This project is still a Work In Progress, but should be functional enough and stable enough
|
||||||
for everyday usage. Users are more than welcome to submit feature requests or patches for
|
for everyday usage. Users are more than welcome to submit feature requests or patches for
|
||||||
discussion or inclusion. Bug reports and feature requests can be submitted to
|
discussion or inclusion. Bug reports and feature requests can be submitted to
|
||||||
[my bug tracker][mantis] by selecting the "ZNC to Notifo" project from the top right, or
|
[my bug tracker][mantis] by selecting the "ZNC Push" project from the top right, or
|
||||||
sent via email.
|
sent via email.
|
||||||
|
|
||||||
For full functionality, this module requires ZNC version 0.090 or newer, but should compile
|
For full functionality, this module requires ZNC version 0.090 or newer, but should compile
|
||||||
|
@ -15,7 +15,7 @@ and run with a reduced feature set on versions as old as 0.078, the current vers
|
||||||
Ubuntu. However, development and testing is done exclusively against the latest source
|
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.
|
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
|
ZNC Push 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
|
personal need. It may not fit your use cases, but any and all feedback would be greatly
|
||||||
appreciated.
|
appreciated.
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ If you have `make` installed, you can compile the module with:
|
||||||
|
|
||||||
Otherwise, run the full command:
|
Otherwise, run the full command:
|
||||||
|
|
||||||
$ znc-build notifo.cpp
|
$ znc-build push.cpp
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
@ -43,24 +43,35 @@ Installation
|
||||||
|
|
||||||
Copy the compiled module into your ZNC profile:
|
Copy the compiled module into your ZNC profile:
|
||||||
|
|
||||||
$ cp notifo.so ~/.znc/modules/
|
$ cp push.so ~/.znc/modules/
|
||||||
|
|
||||||
Now, load the module in ZNC:
|
Now, load the module in ZNC:
|
||||||
|
|
||||||
/msg *status loadmod notifo
|
/msg *status loadmod push
|
||||||
|
|
||||||
Then set your Notifo username and API secret. The API secret is not your password, and
|
Then set your Notifo username and API secret. The API secret is not your password, and
|
||||||
can be obtained by logging into Notifo's website, clicking Settings, and then "Click to
|
can be obtained by logging into Notifo's website, clicking Settings, and then "Click to
|
||||||
Show" next to the "API Secret" heading:
|
Show" next to the "API Secret" heading:
|
||||||
|
|
||||||
/msg *notifo set username foo
|
/msg *push set username foo
|
||||||
/msg *notifo set secret ...
|
/msg *push set secret ...
|
||||||
|
|
||||||
At this point, it should start sending notifications every time you get a private message
|
At this point, it should start sending notifications every time you get a private message
|
||||||
or someone says your name in a channel. If this is everything you wanted, congratulations,
|
or someone says your name in a channel. If this is everything you wanted, congratulations,
|
||||||
you're done!
|
you're done!
|
||||||
|
|
||||||
|
|
||||||
|
Migrating From Notifo
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Before uninstalling the old Notifo module, save your settings to a file. When you have the
|
||||||
|
new Push module installed, you can then load those settings back in, rather than needing
|
||||||
|
to set your configuration all over again:
|
||||||
|
|
||||||
|
/msg *notifo save /tmp/znc_notifo
|
||||||
|
/msg *push load /tmp/znc_notifo
|
||||||
|
|
||||||
|
|
||||||
Commands
|
Commands
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* ZNC Notifo Module
|
* ZNC Push Module
|
||||||
*
|
*
|
||||||
* Allows the user to enter a Notifo user and API token, and sends
|
* Allows the user to enter a Push user and API token, and sends
|
||||||
* channel highlights and personal messages to Notifo.
|
* channel highlights and personal messages to Push.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 John Reese
|
* Copyright (c) 2011 John Reese
|
||||||
* Licensed under the MIT license
|
* Licensed under the MIT license
|
||||||
|
@ -22,19 +22,19 @@
|
||||||
|
|
||||||
// Handle versions of ZNC older than 0.090 by disabling the away_only condition
|
// Handle versions of ZNC older than 0.090 by disabling the away_only condition
|
||||||
#if VERSION_MAJOR == 0 && VERSION_MINOR >= 90
|
#if VERSION_MAJOR == 0 && VERSION_MINOR >= 90
|
||||||
#define NOTIFO_AWAY
|
#define PUSH_AWAY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Debug output
|
// Debug output
|
||||||
#define NOTIFO_DEBUG 0
|
#define PUSH_DEBUG 0
|
||||||
|
|
||||||
#if NOTIFO_DEBUG
|
#if PUSH_DEBUG
|
||||||
#define PutDebug(s) PutModule(s)
|
#define PutDebug(s) PutModule(s)
|
||||||
#else
|
#else
|
||||||
#define PutDebug(s) //s
|
#define PutDebug(s) //s
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class CNotifoMod : public CModule
|
class CPushMod : public CModule
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class CNotifoMod : public CModule
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MODCONSTRUCTOR(CNotifoMod) {
|
MODCONSTRUCTOR(CPushMod) {
|
||||||
app = "ZNC";
|
app = "ZNC";
|
||||||
crlf = "\r\n";
|
crlf = "\r\n";
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class CNotifoMod : public CModule
|
||||||
notifo_auth = "";
|
notifo_auth = "";
|
||||||
notifo_host = "api.notifo.com";
|
notifo_host = "api.notifo.com";
|
||||||
notifo_url = "/v1/send_notification";
|
notifo_url = "/v1/send_notification";
|
||||||
user_agent = "ZNC To Notifo";
|
user_agent = "ZNC Push";
|
||||||
|
|
||||||
// Current user
|
// Current user
|
||||||
user = GetUser();
|
user = GetUser();
|
||||||
|
@ -97,7 +97,7 @@ class CNotifoMod : public CModule
|
||||||
defaults["query_conditions"] = "all";
|
defaults["query_conditions"] = "all";
|
||||||
|
|
||||||
// Notification conditions
|
// Notification conditions
|
||||||
#ifdef NOTIFO_AWAY
|
#ifdef PUSH_AWAY
|
||||||
defaults["away_only"] = "no";
|
defaults["away_only"] = "no";
|
||||||
#endif
|
#endif
|
||||||
defaults["client_count_less_than"] = "0";
|
defaults["client_count_less_than"] = "0";
|
||||||
|
@ -112,7 +112,7 @@ class CNotifoMod : public CModule
|
||||||
defaults["message_length"] = "100";
|
defaults["message_length"] = "100";
|
||||||
defaults["message_uri"] = "";
|
defaults["message_uri"] = "";
|
||||||
}
|
}
|
||||||
virtual ~CNotifoMod() {}
|
virtual ~CPushMod() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ class CNotifoMod : public CModule
|
||||||
* @param title Message title to use
|
* @param title Message title to use
|
||||||
* @param context Channel or nick context
|
* @param context Channel or nick context
|
||||||
*/
|
*/
|
||||||
void send_message(const CString& message, const CString& title="New Message", const CString& context="*notifo", const CNick& nick=CString("*notifo"))
|
void send_message(const CString& message, const CString& title="New Message", const CString& context="*push", const CNick& nick=CString("*push"))
|
||||||
{
|
{
|
||||||
// Set the last notification time
|
// Set the last notification time
|
||||||
last_notification_time[context] = time(NULL);
|
last_notification_time[context] = time(NULL);
|
||||||
|
@ -351,7 +351,7 @@ class CNotifoMod : public CModule
|
||||||
*/
|
*/
|
||||||
bool away_only()
|
bool away_only()
|
||||||
{
|
{
|
||||||
#ifdef NOTIFO_AWAY
|
#ifdef PUSH_AWAY
|
||||||
CString value = options["away_only"].AsLower();
|
CString value = options["away_only"].AsLower();
|
||||||
return value != "yes" || user->IsIRCAway();
|
return value != "yes" || user->IsIRCAway();
|
||||||
#else
|
#else
|
||||||
|
@ -397,11 +397,11 @@ class CNotifoMod : public CModule
|
||||||
{
|
{
|
||||||
CString value = i->AsLower();
|
CString value = i->AsLower();
|
||||||
char prefix = value[0];
|
char prefix = value[0];
|
||||||
bool notify = true;
|
bool push = true;
|
||||||
|
|
||||||
if (prefix == '-')
|
if (prefix == '-')
|
||||||
{
|
{
|
||||||
notify = false;
|
push = false;
|
||||||
value.LeftChomp(1);
|
value.LeftChomp(1);
|
||||||
}
|
}
|
||||||
else if (prefix == '_')
|
else if (prefix == '_')
|
||||||
|
@ -413,7 +413,7 @@ class CNotifoMod : public CModule
|
||||||
|
|
||||||
if (msg.WildCmp(value))
|
if (msg.WildCmp(value))
|
||||||
{
|
{
|
||||||
return notify;
|
return push;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,7 +747,7 @@ class CNotifoMod : public CModule
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle direct commands to the *notifo virtual user.
|
* Handle direct commands to the *push virtual user.
|
||||||
*
|
*
|
||||||
* @param command Command string
|
* @param command Command string
|
||||||
*/
|
*/
|
||||||
|
@ -951,7 +951,7 @@ class CNotifoMod : public CModule
|
||||||
}
|
}
|
||||||
|
|
||||||
CString file_path = command.Token(1, true, " ");
|
CString file_path = command.Token(1, true, " ");
|
||||||
|
|
||||||
if (!CFile::Exists(file_path))
|
if (!CFile::Exists(file_path))
|
||||||
{
|
{
|
||||||
PutModule("File does not exist: " + file_path);
|
PutModule("File does not exist: " + file_path);
|
||||||
|
@ -986,7 +986,7 @@ class CNotifoMod : public CModule
|
||||||
table.AddColumn("Condition");
|
table.AddColumn("Condition");
|
||||||
table.AddColumn("Status");
|
table.AddColumn("Status");
|
||||||
|
|
||||||
#ifdef NOTIFO_AWAY
|
#ifdef PUSH_AWAY
|
||||||
table.AddRow();
|
table.AddRow();
|
||||||
table.SetCell("Condition", "away");
|
table.SetCell("Condition", "away");
|
||||||
table.SetCell("Status", user->IsIRCAway() ? "yes" : "no");
|
table.SetCell("Status", user->IsIRCAway() ? "yes" : "no");
|
||||||
|
@ -1049,7 +1049,7 @@ class CNotifoMod : public CModule
|
||||||
// HELP command
|
// HELP command
|
||||||
else if (action == "help")
|
else if (action == "help")
|
||||||
{
|
{
|
||||||
PutModule("View the detailed documentation at https://github.com/jreese/znc-notifo/blob/master/README.md");
|
PutModule("View the detailed documentation at https://github.com/jreese/znc-push/blob/master/README.md");
|
||||||
}
|
}
|
||||||
// EVAL command
|
// EVAL command
|
||||||
else if (action == "eval")
|
else if (action == "eval")
|
||||||
|
@ -1064,4 +1064,4 @@ class CNotifoMod : public CModule
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MODULEDEFS(CNotifoMod, "Send highlights and personal messages to a Notifo account")
|
MODULEDEFS(CPushMod, "Send highlights and personal messages to a push notification service")
|
Loading…
Reference in New Issue