From: Kyle Fuller Date: Mon, 18 Mar 2013 21:35:44 +0000 (+0000) Subject: Add a command to test notify X-Git-Tag: 1.0.0~31 X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=ac4de181b3b97c074fa2738db098d10f3d852e88;p=znc-palaver.git Add a command to test notify --- diff --git a/palaver.cpp b/palaver.cpp index c41747f..55f35bb 100644 --- a/palaver.cpp +++ b/palaver.cpp @@ -340,7 +340,11 @@ private: class CPalaverMod : public CModule { public: - MODCONSTRUCTOR(CPalaverMod) {} + MODCONSTRUCTOR(CPalaverMod) { + AddHelpCommand(); + AddCommand("test", static_cast(&CPalaverMod::HandleTestCommand), + "", "Send notifications to registered devices"); + } #pragma mark - Cap @@ -547,6 +551,29 @@ public: return CONTINUE; } +#pragma mark - Commands + + void HandleTestCommand(const CString& sLine) { + if (m_pNetwork) { + unsigned int count = 0; + + for (std::vector::const_iterator it = m_vDevices.begin(); + it != m_vDevices.end(); ++it) + { + CDevice& device = **it; + + if (device.HasNetwork(*m_pNetwork)) { + count++; + device.SendNotification(*this, "palaver", "Test notification", NULL); + } + } + + PutModule("Notification sent to " + CString(count) + " clients."); + } else { + PutModule("You need to connect with a network."); + } + } + private: std::vector m_vDevices;