AnyEvent-SlackBot
view release on metacpan or search on metacpan
lib/AnyEvent/SlackBot.pm view on Meta::CPAN
271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
my
$id
=
$self
->next_id;
my
$msg
={
bot_id
=>
$self
->bot_id,
channel
=>
$json
->{channel},
id
=>
$id
,
type
=>
'typing'
,
};
$self
->
send
(
$msg
);
}
=item * $self->post_to_web($msg,$endpoint|undef,"FORM"|"JSON"|undef)
Posts the to the given REST Endpoint outside of the WebSocket.
msg:
Hash ref representing the requrest being sent
token: set to $self->token if not set
scope: set to: 'chat:write:bot' if not set
endpoint:
The Rest xxx endpint, the default is 'chat.postMessage'
type:
Sets how the data will be sent over
Supported options are:
- FORM: posts the data using form encoding
- JSON: converts $msg to a json string and posts
=cut
sub
post_to_web {
my
(
$self
,
$msg
,
$endpoint
,
$type
)=
@_
;
$endpoint
=
'chat.postMessage'
unless
defined
(
$endpoint
);
$type
=
'FORM'
;
$self
->stats->{running_posts}++;
$msg
->{token}=
$self
->token
unless
exists
$msg
->{token};
$msg
->{scope}=
'chat:write:bot'
unless
exists
$msg
->{scope};
my
$request
;
if
(
$type
eq
'FORM'
) {
$request
=POST
$url
,[%{
$msg
}];
}
else
{
( run in 0.891 second using v1.01-cache-2.11-cpan-49f99fa48dc )