Giter VIP home page Giter VIP logo

slack-client's People

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  avatar  avatar  avatar  avatar  avatar  avatar

slack-client's Issues

Switching to Icicle

Switch from React PHP to Icicle, which is so much easier to work with and so much cooler. Icicle should have a usable websocket package soon, which will be much more actively maintained and less buggy than PHPWS., which was a less-than-ideal dependency anyway.

This will be a major change, and will be bundled with other changes toward a v1.0 release. All React-related code will be removed and replaced with Icicle. Guzzle may also be removed in favor of icicleio/http. A name change may also be involved.

Shameless plug: I'm a member of the Icicle team. ๐Ÿ˜€

Php 7 - React TimeoutException

Hi all,
I'm sorry to bother but seems no one have my problem with PHP7.

With PHP 5.6 all good, but after my update to PHP 7,
I started to receive a React Timeout Error.
I can copy and paste the issue, but I don't know how much could be useful.

React\Promise\Timer\TimeoutException: Timed out after 5 seconds in...
#0 [internal function]: React\Promise\Timer{closure}(Object(React\EventLoop\Timer\Timer))
Next React\Dns\Query\TimeoutException: DNS query for mpmulti-dgb1.slack-msgs.com timed out in...

All my composer library has been updated to the latest version, and honestly I don't know what to do.

Anyone can help me please?
Thank you so much.

Regards

Cant send a message with an attachment

No mater what i have tried i just cant get this lib to send messages with attachments, some sort of explanation or sample code could be extremely helpfull

Refresh Channel (and other) contents

I actually noticed this while using https://github.com/chrisgillis/slackwolf which has slack-client as a dependency. It'd be nice if there was a way to 'refresh' the data for an object; in this particular case I'd like to re-get the list of users in a channel, but I imagine being able to refresh most things would be nice. As it is now I can only force a disconnect and then re-connect, which repopulates all the objects with new data.

I see the actual API calls to fetch the data required are in ApiClient, but they're hidden away behind implementations of Channel and whatnot.

How does the looping functionality work?

I see that there is a loop, is it based off of when a user sends a message in the channel? I'd like to have a function ran when someone inputs a message. Right now, I'm using JS to refresh the div and send a request every minute or so.

How do I initialize a user?

I've tried multiple different things, like:
$user = new User($client, $data['user']);
but I can't get them to work.

EDIT: the error I receive:
Slack\ClientObject::__construct() must be of the type array, string given

Sending a message to a private channel the bot is in doesn't not work

class Slack\Payload#287 (1) {
protected $data =>
array(6) {
'type' =>
string(7) "message"
'channel' =>
string(9) "G0GNUPNRX"
'user' =>
string(9) "U1"
'text' =>
string(6) "!start"
'ts' =>
string(17) "1450242920.000008"
'team' =>
string(9) "T1"
}
}
PHP Notice: Undefined index: G0GNUPNRX in /Users/chris/slackwolf/vendor/coderstephen/slack-client/src/RealTimeClient.php on line 170

Client not doing anything

I am running the latest version of slack-client (installed via composer) and I set up the simple test:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

$loop = React\EventLoop\Factory::create();

$client = new Slack\RealTimeClient($loop);
$client->setToken('xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');

// disconnect after first message
$client->on('message', function ($data) {
    echo "Someone typed a message: ".$data['text']."\n";
    $client->disconnect();
});

$client->connect()->then(function () {
    echo "Connected!\n";
});

