]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blobdiff - lib/Spamfilter.php
Make the *.get/*.add/*.delete calls return the channel/user/.. directly.
[irc/unrealircd/unrealircd-rpc-php.git] / lib / Spamfilter.php
index a7a0b3917eefde94e77728dd7d3ad9dbab2901b6..56fdfb9b809a5b0121b8d5893d84160b69a7d2b8 100644 (file)
@@ -23,7 +23,7 @@ class Spamfilter
      */
     public function add(string $name, string $match_type, string $spamfilter_targets, string $ban_action, string $ban_duration, string $reason): stdClass|array|bool
     {
-        return $this->connection->query('spamfilter.add', [
+        $response = $this->connection->query('spamfilter.add', [
             'name' => $name,
             'match_type' => $match_type,
             'spamfilter_targets' => $spamfilter_targets,
@@ -31,6 +31,9 @@ class Spamfilter
             'ban_duration' => $ban_duration,
             'reason' => $reason,
         ]);
+        if (property_exists($response, 'tkl'))
+            return $response->tkl;
+        return FALSE;
     }
 
     /**
@@ -41,12 +44,15 @@ class Spamfilter
      */
     public function delete(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass|array|bool
     {
-        return $this->connection->query('spamfilter.del', [
+        $response = $this->connection->query('spamfilter.del', [
             'name' => $name,
             'match_type' => $match_type,
             'spamfilter_targets' => $spamfilter_targets,
             'ban_action' => $ban_action,
         ]);
+        if (property_exists($response, 'tkl'))
+            return $response->tkl;
+        return FALSE;
     }
 
     /**
@@ -82,7 +88,7 @@ class Spamfilter
         ]);
 
         if (!is_bool($response)) {
-            return $response;
+            return $response->tkl;
         }
 
         throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');