-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathslackbot.tcl
45 lines (35 loc) · 1.32 KB
/
slackbot.tcl
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
##############################################################################
#
# Eggdrop Slackbot - Simple Message Relay from IRC to Slack
#
# @author Jason Roman <[email protected]>
#
##############################################################################
# get the directory of where this script is located
set SlackbotScriptDir [file dirname [info script]]
# load slack functionality
source [file join $SlackbotScriptDir utility.tcl]
source [file join $SlackbotScriptDir slack.tcl]
# listen for any and all text in the channel to forward
bind pubm - * pub_slackpush
# pushes a chat message to slack
proc pub_slackpush {nick mask hand channel args} {
set msg [lindex $args 0]
# if there is no mapping for this channel to slack, do not echo
if {![::slack::channel::mappingExists $channel]} {
return 0
}
# if this is a bot command, do not echo
if {[::slack::channel::isCommand $msg]} {
return 0
}
# set the JSON payload and push it to slack
set payload [
::json::write object \
text [json::write string $msg] \
username [json::write string $nick] \
channel [json::write string [::slack::channel::ircToSlack $channel]] \
unfurl_links [json::write string $::slack::webhook::unfurl_links]
]
set result [slack::push -payload $payload]
}