roesten/rocketchat

package to send messages in rocket chat channels

v0.2.0 2024-02-14 17:44 UTC

This package is auto-updated.

Last update: 2024-09-14 19:25:58 UTC


README

It is a simple package for sending messages using rocket chat channels. This is very simple and without many dependencies.

How to install

composer require roestreich/rocketchatchannel

How to use

Create a new instance of Message

$message = new Message();
$message->setImportant(false);
$message->setSuccess(false);
#name channel
$message->setChannel('test');
$message->setText(Markdown::table(['Country','City'],['Spain','Madri']));

Create a new instance of RocketChat

$clientRocketChat = new RocketChat('https://rocketchat.com.br/api/v1/','UGS45hIeD29u0SYmwAdVmdF7cNbOd0ydg4487S9zgw5','SJSGHJLKlhdds');
$clientRocketChat->sendMessage($message);

And is it very simple!

Message types

Bold

$message->setText(Markdown::bold('Spain'));

Result Bold

Spain

Headings h1 > h6

$message->setText(Markdown::headings('Spain',1));
$message->setText(Markdown::headings('Spain',2));
$message->setText(Markdown::headings('Spain',3));
$message->setText(Markdown::headings('Spain',4));
$message->setText(Markdown::headings('Spain',5));
$message->setText(Markdown::headings('Spain',6));

Result Headings

Spain

Spain

Spain

Spain

Spain

Spain

List

$message->setText(Markdown::listItem(['Spain','Portugal','France']));

Result List

  • Spain
  • Portugal
  • France

Code Block

The second argument is optional and default is sh, but have many options for syntax highlighting code some examples: 'js','php','ruby'

$message->setText(Markdown::codeBlock('npm install --production
NODE_ENV=production node app','js'));

Result Code Block

npm install --production
NODE_ENV=production node app

Table

$message->setText(Markdown::table(['Country','City'],['Spain','Madri']));

Result Table