Giter Site home page Giter Site logo

Edit last message about hubot-slack HOT 11 CLOSED

lukerollans avatar lukerollans commented on June 7, 2024
Edit last message

from hubot-slack.

Comments (11)

aoberoi avatar aoberoi commented on June 7, 2024 1

i can shed some light on this. there's two problems that i see:

  1. this adapter uses the RTM API for Slack. the only way to update a message is to use Web API method chat.update.
  2. in order to use chat.update, you must know the message's channel and ts properties.

the first problem is pretty easy to solve, because you can create your own WebClient object. first you would npm install --save @slack/client in your project, then add a few lines into your script, like so:

# import the Web client code from the node-slack-sdk
{WebClient} = require '@slack/client'

module.exports = (robot) ->
  # instantiate a Web client using the same bot token as the internal RTM client
  web = new WebClient(robot.adapter.client.rtm.token)

  # the rest of your script follows...

the second problem is a little harder to solve. once a message is already sent, the adapter needs to return that message to your code so you can use the channel and ts values. unfortunately, the adapter doesn't currently support this, but its close. it looks like the SlackBot#send method needs to detect whether the last item in messages... is a function, and if so use that as the callback. i think its worth making a new issue to track this feature, so i'm opening #473.

from hubot-slack.

erunion avatar erunion commented on June 7, 2024

Curious: what use case do you have for this?

from hubot-slack.

lukerollans avatar lukerollans commented on June 7, 2024

When a deployment is underway for example, it would be great for our Hubot to send back status updates within the same chunk of text on screen. It would also allow the use of one preformatted block which will make his output cleaner and skinnier

from hubot-slack.

turnguard avatar turnguard commented on June 7, 2024

are there any news on that one?

i would have another use case :

i'd like to be able to add tags to a message, but sending the original message to a keyphrase extraction service and update the original message with found keywords..

wkr turnguard

from hubot-slack.

lukerollans avatar lukerollans commented on June 7, 2024

Sounds cool.

The new adapter is dropping soon, hopefully we'll see something like this in there. Would be fantastic for ongoing updates that take a long time, rather than spamming messages one after the other.

from hubot-slack.

paulhammond avatar paulhammond commented on June 7, 2024

As I mentioned over in #16 the API used by the new adapter supports this - but we haven't yet built support into hubot-slack, mostly because we've not worked out how it would work in the context of hubot. Suggestions are welcome!

from hubot-slack.

fabianthoma avatar fabianthoma commented on June 7, 2024

👍 This would be such an awesome feature

On to implementation ideas: Maybe you could return the message object you send to the server and give it methods to update and delete the text. It would probably need changes in your node-slack-client as well, but it shouldn't be too big of a change.
I'm not sure about garbage collection on these message objects though, but they should stick around as long as a hubot script is keeping them referenced.

from hubot-slack.

paulhammond avatar paulhammond commented on June 7, 2024

thanks to slackapi/node-slack-sdk#14, the next version of node-slack-client will have the ability to edit messages. The only question left is how we'd implement this inside hubot's framework!

from hubot-slack.

fabianthoma avatar fabianthoma commented on June 7, 2024

As I've already commented on my pull request on node-slack-client, you get
the message object passed back, thanks to coffee script awesomeness you get
it passed through all hubot and node-slack-client methods, not entirely
sure if I changed something in hubot-slack, I'll check that when I get home.
You'd then just save the message object and modify it when you need to.
Am 31.01.2015 02:03 schrieb "Paul Hammond" [email protected]:

thanks to slackapi/node-slack-sdk#14
slackapi/node-slack-sdk#14, the next version
of node-slack-client will have the ability to edit messages. The only
question left is how we'd implement this inside hubot's framework!


Reply to this email directly or view it on GitHub
#91 (comment).

from hubot-slack.

id0Sch avatar id0Sch commented on June 7, 2024

@paulhammond hi, just wondering; was this ever implemented? if not, how can I use it anyways?
I couldn't find a way and i really need to update sent messages
thanks

from hubot-slack.

gonstr avatar gonstr commented on June 7, 2024

Would also really like to know how to update messages. Been digging through documentation and PRs and can't figure out how.

from hubot-slack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.