Skip to content

Latest commit

 

History

History

Channels

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

You have to be logged in and have relevant permissions.

CHANNEL LISTING

$listing = \ATDev\RocketChat\Channels\Channel::listing();

if (!$listing) {

	// Log the error
	$error = \ATDev\RocketChat\Channels\Channel::getError();
}

CREATE CHANNEL

$channel = new \ATDev\RocketChat\Channels\Channel();
$channel->setName("[CHANNEL-NAME-NO-SPACES]");
$channel->setReadOnlyValue(true);

$result = $channel->create();

if (!$result) {
	// Log the error
	$error = $channel->getError();
}

GET CHANNEL INFO

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->info();

if (!$result) {
	// Log the error
	$error = $channel->getError();
}

DELETE CHANNEL

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->delete();

if (!$result) {
	// Log the error
	$error = $channel->getError();
}

OPEN CHANNEL

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->open();

if (!$result) {
	// Log the error
	$error = $channel->getError();
}

CLOSE CHANNEL

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->close();

if (!$result) {
	// Log the error
	$error = $channel->getError();
}

INVITE USER TO CHANNEL

$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->invite($user);

if (!$result) {
	// Log the error
	$error = $channel->getError();
}

KICK USER OUT OF CHANNEL

$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->kick($user);

if (!$result) {
	// Log the error
	$error = $channel->getError();
}

ADD OWNER TO CHANNEL

$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->addOwner($user);

if (!$result) {
	// Log the error
	$error = $channel->getError();
}

REMOVE OWNER OUT OF CHANNEL

$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->removeOwner($user);

if (!$result) {
	// Log the error
	$error = $channel->getError();
}

LISTS ALL THE CHANNEL MESSAGES ON THE SERVER

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$result = $channel->messages();

if (!$result) {
    // Log the error
    $error = $channel->getError();
}

CHANNEL ADD ALL

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$result = $channel->addAll(true);

if (!$result) {
    $error = $channel->getError();
}

CHANNEL ADD LEADER

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$result = $channel->addLeader($user);

if (!$result) {
    $error = $channel->getError();
}

CHANNEL REMOVE LEADER

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$result = $channel->removeLeader($user);

if (!$result) {
    $error = $channel->getError();
}

CHANNEL ADD MODERATOR

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$result = $channel->addModerator($user);

if (!$result) {
    $error = $channel->getError();
}

CHANNEL REMOVE MODERATOR

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$result = $channel->removeModerator($user);

if (!$result) {
    $error = $channel->getError();
}

CHANNEL MODERATORS LIST

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->moderators();
if (!$result) {
	$error = $channel->getError();
}

CHANNEL JOIN

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->join("[JOIN CODE]");
if (!$result) {
	$error = $channel->getError();
}

CHANNEL LEAVE

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->leave();
if (!$result) {
	$error = $channel->getError();
}

CHANNEL LIST JOINED

$list = \ATDev\RocketChat\Channels\Channel::listJoined();

if (!$list) {
    $error = \ATDev\RocketChat\Channels\Channel::getError();
}

CHANNEL MEMBERS LIST

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->members();
if (!$result) {
	$error = $channel->getError();
}

CHANNEL COUNTERS

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->counters();
if (!$result) {
	$error = $channel->getError();
}

CHANNEL ONLINE

// Get online users of all channels
$result = \ATDev\RocketChat\Channels\Channel::onlineAll();
if (!$result) {
	$error = \ATDev\RocketChat\Channels\Channel::getError();
}

// Or get online users of particular channel
$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->online();
if (!$result) {
	$error = $channel->getError();
}

CHANNEL ANONYMOUS READ

// Identify channel by id
$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
// or by name
$channel = new \ATDev\RocketChat\Channels\Channel();
$channel->setName("[CHANNEL-NAME]");
$result = $channel->anonymousRead();

if (!$result) {
    $error = $channel->getError();
}

CHANNEL ARCHIVE

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->archive();
if (!$result) {
    $error = $channel->getError();
}

CHANNEL UNARCHIVE

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->unarchive();
if (!$result) {
    $error = $channel->getError();
}

CHANNEL RENAME

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->rename("[NEW-CHANNEL-NAME]");
if (!$result) {
    $error = $channel->getError();
}

CHANNEL SET DEFAULT

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$result = $channel->setDefault(true);
if (!$result) {
    $error = $channel->getError();
}

CHANNEL SET JOIN CODE

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$result = $channel->setJoinCode("[JOIN-CODE]");
if (!$result) {
    $error = $channel->getError();
}

CHANNEL SET DESCRIPTION

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$result = $channel->setDescription("[CHANNEL DESCRIPTION]");
if (!$result) {
    $error = $channel->getError();
}

CHANNEL SET ANNOUNCEMENT

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$result = $channel->setAnnouncement("[CHANNEL ANNOUNCEMENT]");
if (!$result) {
    $error = $channel->getError();
}

CHANNEL SET CUSTOM FIELDS

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$result = $channel->setCustomFields(["CUSTOM-FIELD" => "VALUE"]);
if (!$result) {
    $error = $channel->getError();
}

CHANNEL SET READ ONLY

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$result = $channel->setReadOnly(true);
if (!$result) {
    $error = $channel->getError();
}

CHANNEL SET TOPIC

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");
$result = $channel->setTopic("[NEW CHANNEL TOPIC]");
if (!$result) {
    $error = $channel->getError();
}

CHANNEL SET TYPE

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->setType("c");
if (!$result) {
    $error = $channel->getError();
}

GET ALL THE MENTIONS OF A CHANNEL

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->getAllUserMentionsByChannel(5, 10);
if (!$result) {
    $error = $channel->getError();
}

CHANNEL ROLES

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$roles = $channel->roles();
if (!$roles) {
	$error = $channel->getError();
} else {
    $roles->first()->getRoles();
}

CHANNEL HISTORY

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->history([
    "latest" => "2016-09-30T13:42:25.304Z",
    "oldest" => "2016-05-30T13:42:25.304Z",
    "inclusive" => true,
    "unreads" => true
]);
if (!$result) {
	$error = $channel->getError();
}

CHANNEL FILES

$channel = new \ATDev\RocketChat\Channels\Channel("[CHANNEL ID]");

$result = $channel->files(10, 20);
if (!$result) {
	$error = $channel->getError();
}