New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Please consider implementing 'snippet' support for the Slack connector #1611
Comments
I have just recently written a quick thing using NLTK to get a summary/snippet of a large block of text. I wonder if this should be done on a skill level - although I'm not sure how that would work... Maybe we could create an event that is fired when the text has more than x number of lines? 🤔 Unless you don't really care as much about a summary of that large block of test and instead you just want the first x words of the test? 🤔 |
I think in this case we want to upload the text to Slack as a We already have the Lines 336 to 337 in 1e1544d
We should add a new handler to the Slack connector which can send @register_event(opsdroid.events.File)
async def _send_file(self, file_event):
return await self.slack.api_call(
"files.upload",
data={"channels": file_event.target, "content": await file_event.get_file_bytes(), "filetype": await file_event.get_mimetype(), "filename": file_event.name},
) Then in order to send this from your skill you would need to construct a await message.respond(File(file_bytes=f"my long string".encode("utf-8"), mimetype="text", name="mysnippet.txt")) This would allow the use case here of sending long messages as snippets, but also uploading of files in general. We could also add a await message.respond(Snippet(f"my long string", type="text")) Allowing the |
is uploading files as snippets still on the roadmap? |
I'm attempting to take a stab at this, we'll see how it goes |
@jacobtomlinson I put together a small PR based on your input, any additional feedback/guidance you have would be appreciated. |
Description
I'm developing a skill that occasionally will return a LARGE amount of text. Rather than flood the public room, it would be nice if the Opsdroid Slack connector had the ability to send a message as a 'snippet' so a small preview of the larger output would be shown, and users would have the ability to click through to see the full data-dump.
Steps to Reproduce
Right now,
await message.respond(f"regular message")
only sends a regular Slack message. There is the ability to send 'rich' messages withevent.respond(Blocks([]))
, but anevent.respond(Snippet([]))
that utilizes the https://api.slack.com/types/file type or similar would be ideal.Expected Functionality
Opsdroid should have the option of sending large messages as a 'snippet' or 'file' type, for cleaner displays of large amounts of data in public channels.
Additional Details
Any other details you wish to include such as screenshots, console messages, etc.
The text was updated successfully, but these errors were encountered: