]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blobdiff - lib/Spamfilter.php
Add streaming JSON-LOG support. Requires UnrealIRCd 6.1.0+
[irc/unrealircd/unrealircd-rpc-php.git] / lib / Spamfilter.php
index 56fdfb9b809a5b0121b8d5893d84160b69a7d2b8..fbb889a8cf68475b5069730c6839eb576d8ffcfb 100644 (file)
@@ -19,7 +19,6 @@ class Spamfilter
      * Add a spamfilter.
      *
      * @return stdClass|array|bool
-     * @throws Exception
      */
     public function add(string $name, string $match_type, string $spamfilter_targets, string $ban_action, string $ban_duration, string $reason): stdClass|array|bool
     {
@@ -31,6 +30,10 @@ class Spamfilter
             'ban_duration' => $ban_duration,
             'reason' => $reason,
         ]);
+
+        if (is_bool($response))
+            return false;
+
         if (property_exists($response, 'tkl'))
             return $response->tkl;
         return FALSE;
@@ -40,7 +43,6 @@ class Spamfilter
      * Delete a spamfilter.
      *
      * @return stdClass|array|bool
-     * @throws Exception
      */
     public function delete(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass|array|bool
     {
@@ -50,6 +52,10 @@ class Spamfilter
             'spamfilter_targets' => $spamfilter_targets,
             'ban_action' => $ban_action,
         ]);
+
+        if (is_bool($response))
+            return false;
+
         if (property_exists($response, 'tkl'))
             return $response->tkl;
         return FALSE;
@@ -76,7 +82,6 @@ class Spamfilter
      * Get a specific spamfilter.
      *
      * @return stdClass|array|bool
-     * @throws Exception
      */
     public function get(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass|array|bool
     {
@@ -91,6 +96,6 @@ class Spamfilter
             return $response->tkl;
         }
 
-        throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
+        return false; // not found
     }
 }