Skip to content

Commit

Permalink
SlackID: add proof of concept of posting a snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbs committed Oct 26, 2023
1 parent 13dea13 commit f23a1b1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/Synergy/Reactor/SlackID.pm
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,30 @@ responder reload_slack => {
return $event->reply_error("Sorry, I didn't understand your reload command.");
};

command slacksnippet => {
} => async sub ($self, $event, $text) {
my $channel = $event->from_channel;

unless ($channel->can('slack')) {
return await $event->error_reply("Sorry, you can't use *slackid* outside Slack");
}

my $text = join q{}, ("$text\n") x 25;

my $res = await $channel->slack->api_call(
'files.upload',
{
form_encoded => 1, # Sigh.

content => $text,
channels => $event->conversation_address,
initial_comment => "Here's what you said, as a snippet.",
},
);

warn $res->as_string;

return;
};

1;

0 comments on commit f23a1b1

Please sign in to comment.