botman / driver-slack

BotMan Slack Driver
MIT License
51 stars 54 forks source link

Add support for reactions #65

Open iNilo opened 3 years ago

iNilo commented 3 years ago

I'd love to reply to a message / command, not by text, but by reaction.

I'm trying to look into this myself, but I'm not experienced enough yet

eg:

$botman->hears('wave', function (BotMan $bot)
{
       $bot->replyWithReaction("thumbsup");
});

https://api.slack.com/methods/reactions.add

I suppose it would need to be added here https://github.com/botman/driver-slack/blob/a832671a0bc2a42b083ebaea60ea7a4efee96045/src/SlackDriver.php#L258

iNilo commented 3 years ago

For those stumbling across this issue:

Currently I'm achieving this with a 2nd framework

https://github.com/jolicode/slack-php-api

$SlackClient = JoliCode\Slack\ClientFactory::create($SLACK_TOKEN);

$botman->hears('thumbsup', function (BotMan $bot)
{
    global $SlackClient;
    $SlackClient->reactionsAdd(
        [
            'channel' => $bot->getMessage()->getPayload()->get('channel'),
            'name' => 'thumbsup',
            'timestamp' => $bot->getMessage()->getPayload()->get('ts'),
        ]);
});