$client->on('hello', function() {
    echo "EHLO\n";
}

$loop->addPeriodicTimer(1, function() {
    echo "Tick\n";
});

$loop->run();

I am only getting the tick output when I run the script. Any ideas?

PHP 7 RealTimeClient connection issue

Hi,

Lib been working really well in PHP5. Gave my app a go on PHP 7 today but couldn't get it to work. As far as I can tell everything is the same, except the PHP version, has anyone else had success running the RealTimeClient in PHP7?

The WebSocket appears to be connecting, but nothing happens after that. Waiting for ->on('hello') or ->on('error') nothing happens. Eventually the react loop seems to stop and the script exits.

Will try to debug further, but not had much luck pinpointing it so far. Throwing this out there in case anyone has any suggestions?

Implement ping/pong

Are you planning to implement ping/pong messages to the slack api such that the client can monitor its connection and reconnect when it is dropped?
I'm having some issues with my connection and it looks like the client stays active after a connection drop, but it is dropped from slack's point of view.
A similar sollution worked in another slack-bot project

Websocket produces duplicate messages

Hi there, I believe this is a bug with the websocket package and not your package directly, but every event comes in twice (with the same payload) which causes everything to be triggered twice:

object(Devristo\Phpws\Messaging\WebSocketMessage)#53 (2) {
  ["frames":protected]=>
  array(1) {
    [0]=>
    object(Devristo\Phpws\Framing\WebSocketFrame)#2094 (10) {
      ["FIN":protected]=>
      int(1)
      ["RSV1":protected]=>
      int(0)
      ["RSV2":protected]=>
      int(0)
      ["RSV3":protected]=>
      int(0)
      ["opcode":protected]=>
      int(1)
      ["mask":protected]=>
      int(0)
      ["payloadLength":protected]=>
      int(63)
      ["maskingKey":protected]=>
      int(0)
      ["payloadData":protected]=>
      string(63) "{"type":"user_typing","channel":"D214XLEJG","user":"U096BVDUM"}"
      ["actualLength":protected]=>
      int(0)
    }
  }
  ["data":protected]=>
  string(0) ""
}
object(Devristo\Phpws\Messaging\WebSocketMessage)#53 (2) {
  ["frames":protected]=>
  array(1) {
    [0]=>
    object(Devristo\Phpws\Framing\WebSocketFrame)#2094 (10) {
      ["FIN":protected]=>
      int(1)
      ["RSV1":protected]=>
      int(0)
      ["RSV2":protected]=>
      int(0)
      ["RSV3":protected]=>
      int(0)
      ["opcode":protected]=>
      int(1)
      ["mask":protected]=>
      int(0)
      ["payloadLength":protected]=>
      int(63)
      ["maskingKey":protected]=>
      int(0)
      ["payloadData":protected]=>
      string(63) "{"type":"user_typing","channel":"D214XLEJG","user":"U096BVDUM"}"
      ["actualLength":protected]=>
      int(0)
    }
  }
  ["data":protected]=>
  string(0) ""
}
object(Devristo\Phpws\Messaging\WebSocketMessage)#53 (2) {
  ["frames":protected]=>
  array(1) {
    [0]=>
    object(Devristo\Phpws\Framing\WebSocketFrame)#2094 (10) {
      ["FIN":protected]=>
      int(1)
      ["RSV1":protected]=>
      int(0)
      ["RSV2":protected]=>
      int(0)
      ["RSV3":protected]=>
      int(0)
      ["opcode":protected]=>
      int(1)
      ["mask":protected]=>
      int(0)
      ["payloadLength":protected]=>
      int(116)
      ["maskingKey":protected]=>
      int(0)
      ["payloadData":protected]=>
      string(116) "{"type":"message","channel":"D214XLEJG","user":"U096BVDUM","text":"Hey","ts":"1488026184.000017","team":"T02TZ7DQW"}"
      ["actualLength":protected]=>
      int(0)
    }
  }
  ["data":protected]=>
  string(0) ""
}
object(Devristo\Phpws\Messaging\WebSocketMessage)#53 (2) {
  ["frames":protected]=>
  array(1) {
    [0]=>
    object(Devristo\Phpws\Framing\WebSocketFrame)#2094 (10) {
      ["FIN":protected]=>
      int(1)
      ["RSV1":protected]=>
      int(0)
      ["RSV2":protected]=>
      int(0)
      ["RSV3":protected]=>
      int(0)
      ["opcode":protected]=>
      int(1)
      ["mask":protected]=>
      int(0)
      ["payloadLength":protected]=>
      int(116)
      ["maskingKey":protected]=>
      int(0)
      ["payloadData":protected]=>
      string(116) "{"type":"message","channel":"D214XLEJG","user":"U096BVDUM","text":"Hey","ts":"1488026184.000017","team":"T02TZ7DQW"}"
      ["actualLength":protected]=>
      int(0)
    }
  }
  ["data":protected]=>
  string(0) ""
}

The only way I've been able to mitigate this is to do something like:

$messages = [];

