-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack.rules.inc
50 lines (47 loc) · 1.28 KB
/
slack.rules.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* @file
* Slack integration module rules functions.
*/
/**
* Implements hook_rules_action_info().
*/
function slack_rules_action_info() {
$actions = array();
$actions['slack_send_message'] = array(
'base' => 'slack_rules_send_message_action',
'label' => t('Slack send message'),
'group' => t('Slack'),
'parameter' => array(
'message' => array(
'type' => 'text',
'label' => t('Sending message'),
),
'channel' => array(
'type' => 'text',
'label' => t('Channel'),
'description' => t("It will be using a channel from slack module settings, if you don't enter channel here."),
'optional' => TRUE,
),
'username' => array(
'type' => 'text',
'label' => t('Username'),
'description' => t("It will be using a username from slack module settings, if you don't enter username here."),
'optional' => TRUE,
),
),
);
return $actions;
}
/**
* Rules action for sending a message to the Slack.
*/
function slack_rules_send_message_action($message, $channel, $username) {
if (!$channel) {
$channel = slack_get_default_channel();
}
if (!$username) {
$username = slack_get_default_username();
}
slack_send_message($message, $channel, $username);
}