Download the PHP package jclg/php-slack-bot without Composer

On this page you can find all versions of the php package jclg/php-slack-bot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-slack-bot

PHP Slack Bot

A simple bot user written in PHP using the Slack Real Time Messaging API https://api.slack.com/rtm

Installation

With Composer

composer require jclg/php-slack-bot

Usage

Create a php file called bot.php with the following content

Then run php bot.php from the command line (terminal).

Example commands

Example commands are located in src/PhpSlackBot/Command/ and can be loaded with $bot->loadInternalCommands();

Ping Pong Command

Type ping in a channel and the bot should answer "Pong" to you.

Count Command

Type count several times in a channel and the bot should answer with 1 then 2...

Date Command

Type date in a channel and the current date.

Planning Poker Command

https://en.wikipedia.org/wiki/Planning_poker

Type pokerp start in a public channel with your team in order to start a planning poker session.

Direct message the bot with pokerp vote number. The bot will record your vote.

Type pokerp status to see the current status of the session (who has voted).

Type pokerp end in a public channel and the bot will output each vote.

Load your own commands

You can load your own commands by implementing the \PhpSlackBot\Command\BaseCommand.

Then call PhpSlackBot\Bot::loadCommand method for each command you have to load.

"Catch All" command

If you need to execute a command when an event occurs, you can set up a "catch all" command.

This special command will be triggered on all events.

Incoming webhooks

The bot can also listen for incoming webhooks.

Commands are triggered from users messages inside Slack and webhooks are triggered from web post requests.

Custom webhooks can be loaded using the PhpSlackBot\Bot::loadWebhook method.

This is useful if you need to control the bot from an external service. For example, with IFTTT https://ifttt.com/maker

To enable webhooks, use the enableWebserver method before the run method.

You can also set a secret token to prevent unauthorized requests.

Then, use the parameter "name" to trigger the corresponding webhook :

Active Messaging

The example provided in the usage section above sets the bot to be reactive. The reactive bot is not capable of sending messages to any user on its own. It must be given an input to get a response from. In other words, the bot can only react to inputs given to it.

Active Messaging means that as a developer, you would be able to send messages to your users without them sending a message to the bot first. It is useful when you have to notify your users about something e.g. a bot which can check a user's birthday and wish them, or tell them weather outside every 2 hours without them having to type in a command everytime. There can be many other uses.

You can use active messaging this way:

In the example above, we have set two active messages.

First message will send the following message in the '#general' channel:

It will be triggered only once, 10 seconds after launching the script. Slack servers normally establish the connection by then.

Second message is a periodic message. It will be sent to the user having the username slacker in the team. It won't mention anyone and will be repeated every 30 minutes (1800 seconds). The message should appear as:

That should happen within 1 hour of launching.

NOTE: The first message would appear 30 minutes after launching.

The function you add using loadPushNotifier must return an array containing the following keys:


All versions of php-slack-bot with dependencies

PHP Build Version
Package Version
Requires semako/phpws Version 1.0.1
react/http Version ^0.4
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jclg/php-slack-bot contains the following files

Loading the files please wait ....