$client->on('message', function ($data) use (&$messages) {
    $dataArray = $data->jsonSerialize();

    if ($key = array_search($dataArray, $messages, true))
    {
        unset($key);
        return;
    }
    $messages[] = $data;

Enabling markdown?

This might just be something I misunderstood, but I made a message with an attachment like the following, but I just can't seem to get markdown enabled. I tried adding the mrkdown_in to the attachment fields (https://api.slack.com/docs/message-formatting), but I haven't gotten it to work yet.

    $message = $client->getMessageBuilder()
        ->setText('Ordinary text')
        ->setChannel($channel)
        ->addAttachment(new Attachment('This is my attachment:', 'This *is* _my_ text', "#BADA55", "Pretext with *bold* word", ['mrkdown_in' => ['text', 'pretext', 'fields']]))
        ->create();

The markdown is never parsed, when it get's into the channel.

getAuthedUser() not working properly

Hi there, great Slack client, thanks!

There seems to be an issue

$client->getAuthedUser()->done(function ($user) {
//something
});

where $client is the RealTimeClient. It outputs the notice: PHP Notice: Undefined index: XXXXXXX in /vagrant/dev/slack/vendor/coderstephen/slack-client/src/RealTimeClient.php on line 218

and $user is null.

Or am I using this incorrectly?

Random websocket connection closed errors

I am running a Python script in a Windows server machine to use the Slack RTM API to listen on new incoming messages addressed to a bot. Based on the message, I write back to the Slack channel where the question was asked.

Unfortunately, the websocket used by RTM API is randomly getting closed, forcing me to come up with a workaround where I have to call slack_client.rtm_connect() in my except block to re-connect.

This is causing two issues:

  1. I don't see a reason why the websocket is getting closed
  2. After reconnecting multiple times, the Python script stops listening to messages directed to my bot, forcing me to restart the Python script manually.

Attached is the excerpt from my Python script.

Please let me know if this is a known bug or have a better to handle this type of websocket error.

Thank you in advance for your reply.
Bastien

Can't create channel as app bot

I'm trying to create channel using Bot User OAuth Access Token.
I've selected all Permission Scopes for the bot, but always get this exception:

exception 'Slack\ApiException' with message 'Missing scope' in /storage/www/redminetoslack/vendor/coderstephen/slack-client/src/ApiClient.php:415

Stack trace:

#0 /storage/www/redminetoslack/vendor/guzzlehttp/promises/src/Promise.php(203): Slack\ApiClient->Slack\{closure}(Object(GuzzleHttp\Psr7\Response))
#1 /storage/www/redminetoslack/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#2 /storage/www/redminetoslack/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#3 /storage/www/redminetoslack/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(96): GuzzleHttp\Promise\TaskQueue->run()
#4 /storage/www/redminetoslack/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(123): GuzzleHttp\Handler\CurlMultiHandler->tick()
#5 /storage/www/redminetoslack/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#6 /storage/www/redminetoslack/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#7 /storage/www/redminetoslack/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#8 /storage/www/redminetoslack/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#9 /storage/www/redminetoslack/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#10 /storage/www/redminetoslack/vendor/coderstephen/slack-client/src/ApiClient.php(397): GuzzleHttp\Promise\Promise->wait()
#11 [internal function]: Slack\ApiClient->Slack\{closure}(Object(React\EventLoop\StreamSelectLoop))
#12 /storage/www/redminetoslack/vendor/react/event-loop/src/Tick/FutureTickQueue.php(46): call_user_func(Object(Closure), Object(React\EventLoop\StreamSelectLoop))
#13 /storage/www/redminetoslack/vendor/react/event-loop/src/StreamSelectLoop.php(175): React\EventLoop\Tick\FutureTickQueue->tick()
#14 /storage/www/redminetoslack/helper.php(335): React\EventLoop\StreamSelectLoop->run()
#15 /storage/www/redminetoslack/helper.php(426): SlackClient->createChannel('issue-14787', 'creating interi...', 'The content for...', Array)
#16 /storage/www/redminetoslack/helper.php(511): RedmineToSlack->checkChannel()
#17 /storage/www/redminetoslack/helper.php(408): RedmineToSlack->processRedmineIssue(Object(stdClass))
#18 /storage/www/redminetoslack/index.php(10): RedmineToSlack->processRedmineIssues()
#19 {main}

Here is my code:
$this->loop = \React\EventLoop\Factory::create();
$this->client = new \Slack\ApiClient($this->loop);
$this->client->setToken($token);
$this->client->apiCall('channels.create', ['name' => $name])->then(function(\Slack\Payload $response) {
$channel = new \Slack\Channel($this->client, $response['channel']);
$this->channels[$channel->getName()] = $channel;
})->otherwise(function($reason) {
echo $reason->__toString().PHP_EOL;
});
$this->loop->run();

I got same if trying to add bot to existing channel.
What I'm doing wrong?

RealTimeClient doesn't work with PHP 5.6 due to SSL/TLS issue

Under PHP version 5.6 or greater, the real-time client refuses to connect to Slack using SSL, throwing various exceptions that look similar to this:

2015-06-04T22:56:25-05:00 ERR (3): exception 'UnexpectedValueException' with message '
    Unable to complete SSL/TLS handshake: stream_socket_enable_crypto():
    Peer certificate CN=`*.slack-msgs.com' did not match expected CN=`<IP_ADDRESS>''
in /data/projects/slack-client/vendor/react/socket-client/src/StreamEncryption.php:96

Sending URLs with getMessageBuilder/postMessage

When using postMessage() and getMessageBuilder to build my messages, formatted text and newlines work fine but when I try linking my strings, it shows as the raw text instead of the linked text.

An example would be

<http://www.google.com|google>

returns as such in the message when it should show as

google

Installation failed

$ composer require coderstephen/slack-client
Using version ^0.2.0 for coderstephen/slack-client
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1

  • Installation request for coderstephen/slack-client ^0.2.0 -> satisfiable by coderstephen/slack->client[v0.2.0].
  • coderstephen/slack-client v0.2.0 requires devristo/phpws dev-master -> no matching package found.

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, deleting ./composer.json.

Error Installing on Ubuntu 14.04

  Problem 1
    - Installation request for coderstephen/slack-client ^0.2.5 -> satisfiable by coderstephen/slack-client[v0.2.5].
    - coderstephen/slack-client v0.2.5 requires devristo/phpws dev-master -> satisfiable by devristo/phpws[dev-master] but these conflict with your requirements or minimum-stability.

Is there a way I can still use this package?

$client->getChannelById() for Private Messages

I'm using example code, and this callback newer works with PM's, only with pubic channels:

$client->on('message', function ($data) use ($client) {
$client->getChannelById($data['channel'])->then(function (\Slack\Channel $channel) use ($client) {
print $channel->getId();

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.