Skip to content

jwenzler/Shooker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Shooker - Slack WebHooks made crazy simple

Incoming & Outgoing Webhooks are now supported!

Setup on Slack

Incoming

Navigate to https://TEAMNAME.slack.com/services/new and choose to add a new incoming WebHook.

You only really need the Webhook URL but feel free to adjust the default username and image.

Outgoing

alt example

Navigate to https://TEAMNAME.slack.com/services/new and choose to add a new outgoing WebHook.

For this page note the following fields:

  • Channel: You can use any or select a specific channel. The benefit of choosing a channel is that you will not have to specify trigger words in the next field.
  • Trigger Word(s): If you chose a specific channel, you can skip this setup, otherwise place all words you plan on using for triggers in this field with commas separating them.
  • URL(s): Place the location of the PHP file you are going to include Shooker on here.
  • Token: Note this value because you will need to add it within the class initialization.
  • Descriptive Label: Optional and only used to provide context within Slack integrations list.
  • Customize Name: Use whatever name you want to display within the Slack client along with your responses from PHP.
  • Customize Icon: Again, whatever you want here.

Setup within PHP

Just include the main class file and then set up Shooker like so:

Incoming

```php //Initialize class with the token from Slack $shkr = new Shooker();

$shkr->setupIncoming('');

//Send a message (message, username, emoji) $shkr->sendMessage("Your message here", "Mr. Bot", ":ballot_box_with_check:");


<h4>Outgoing</h4>
```php
//Initialize class with the token from Slack
$shkr = new Shooker();

$shkr->setupOutgoing('<YOUR TOKEN HERE>');

//Add a trigger based on keyword "test"
$testTrigger = $shkr->addTrigger("test");

//When this trigger is hit, perform this function
$testTrigger->addAction(function($paramString, $user, $channel){
return "params: ".$paramString." user: ".$user." channel: ".$channel;
});

//This function is required to listen for triggers within Slack client, make sure to call after all triggers are added
$shkr->listen();

Examples

More examples here with source code »

THAT'S IT!

About

Slack WebHooks PHP Class

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages