ts3phpframework
Loading...
Searching...
No Matches
Group.php
Go to the documentation of this file.
1<?php
2
3namespace PlanetTeamSpeak\TeamSpeak3Framework\Node;
4
5use PlanetTeamSpeak\TeamSpeak3Framework\Exception\AdapterException;
6use PlanetTeamSpeak\TeamSpeak3Framework\Exception\HelperException;
7use PlanetTeamSpeak\TeamSpeak3Framework\Exception\ServerQueryException;
8use PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper;
9use PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3;
10
11abstract class Group extends Node
12{
21 public function message(string $msg): void
22 {
23 foreach ($this as $client) {
24 try {
25 $this->execute("sendtextmessage", ["msg" => $msg, "target" => $client, "targetmode" => TeamSpeak3::TEXTMSG_CLIENT]);
26 } catch (ServerQueryException $e) {
27 /* ERROR_client_invalid_id */
28 if ($e->getCode() != 0x0200) {
29 throw $e;
30 }
31 }
32 }
33 }
34
43 public function iconDownload()
44 {
45 $iconid = $this['iconid'];
46 if (!is_int($iconid)) {
47 $iconid = $iconid->toInt();
48 }
49
50 if ($this->iconIsLocal("iconid") || $iconid == 0) {
51 return;
52 }
53
54 $download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("iconid"));
55 $transfer = TeamSpeak3::factory("filetransfer://" . (str_contains($download["host"], ":") ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
56
57 return $transfer->download($download["ftkey"], $download["size"]);
58 }
59
65 public function getSymbol(): string
66 {
67 return "%";
68 }
69
75 public function __toString()
76 {
77 return (string)$this["name"];
78 }
79}
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery objects.