3namespace PlanetTeamSpeak\TeamSpeak3Framework\Node;
5use PlanetTeamSpeak\TeamSpeak3Framework\Exception\AdapterException;
6use PlanetTeamSpeak\TeamSpeak3Framework\Exception\HelperException;
7use PlanetTeamSpeak\TeamSpeak3Framework\Exception\ServerQueryException;
8use PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper;
9use PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3;
30 $this->nodeInfo = $info;
32 if (!array_key_exists($index, $this->nodeInfo)) {
36 $this->nodeId = $this->nodeInfo[$index];
47 public function modify(array $properties): void
49 $properties[
"clid"] = $this->
getId();
51 $this->
execute(
"clientedit", $properties);
61 public function modifyDb(array $properties): void
63 $this->
getParent()->clientModifyDb($this[
"client_database_id"], $properties);
73 $this->
getParent()->clientDeleteDb($this[
"client_database_id"]);
83 return $this->
getParent()->clientInfoDb($this[
"client_database_id"]);
94 public function message(
string $msg): void
106 public function move(
int $cid,
string $cpw =
null): void
120 $this->
getParent()->clientKick($this->
getId(), $reasonid, $reasonmsg);
129 public function poke(
string $msg): void
142 public function ban(
int $timeseconds =
null,
string $reason =
null): array
144 return $this->
getParent()->clientBan($this->
getId(), $timeseconds, $reason);
154 return $this->
getParent()->customInfo($this[
"client_database_id"]);
164 public function customSet(
string $ident,
string $value): void
166 $this->
getParent()->customSet($this[
"client_database_id"], $ident, $value);
177 $this->
getParent()->customDelete($this[
"client_database_id"], $ident);
190 return $this->
execute(
"permoverview", [
"cldbid" => $this[
"client_database_id"],
"cid" => $cid,
"permid" => 0])->toArray();
199 public function permList(
bool $permsid =
false): array
201 return $this->
getParent()->clientPermList($this[
"client_database_id"], $permsid);
213 public function permAssign(
int|array $permid,
int|array $permvalue, array|
bool $permskip =
false): void
215 $this->
getParent()->clientPermAssign($this[
"client_database_id"], $permid, $permvalue, $permskip);
225 $this->
permAssign($permname, $permvalue, $permskip);
236 $this->
getParent()->clientPermRemove($this[
"client_database_id"], $permid);
258 $this->
getParent()->clientSetChannelGroup($this[
"client_database_id"], $cid, $cgid);
269 $this->
getParent()->serverGroupClientAdd($sgid, $this[
"client_database_id"]);
280 $this->
getParent()->serverGroupClientDel($sgid, $this[
"client_database_id"]);
290 return new StringHelper(
"/avatar_" . $this[
"client_base64HashClientUID"]);
303 if ($this[
"client_flag_avatar"] ==
null) {
308 $transfer =
TeamSpeak3::factory(
"filetransfer://" . (str_contains($download[
"host"],
":") ?
"[" . $download[
"host"] .
"]" : $download[
"host"]) .
":" . $download[
"port"]);
310 return $transfer->download($download[
"ftkey"], $download[
"size"]);
322 return $this->
execute(
"clientgetids", [
"cluid" => $this[
"client_unique_identifier"]])->toAssocArray(
"clid");
332 return str_contains($this[
"client_badges"],
"overwolf=1");
344 foreach (explode(
":", $this[
"client_badges"]) as $set) {
345 if (str_starts_with($set,
"badges=")) {
346 $badges[] = array_map(
"trim", explode(
",", substr($set, 7)));
360 return $this[
"client_type"] ? null : $this[
"client_version"]->section(
"[", 1)->filterDigits();
370 $channelGroups = [$this->
getParent()->channelGroupGetById($this[
"client_channel_group_id"])];
373 foreach (explode(
",", $this[
"client_servergroups"]) as $sgid) {
374 $serverGroups[] = $this->
getParent()->serverGroupGetById($sgid);
377 uasort($serverGroups, [__CLASS__,
"sortGroupList"]);
379 return array_merge($channelGroups, $serverGroups);
392 $iconid = $this[
'client_icon_id'];
393 if (!is_int($iconid)) {
394 $iconid = $iconid->toInt();
397 if ($this->
iconIsLocal(
"client_icon_id") || $iconid == 0) {
401 $download = $this->
getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->
iconGetName(
"client_icon_id"));
402 $transfer =
TeamSpeak3::factory(
"filetransfer://" . (str_contains($download[
"host"],
":") ?
"[" . $download[
"host"] .
"]" : $download[
"host"]) .
":" . $download[
"port"]);
404 return $transfer->download($download[
"ftkey"], $download[
"size"]);
427 if ($this->
offsetExists(
"client_type") && $this[
"client_type"] == 1) {
431 $this->nodeInfo = array_merge($this->nodeInfo, $this->
execute(
"clientinfo", [
"clid" => $this->
getId()])->toList());
441 return $this->
getParent()->getUniqueId() .
"_cl" . $this->
getId();
451 if ($this[
"client_type"]) {
452 return "client_query";
453 } elseif ($this[
"client_away"]) {
454 return "client_away";
455 } elseif (!$this[
"client_output_hardware"]) {
456 return "client_snd_disabled";
457 } elseif ($this[
"client_output_muted"]) {
458 return "client_snd_muted";
459 } elseif (!$this[
"client_input_hardware"]) {
460 return "client_mic_disabled";
461 } elseif ($this[
"client_input_muted"]) {
462 return "client_mic_muted";
463 } elseif ($this[
"client_is_channel_commander"]) {
464 return $this[
"client_flag_talking"] ?
"client_cc_talk" :
"client_cc_idle";
466 return $this[
"client_flag_talking"] ?
"client_talk" :
"client_idle";
487 return (
string)$this[
"client_nickname"];
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery objects.
Helper class for string handling.
Class describing a TeamSpeak 3 client and all it's parameters.
setChannelGroup(int $cid, int $cgid)
__construct(Server $server, array $info, string $index="clid")
addServerGroup(int $sgid)
customDelete(string $ident)
sendPluginCmd(string $plugin, string $data)
modifyDb(array $properties)
move(int $cid, string $cpw=null)
ban(int $timeseconds=null, string $reason=null)
remServerGroup(int $sgid)
permList(bool $permsid=false)
customSet(string $ident, string $value)
permAssign(int|array $permid, int|array $permvalue, array|bool $permskip=false)
permAssignByName($permname, $permvalue, $permskip=false)
kick(int $reasonid=TeamSpeak3::KICK_CHANNEL, string $reasonmsg=null)
permRemoveByName($permname)
modify(array $properties)
execute($cmd, array $params=[])
Class describing a TeamSpeak 3 virtual server and all it's parameters.
const TEXTMSG_CLIENT
1: target is a client
const PLUGINCMD_CLIENT
3: send plugincmd to all given client ids
const KICK_CHANNEL
4: kick client from channel
static factory(string $uri)