Skip to content

Commit f23a1b1

Browse files
committed
SlackID: add proof of concept of posting a snippet
1 parent 13dea13 commit f23a1b1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

lib/Synergy/Reactor/SlackID.pm

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,30 @@ responder reload_slack => {
7979
return $event->reply_error("Sorry, I didn't understand your reload command.");
8080
};
8181

82+
command slacksnippet => {
83+
} => async sub ($self, $event, $text) {
84+
my $channel = $event->from_channel;
85+
86+
unless ($channel->can('slack')) {
87+
return await $event->error_reply("Sorry, you can't use *slackid* outside Slack");
88+
}
89+
90+
my $text = join q{}, ("$text\n") x 25;
91+
92+
my $res = await $channel->slack->api_call(
93+
'files.upload',
94+
{
95+
form_encoded => 1, # Sigh.
96+
97+
content => $text,
98+
channels => $event->conversation_address,
99+
initial_comment => "Here's what you said, as a snippet.",
100+
},
101+
);
102+
103+
warn $res->as_string;
104+
105+
return;
106+
};
107+
82108
1;

0 commit comments

Comments
 (0)