send_only
send_text(text, *, channel_id=None, client=None)
¶
Send a text message to the default client and channel (if not specified).
Source code in src/slack_helpers/send_only.py
send_text_as_file(*, filename, content, title, ensure_preview=False, initial_comment=None, channel_id=None, client=None)
¶
Send a text as a file to the default client and channel (if not specified).
Slack is stupid and having special characters in the file makes it think it's a binary file.
If ensure_preview is True, then we append """"dear-viewer""""
at the beginning of the file so Slack thinks
it's a python file and will preview it.
Note
ensure_preview
is a hacky workaround and may not work in the future.
Issues
ensure_preview
only works with text-ish files (txt, html, etc.) and not with other files (pdf, png, svg).
You can set the filename
to be like "file.html" for svg files with the ensure_preview
flag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
|
required |
content |
str
|
|
required |
title |
str
|
|
required |
ensure_preview |
bool
|
If True, append |
False
|
initial_comment |
str | None
|
|
None
|
channel_id |
str | None
|
|
None
|
client |
WebClient | None
|
|
None
|
Source code in src/slack_helpers/send_only.py
send_divider(*, channel_id=None, client=None)
¶
Send a divider block to the default client and channel (if not specified).
Source code in src/slack_helpers/send_only.py
send_file(*, filename, file, title, snippet_type=None, initial_comment=None, channel_id=None, client=None)
¶
Send a file to the default client and channel (if not specified).
Source code in src/slack_helpers/send_only.py
send_matplotlib_fig(filename, fig, title, initial_comment=None, channel_id=None, client=None)
¶
Send a matplotlib figure as a PDF file to the default client and channel (if not specified).
Source code in src/slack_helpers/send_only.py
send_pil_image(filename, image, title, initial_comment=None, channel_id=None, client=None)
¶
Send a PIL image as a PNG file to the default client and channel (if not specified).
Source code in src/slack_helpers/send_only.py
send_svg_as_pdf(filename, svg_file, title, initial_comment=None, channel_id=None, client=None)
¶
Send an SVG file as a PDF file.
Slack does not support previewing SVG files, so we convert it to PDF.
Issues
The cairosvg library does not have good support for fonts, and if you export_svg
from rich.console
then it will have font alignment issues, even if you install the Fira Code font on your system.