]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/commitdiff
Add nameban to Connection.php and various bugfixes
authorValerie Pond <redacted>
Tue, 10 Jan 2023 05:08:49 +0000 (05:08 +0000)
committerValerie Pond <redacted>
Tue, 10 Jan 2023 05:08:49 +0000 (05:08 +0000)
In many cases on a failed lookup such as if a nick didn't exist, this threw an exception which halted things. Also in some cases there weren't bool checks when there needed to be for such catches

lib/Connection.php
lib/NameBan.php
lib/ServerBan.php
lib/Spamfilter.php

index 02fdeeed971a87467164700c52c396e93140d9d9..068c1bb2d6a95c80d532603bc561249e49395f17 100644 (file)
@@ -98,4 +98,8 @@ class Connection
     {
         return new Spamfilter($this);
     }
+    public function nameban(): NameBan
+    {
+        return new NameBan($this);
+    }
 }
index 4f969b0f557c6e27fc170ce0f54a8386431b84c6..0447d89ecd37c1dd038bea721597cbeabf889199 100644 (file)
@@ -37,6 +37,10 @@ class NameBan
             $query['set_by'] = $set_by;
 
         $response = $this->connection->query('name_ban.add', $query);
+
+        if (is_bool($response))
+            return false;
+            
         if (property_exists($response, 'tkl'))
             return $response->tkl;
         return FALSE;
@@ -54,6 +58,10 @@ class NameBan
         $response = $this->connection->query('name_ban.del', [
             'name' => $name,
         ]);
+        
+        if (is_bool($response))
+            return false;
+
         if (property_exists($response, 'tkl'))
             return $response->tkl;
         return FALSE;
index ab8ea2fdbb66fef7f36ef3fb1dc3c103a01b1f50..9f874b871fd4e307490afb0a080c5420968d3891 100644 (file)
@@ -30,6 +30,10 @@ class ServerBan
             'reason' => $reason,
             'duration_string' => $duration ?? '1d',
         ]);
+
+        if (is_bool($response))
+            return false;
+            
         if (property_exists($response, 'tkl'))
             return $response->tkl;
         return FALSE;
@@ -48,6 +52,10 @@ class ServerBan
             'name' => $name,
             'type' => $type,
         ]);
+
+        if (is_bool($response))
+            return false;
+            
         if (property_exists($response, 'tkl'))
             return $response->tkl;
         return FALSE;
index 56fdfb9b809a5b0121b8d5893d84160b69a7d2b8..723c3708bd336fa8ca4fcba10304eee728575b05 100644 (file)
@@ -31,6 +31,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;
@@ -50,6 +54,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;