MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / send

Method send

pushover_service.py:108–149  ·  view source on GitHub ↗

Send a Pushover notification. Returns dict with success/message.

(self, message, title="Ragnar", priority=0, sound="pushover")

Source from the content-addressed store, hash-verified

106 except Exception as e:
107 logger.debug(f"Slack webhook lookup failed: {e}")
108 return None
109
110 def pushover_configured(self):
111 """Return True when both Pushover keys are present."""
112 user_key, api_token = self._get_keys()
113 return bool(user_key and api_token)
114
115 def slack_configured(self):
116 """Return True when a Slack webhook URL is present."""
117 return bool(self._get_slack_webhook())
118
119 def is_configured(self):
120 """Return True when at least one delivery channel is configured."""
121 return self.pushover_configured() or self.slack_configured()
122
123 def is_enabled(self):
124 """Return True when push notifications are configured and enabled in config."""
125 return self.shared_data.config.get("pushover_enabled", False) and self.is_configured()
126
127 # ------------------------------------------------------------------
128 # Core send
129 # ------------------------------------------------------------------
130
131 def send(self, message, title="Ragnar", priority=0, sound="pushover"):
132 """Send a notification to every configured channel (Pushover, Slack).
133
134 Returns dict with success/message; success is True when at least one
135 channel delivered."""
136 results = {}
137 if self.pushover_configured():
138 results["Pushover"] = self._send_pushover(message, title, priority, sound)
139 webhook = self._get_slack_webhook()
140 if webhook:
141 results["Slack"] = self._send_slack(webhook, message, title, priority)
142 if not results:
143 return {"success": False, "message": "No notification channel configured"}
144 ok = [name for name, r in results.items() if r.get("success")]
145 failed = [f"{name}: {r.get('message')}" for name, r in results.items() if not r.get("success")]
146 if ok:
147 msg = f"Notification sent via {', '.join(ok)}"
148 if failed:
149 msg += f" (failed — {'; '.join(failed)})"
150 return {"success": True, "message": msg, "channels": results}
151 return {"success": False, "message": "; ".join(failed), "channels": results}
152

Callers 3

test_pushoverFunction · 0.95
rusense_ws_proxyFunction · 0.45
pump_upstream_to_clientFunction · 0.45

Calls 9

_get_keysMethod · 0.95
infoMethod · 0.80
warningMethod · 0.80
errorMethod · 0.80
sleepMethod · 0.45
encodeMethod · 0.45
decodeMethod · 0.45
readMethod · 0.45
getMethod · 0.45

Tested by 1

test_pushoverFunction · 0.76