2021-08-06 12:22:22 +10:00
< ? php
namespace Slack\Options ;
use Illuminate\Support\Facades\Log ;
2022-08-23 17:48:09 +10:00
2021-08-06 12:22:22 +10:00
use Slack\Message ;
/**
* Class InteractiveMessage
*
* [ name ] => source
* [ value ] =>
* [ callback_id ] => classify | 46
* [ type ] => interactive_message
* [ team ] => stdClass Object
* (
* [ id ] => { SLACKTEAM }
* [ domain ] => { SLACKDOMAIN }
* )
* [ channel ] => stdClass Object
* (
* [ id ] => { SLACKCHANNEL }
* [ name ] => directmessage
* )
* [ user ] => stdClass Object
* (
* [ id ] => { SLACKUSER }
* [ name ] => { SLACKUSER }
* )
* [ action_ts ] => 1603780652.484943
* [ message_ts ] => 1601349865.001500
* [ attachment_id ] => 3
* [ token ] => Oow8S2EFvrZoS9z8N4nwf9Jo
*/
class InteractiveMessage extends Base
{
2022-02-24 12:27:36 +11:00
protected const LOGKEY = 'OIM' ;
2021-08-06 12:22:22 +10:00
public function __get ( $key )
{
switch ( $key ) {
case 'name' :
case 'value' :
case 'message_ts' :
return object_get ( $this -> _data , $key );
default :
return parent :: __get ( $key );
}
}
/**
* Interactive messages can return their output in the incoming HTTP post
*
* @ return Message
* @ throws \Exception
*/
public function respond () : Message
{
Log :: info ( sprintf ( '%s:Interactive Option - Callback [%s] Name [%s] Value [%s]' , static :: LOGKEY , $this -> callback_id , $this -> name , $this -> value ),[ 'm' => __METHOD__ ]);
if ( preg_match ( '/^(.*)\|([0-9]+)/' , $this -> callback_id )) {
[ $action , $id ] = explode ( '|' , $this -> callback_id , 2 );
} else {
// If we get here, its an action that we dont know about.
Log :: notice ( sprintf ( '%s:Unhandled CALLBACK [%s]' , static :: LOGKEY , $this -> callback_id ),[ 'm' => __METHOD__ ]);
}
return ( new Message ) -> blank ();
}
2022-02-24 12:27:36 +11:00
}