Code Monkey home page Code Monkey logo

php-slack-bot's People

Contributors

bomoko avatar br0ken- avatar bryangruneberg avatar djdevin avatar jclg avatar lira92 avatar medliii avatar mrbase avatar schnabear avatar vaibhav-kaushal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-slack-bot's Issues

Case-insensitive command

Current implemenation of Command is case-sensitive. E.g. if I register a command help, I should send exact command help, but not Help or HELP. It's unusual.

So, why don't make it case-insensitive by adding modifier i inside getCommand method?

This
$find = '/^'.preg_quote($commandName).'/';
Change to this
$find = '/^'.preg_quote($commandName).'/i';

Direct message when command run in public channel

Hi,

I've been playing around with php-slack-bot and I like it so far. However, I have a question I would like to ask : is there any way to respond to a user running a command in a public channel by direct message ?

Thanks,

David

Bot is not working

I have been trying to debug but got no results. Bot is successfully getting wsurl but I think it is not connecting to the wsurl (No log indicating it has connected), also it does not respond to any command. Also the php script terminates after around 30 seconds of run time. What might be the problem ?

Minimum stability

Installing of this package requires setting minimum stability to "dev". This is not good idea if you package is stable enough. This setting is global. But I don't want any other packages to be installed with dev-stability level. It should be better if you require dev package as following:

    "require": {
        "devristo/phpws": "dev-master@dev",
        "react/http": "^0.4"
    },

This will not require global minimum stability set to "dev".

Sending links

In theory, I should be able to send links using the format <http://example.com|Name of site> which is supposed to turn into a hyperlink with my chosen text to the provided URL. (See https://api.slack.com/docs/message-formatting - which is linked from the RTM API docs page under "formatting messages".)

In practice, this is displaying exactly as is. It seems that the string is getting encoded somewhere (e.g. < becomes &lt;), but I can't for the life of me find what's doing this in your source. Any tips on tracking this down and/or bypassing it?

Only respond to mentions?

Is there a way to get the bot to only run commands when mentioned? Is adding the bots username to the command name enough?

ie instead of just typing doThing in slack I want to have to type @mybot doThing

Bot not joining

C:\xampp\htdocs\slackbot>php example1.php 2016-07-27T17:13:47+02:00 NOTICE (5): Request object created! 2016-07-27T17:13:47+02:00 NOTICE (5): Handshake received! 2016-07-27T17:13:47+02:00 NOTICE (5): Connected! 2016-07-27T17:13:48+02:00 NOTICE (5): Got message: {"type":"hello"} 2016-07-27T17:13:48+02:00 NOTICE (5): Got message: {"type":"reconnect_url","url":"wss://mpmulti-uh6j.slack-msgs.com/websocket/<removed>="} 2016-07-27T17:13:48+02:00 NOTICE (5): Got message: {"type":"presence_change","presence":"active","user":"U1XXXXX"} 2016-07-27T17:14:00+02:00 NOTICE (5): Got message: {"type":"reconnect_url","url":"wss://mpmulti-9bvx.slack-msgs.com/websocket/<removed>="}

Issue:

Bot not joining default channel #general, can't interact with him. Also, in https://my.slack.com/services/new/bot:
http://i.imgur.com/nfVwaGU.png

rtm.start Deprecation

Slack has sent out a recent deprecation notice for rtm.start - The timeline is;

November 30, 2021 - New Slack apps and integrations will no longer be able to use rtm.start and must use rtm.connect instead.

September 20, 2022 - The response from rtm.start will transform into the brief response found in the method that replaces it, rtm.connect.

Fallback command

Hello,

Not an issue but a addition I made. This is a fallback command that will be executed when no command is found. Sort of like a catch-all command, but loaded commands will be executed first. I don't know much how this pull request thing work so here it is, as a patch file for Bot.php :

14d13
<     private $fallBackCommand = null;
38,46d36
<     public function loadFallBackCommand($command) {
<         if ($command instanceof Command\BaseCommand) {
<             $this->fallBackCommand = $command;
<         }
<         else {
<             throw new \Exception('Command must implement PhpSlackBot\Command\BaseCommand');
<         }
<     }
<
205,207d194
<                 }
<                 if (null !== $this->fallBackCommand) {
<                     return $this->fallBackCommand;

Usage :

require 'vendor/autoload.php';
use PhpSlackBot\Bot;

// This special command executes when no command is found
class FallBackCommand extends \PhpSlackBot\Command\BaseCommand {

    protected function configure() {
        // We don't have to configure a command name in this case
    }

    protected function execute($data, $context) {
        if ($data['type'] == 'message') {
            $channel = $this->getChannelNameFromChannelId($data['channel']);
            $username = $this->getUserNameFromUserId($data['user']);
            echo $username.' from '.($channel ? $channel : 'DIRECT MESSAGE').' : '.$data['text'].PHP_EOL;
        }
    }

}

$bot = new Bot();
$bot->setToken('TOKEN'); // Get your token here https://my.slack.com/services/new/bot
$bot->loadFallBackAllCommand(new FallBackCommand());
$bot->run();

Hopefully there will be no bug in this code...

instruct bot to leave channel

Hi, could you include a way of instructing the bot to leave a particular channel.

(when i started the bot it joined a channel wich i did not want it to join ... )

Regards.

Sam

not show user command

@jclg, Is there any way to not show the user's command? For example, in planing poker the vote is not interesting to show to everyone in the group.

Bot sending text to a specific channel

I was wondering if the bot is able to send to a channel without any user command. For example the within my application something happens, I want the bot to post some data.

How to use the library

Hello @jclg

I have installed this library into my application (using composer) but I do not know where to go now! I have replaced the token given to me by Slack (a bot token). I am not sure how to make the app listen for incoming connections.

Sorry if that sounds like a newbie question.

Bot loses connection to Slack

The bot loses connection sometimes and does nothing with it. In slack chat (web-)application slackbot user just become with gray circle (offline). But the script continues to run, need to be killed and restarted. Isn't there a way to force the bot to check is connection alive and throw an exception if not?

The code (excepting code of commands and config):

<?php

require __DIR__ . '/vendor/autoload.php';

use PhpSlackBot\Bot;
use SlackBot\Commands\AlphaLockCommand;
use SlackBot\Commands\AlphaShipmentCommand;
use SlackBot\Commands\GetItemQtyCommand;
use SlackBot\Commands\StatusCommand;

$config = require __DIR__ . '/config.php';

$bot = new Bot();
$bot->setToken($config['slackbot']['token']);
try {
    $bot->loadCommand(new StatusCommand());
    $bot->loadCommand(new GetItemQtyCommand());
    $bot->loadCommand(new AlphaLockCommand());
    $bot->loadCommand(new AlphaShipmentCommand());
    $bot->run();
} catch (\Exception $e) {
    echo $e->getMessage(), "\n";
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.