]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Spamfilter.php
56fdfb9b809a5b0121b8d5893d84160b69a7d2b8
11 public Connection
$connection;
13 public function __construct(Connection
$conn)
15 $this->connection
= $conn;
21 * @return stdClass|array|bool
24 public function add(string $name, string $match_type, string $spamfilter_targets, string $ban_action, string $ban_duration, string $reason): stdClass
|array|bool
26 $response = $this->connection
->query('spamfilter.add', [
28 'match_type' => $match_type,
29 'spamfilter_targets' => $spamfilter_targets,
30 'ban_action' => $ban_action,
31 'ban_duration' => $ban_duration,
34 if (property_exists($response, 'tkl'))
35 return $response->tkl
;
40 * Delete a spamfilter.
42 * @return stdClass|array|bool
45 public function delete(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass
|array|bool
47 $response = $this->connection
->query('spamfilter.del', [
49 'match_type' => $match_type,
50 'spamfilter_targets' => $spamfilter_targets,
51 'ban_action' => $ban_action,
53 if (property_exists($response, 'tkl'))
54 return $response->tkl
;
59 * Return a list of all spamfilters.
61 * @return stdClass|array|bool
64 public function getAll(): stdClass
|array|bool
66 $response = $this->connection
->query('spamfilter.list');
68 if (!is_bool($response)) {
69 return $response->list;
72 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
76 * Get a specific spamfilter.
78 * @return stdClass|array|bool
81 public function get(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass
|array|bool
83 $response = $this->connection
->query('spamfilter.get', [
85 'match_type' => $match_type,
86 'spamfilter_targets' => $spamfilter_targets,
87 'ban_action' => $ban_action,
90 if (!is_bool($response)) {
91 return $response->tkl
;
94 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');