跳转到主要内容

Jupyterpost:Mattermost服务的Jupyterhub

项目描述

Jupyterpost:从Jupyterhub向Mattermost服务器发送消息

安装

pip install jupyterpost

启用jupyterpost

  1. 在您的Mattermost服务器上创建一个机器人用户并获取其令牌。
  2. 在您的Jupyterhub配置文件末尾添加以下内容。
from jupyterpost import configure_jupyterhub

configure_jupyterhub(
    c,
    mattermost_token="your mattermost token",
    mattermost_url="https://your.mattermost.server/api/v4/",
    mattermost_team="your mattermost team name",
    jupyterpost_url="https://services.your.jupyterhub/services/jupyterpost",
)

这将

  • 向您的Jupyterhub添加一个新的服务 jupyterpost
  • 允许所有用户及其服务器访问此服务
  • 将服务URL作为环境变量 JUPYTERPOST_URL 提供给用户的服务器

该函数有些脆弱,但应该适用于标准的Jupyterhub安装。

使用jupyterpost

from jupyterpost import post
from matplotlib import pyplot

pyplot.plot([0, 1])
post(
    message="Check out my plot",
    channel="my-channel",  # Or "@username"
    attachment=pyplot.gcf(),  # Or png bytes
)

从Jupyterhub外部发送

  1. 从您的Jupyterhub服务器获取变量 JUPYTERPOST_URLJPY_API_TOKEN
  2. 将它们提供给 jupyterpost.post 作为附加参数,并从任何地方连接!

贡献

欢迎贡献!请打开一个问题或拉取请求。

特别希望支持更多的聊天服务和更多的发送消息的方式。

测试也会很棒。