zostay / anyevent-slackrtm Goto Github PK
View Code? Open in Web Editor NEWAnyEvent library for accessing Slack's RTM API
AnyEvent library for accessing Slack's RTM API
None of the error messages that this module can send out are documented. That's not good. How can someone catch the messages and react appropriately if they are not documented?
Although AnyEvent::WebSocket::Client now supports proxies, it needs the env_proxy
option passed to enable it.
AnyEvent::SlackRTM should provide a way to pass that option through. Possibly even allowing passing through any of the other options it supports.
No current way i can see to handle slack replies
see "Handling responses" at https://api.slack.com/rtm
Once the JSON has been sent to the server visual clients should immediately display the text in the channel, grayed out or otherwise marked to indicate that it is "pending". At some point after that, usually a few milliseconds later, the server will send a confirmation that the message was received:
{
"ok": true,
"reply_to": 1,
"ts": "1355517523.000005",
"text": "Hello world"
}
this code adds a 'type' to these so we can register a 'reply' handler:
$ diff -u /tmp/AnyEvent-SlackRTM-1.1/lib/AnyEvent/SlackRTM.pm lib/perl5/AnyEvent/SlackRTM.pm
--- /tmp/AnyEvent-SlackRTM-1.1/lib/AnyEvent/SlackRTM.pm 2019-10-04 05:01:17.000000000 +1000
+++ lib/perl5/AnyEvent/SlackRTM.pm 2020-11-26 14:41:42.432644470 +1100
@@ -163,6 +165,7 @@
my $message = $raw->body;
croak "unable to decode incoming message: $message";
};
+ $msg->{type} = 'reply' if (! $msg->{type} && $msg->{reply_to});
# Handle errors when they occur
if ($msg->{error}) {
module does not work for me behind a proxy (when ENV variables set for https_proxy etc)
fix:
$ diff -u /tmp/AnyEvent-SlackRTM-1.1/lib/AnyEvent/SlackRTM.pm lib/perl5/AnyEvent/SlackRTM.pm
--- /tmp/AnyEvent-SlackRTM-1.1/lib/AnyEvent/SlackRTM.pm 2019-10-04 05:01:17.000000000 +1000
+++ lib/perl5/AnyEvent/SlackRTM.pm 2020-11-26 14:41:42.432644470 +1100
@@ -45,6 +45,8 @@
agent => "AnyEvent::SlackRTM/$VERSION",
);
+ $furl->env_proxy();
+
my $res = $furl->get($START_URL . '?token=' . $self->{token});
my $start = try {
decode_json($res->content);
For whatever reason, the ping-pong test is consistently failing on the Perl 5.14 test on Travis-CI. Whether this is because it's the first one that runs each time around or some quirk of 5.14, I do not know.
I used to be able to test against my test slack instance using travis CI. However, this depended on legacy slack bot tokens and this needs to be updated to support the new system that has access token and refresh token. I haven't really looked into this.
I can generate the necessary tokens easily enough, but something will need to perform the refresh action and I haven't looked into that part.
The start() method automatically adds an AnyEvent->timer callback that invokes ping(). However, it passes no arguments which leads the ping method to attempt dereferencing an undefined value when constructing the message hashref that is passed to send().
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.