Blake Enloe
03/29/2019, 4:27 PMzach_calh
03/29/2019, 4:32 PMzach_calh
03/29/2019, 4:32 PMmatt.graney
03/29/2019, 4:34 PMBlake Enloe
03/29/2019, 4:41 PMzach_calh
03/29/2019, 4:44 PMzach_calh
03/29/2019, 4:45 PMzach_calh
03/29/2019, 4:45 PMzach_calh
03/29/2019, 4:46 PMBlake Enloe
03/29/2019, 4:57 PMZack
03/29/2019, 5:09 PMjen
03/29/2019, 8:50 PMjen
03/29/2019, 8:53 PMslackAttack()
. This action sends a request to a PHP script on my server, which handles sending a message to the Slack channel.jen
03/29/2019, 8:54 PMfunction slackAttack() {
// Build the post message.
var tx = context.newRecord;
var tran = tx.getValue({fieldId: 'tranid'});
// Who?
var user = runtime.getCurrentUser();
var message = user.name + ' viewed the transaction ' + tran;
log.debug({title: '', details: message});
// ID of the Slack channel to send to.
var channel = 'asdfasdf';
// URL of the PHP script on my server.
var slack_url = '<https://path.to.my/slackhandler.php>';
var request_data = {
url: slack_url,
method: 'POST',
data: {message: message, channel: channel }
};
var req = <http://https.post|https.post>({
url: slack_url,
body: {type: 'slackattack', message: message, channel: channel }
});
log.debug({title:'Resp', details:req.body});
}
jen
03/29/2019, 8:55 PM/* slackhandler.php */
// What's the message?
$message = $_POST['message'];
// What channel is it going to?
$channel = $_POST['channel'];
// Your bot's token generated through the Slack Developer Console.
$user_token = SLACK_OATH_TOKEN_BOT;
// Name of your Slackbot.
$slackbot = 'My SlackBot';
// Send the message to the channel.
$ch = curl_init('<https://slack.com/api/chat.postMessage>');
$data = http_build_query([
'token'=>$user_token,
'channel'=>$channel,
'text'=>$message,
'username'=>slackbot
]);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
Blake Enloe
03/29/2019, 9:25 PMjen
03/29/2019, 9:28 PMjen
03/29/2019, 9:28 PM