Comments (6)
I think this is because the buffer for the web socket is flushed later. I see two options:
EM.next_tick do
client.say ...
end
Or EM.defer
for a long running thing.
Or use a web client, client.web_client.chat_postMessage(channel: ..., text: ...)
which will use the web API to post immmediately.
Generally I think you don't want to block, so I think wrapping the long operation in EM.defer
is probably the best solution.
Le us know which one works best?
from slack-ruby-bot.
I've also noticed that while doing said long running operation that the bot doesn't respond to other requests. So I've taken to running the blocks for any commands that take a while in a new thread. This allows the bot to answer other questions at the same time. One thing to note, that will break test cases as the test case doesn't know to wait for the detached thread. To solve this I enclose the block in a lambda and then check if the environment is test, if so execute the block without the thread, otherwise pass the block to the thread to be run.
from slack-ruby-bot.
I noticed this is the behavior with faye-websocket but if you use celluloid-io gem then you get one message, then the pause while it works, then the next response.
from slack-ruby-bot.
I found that using Celluloid.defer
seems to work for allowing the bot to respond to other commands while processing a long-running command. It also allows me to use client.say
in the deferred block. Maybe this (or something similar) should become a standard feature in how SlackRubyBot responds to commands?
from slack-ruby-bot.
I am down with a global option to defer execution of all commands, including regex parsing. Would love a PR, please!
from slack-ruby-bot.
I suppose it would then need to be something that works w/ both Celluloid and EventMachine. Possibly not too much code to implement but would certainly require major changes to the specs.
from slack-ruby-bot.
Related Issues (20)
- Getting lots of 429 rate limit errors on https://slack.com/api/rtm.start calls HOT 7
- Graceful shutdown HOT 1
- Testing other code execution inside a command HOT 8
- Deployment tutorial needs update HOT 2
- DMing self produces Sorry @Slackbot, I don't understand that command! HOT 1
- Migration to non-legacy bots HOT 6
- Consider splitting RSpec shared behaviours and development dependencies HOT 4
- Where can i find more info on the client.say method? HOT 7
- Remove support for Giphy
- Extract attachments text
- without mention in channel bot can't reply HOT 1
- Upload a file? HOT 1
- Pongbot does not run on linux mint 19 HOT 4
- Testing for two outputs from a command HOT 5
- When a command is posted in thread, its again posted as direct message automatically HOT 4
- is there an example for how to implement a conversational bot using slack-ruby-bot? HOT 1
- Missing concurrency - Add faye-websocket to your gemfile -- It's already in my Gemfile HOT 1
- Clarification of MIGRATION.md HOT 8
- Is this repo really legacy, there is still a use case? HOT 3
- Repeated 429 (ratelimited) errors from slack HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slack-ruby-bot.