|
|
@@ -20,7 +20,10 @@ module Agents
|
20
|
20
|
Once the webhook has been setup it can be used to post to other channels or ping team members.
|
21
|
21
|
To send a private message to team-mate, assign his username as `@username` to the channel option.
|
22
|
22
|
To communicate with a different webhook on slack, assign your custom webhook name to the webhook option.
|
23
|
|
- Messages can also be formatted using [Liquid](https://github.com/cantino/huginn/wiki/Formatting-Events-using-Liquid)
|
|
23
|
+ Messages can also be formatted using [Liquid](https://github.com/cantino/huginn/wiki/Formatting-Events-using-Liquid).
|
|
24
|
+
|
|
25
|
+ Finally, you can set a custom icon for this webhook in `icon`, either as [emoji](http://unicodey.com/emoji-data/table.htm) or an URL to an image.
|
|
26
|
+ Leaving this field blank will use the default icon for a webhook.
|
24
|
27
|
MD
|
25
|
28
|
|
26
|
29
|
def default_options
|
|
|
@@ -29,6 +32,7 @@ module Agents
|
29
|
32
|
'channel' => '#general',
|
30
|
33
|
'username' => DEFAULT_USERNAME,
|
31
|
34
|
'message' => "Hey there, It's Huginn",
|
|
35
|
+ 'icon' => '',
|
32
|
36
|
}
|
33
|
37
|
end
|
34
|
38
|
|
|
|
@@ -67,7 +71,11 @@ module Agents
|
67
|
71
|
def receive(incoming_events)
|
68
|
72
|
incoming_events.each do |event|
|
69
|
73
|
opts = interpolated(event)
|
70
|
|
- slack_notifier.ping opts[:message], channel: opts[:channel], username: opts[:username]
|
|
74
|
+ if /^:/.match(opts[:icon])
|
|
75
|
+ slack_notifier.ping opts[:message], channel: opts[:channel], username: opts[:username], icon_emoji: opts[:icon]
|
|
76
|
+ else
|
|
77
|
+ slack_notifier.ping opts[:message], channel: opts[:channel], username: opts[:username], icon_url: opts[:icon]
|
|
78
|
+ end
|
71
|
79
|
end
|
72
|
80
|
end
|
73
|
81
|
end
|