]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/User.php
11 public Connection
$connection;
13 public function __construct(Connection
$conn)
15 $this->connection
= $conn;
19 * Return a list of all users.
21 public function getAll(int $object_detail_level=2): stdClass
|array|bool
23 $response = $this->connection
->query('user.list', [
24 'object_detail_level' => $object_detail_level,
27 if(!is_bool($response)) {
28 return $response->list;
31 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
35 * Return a user object
37 * @return stdClass|array|bool
39 public function get(string $nick, int $object_detail_level=4): stdClass
|array|bool
41 $response = $this->connection
->query('user.get', [
43 'object_detail_level' => $object_detail_level,
46 if (!is_bool($response)) {
47 return $response->client
;
50 return false; // not found
54 * Set the nickname of a user (changes the nick)
56 * @return stdClass|array|bool
58 public function set_nick(string $nick, string $newnick): stdClass
|array|bool
60 return $this->connection
->query('user.set_nick', [
62 'newnick' => $newnick,
67 * Set the username/ident of a user
69 * @return stdClass|array|bool
71 public function set_username(string $nick, string $username): stdClass
|array|bool
73 return $this->connection
->query('user.set_username', [
75 'username' => $username,
80 * Set the realname/gecos of a user
82 * @return stdClass|array|bool
84 public function set_realname(string $nick, string $realname): stdClass
|array|bool
86 return $this->connection
->query('user.set_realname', [
88 'realname' => $realname,
93 * Set a virtual host (vhost) on the user
95 * @return stdClass|array|bool
97 public function set_vhost(string $nick, string $vhost): stdClass
|array|bool
99 return $this->connection
->query('user.set_vhost', [
106 * Change the user modes of a user.
108 * @return stdClass|array|bool
110 public function set_mode(string $nick, string $mode, bool $hidden = false): stdClass
|array|bool
112 return $this->connection
->query('user.set_mode', [
120 * Change the snomask of a user (oper).
122 * @return stdClass|array|bool
124 public function set_snomask(string $nick, string $snomask, bool $hidden = false): stdClass
|array|bool
126 return $this->connection
->query('user.set_snomask', [
128 'snomask' => $snomask,
134 * Make user an IRC Operator (oper).
136 * @return stdClass|array|bool
138 public function set_oper(string $nick, string $oper_account, string $oper_class,
139 string $class = null, string $modes = null,
140 string $snomask = null, string $vhost = null): stdClass
|array|bool
142 return $this->connection
->query('user.set_oper', [
144 'oper_account' => $oper_account,
145 'oper_class' => $oper_class,
148 'snomask' => $snomask,
154 * Join a user to a channel.
156 * @return stdClass|array|bool
158 public function join(string $nick, string $channel,
159 string $key = null, bool $force = false): stdClass
|array|bool
161 return $this->connection
->query('user.join', [
163 'channel' => $channel,
170 * Part a user from a channel.
172 * @return stdClass|array|bool
174 public function part(string $nick, string $channel, bool $force = false): stdClass
|array|bool
176 return $this->connection
->query('user.part', [
178 'channel' => $channel,
184 * Quit a user from IRC. Pretend it is a normal QUIT.
186 * @return stdClass|array|bool
188 public function quit(string $nick, string $reason): stdClass
|array|bool
190 return $this->connection
->query('user.quit', [
197 * Kill a user from IRC. Show that the user is forcefully removed.
199 * @return stdClass|array|bool
201 public function kill(string $nick, string $reason): stdClass
|array|bool
203 return $this->connection
->query('user.kill', [