Enable sending ephemeral messages to Slack

This commit is contained in:
Deon George 2022-09-02 17:39:49 +10:00
parent 80c1768534
commit e9a4eae7d1

View File

@ -33,6 +33,7 @@ final class API
private const scopes = [ private const scopes = [
'auth.test'=>'', // No scope required 'auth.test'=>'', // No scope required
'chat.delete'=>'chat:write', 'chat.delete'=>'chat:write',
'chat.postEphemeral'=>'chat:write',
'chat.postMessage'=>'chat:write', 'chat.postMessage'=>'chat:write',
'chat.update'=>'chat:write', 'chat.update'=>'chat:write',
'conversations.history'=>'channels:history', // Also need groups:history for Private Channels and im:history for messages to the bot. 'conversations.history'=>'channels:history', // Also need groups:history for Private Channels and im:history for messages to the bot.
@ -216,6 +217,20 @@ final class API
return new Generic($this->execute('pins.add',json_encode(['channel'=>$channel,'timestamp'=>$timestamp]))); return new Generic($this->execute('pins.add',json_encode(['channel'=>$channel,'timestamp'=>$timestamp])));
} }
/**
* Post a Slack Message to a user as an ephemeral message
*
* @param Message $request
* @return Generic
* @throws \Exception
*/
public function postEphemeral(Message $request): Generic
{
Log::debug(sprintf('%s:Post a Slack Ephemeral Message',static::LOGKEY),['m'=>__METHOD__,'r'=>$request]);
return new Generic($this->execute('chat.postEphemeral',json_encode($request)));
}
/** /**
* Post a Slack Message * Post a Slack Message
* *