使用支持的附件和字段向slack channel发送通知

slack-notifications的Python项目详细描述


延迟通知

安装

pip install slack-notifications

简单用法

^{pr2}$

使用附件

importosimportslack_notificationsasslackslack.ACCESS_TOKEN='xxx'attachment=slack.Attachment(title='Attachment title',pretext='Attachment pretext',text='Attachment text',footer='Attachment footer',color='green',)slack.send_notify('channel-name',username='Bot',text='@channel This is test message',attachments=[attachment])

参见程序API

附件字段

importslack_notificationsasslackslack.ACCESS_TOKEN='xxx'attachment=slack.Attachment(title='Attachment title',pretext='Attachment pretext',text='Attachment text',footer='Attachment footer',fields=[Attachment.Field(title='Field title',value='Field value',),],color='green',)slack.send_notify('channel-name',username='Bot',text='@channel This is test message',attachments=[attachment])

简单文本块

importslack_notificationsasslackslack.ACCESS_TOKEN='xxx'block=slack.SimpleTextBlock('Text example',fields=[SimpleTextBlock.Field('Text field',),SimpleTextBlock.Field('Text field',emoji=True,),],)slack.send_notify('channel-name',username='Bot',text='@channel This is test message',blocks=[block])

参见程序API

初始颜色

importslack_notificationsasslackslack.init_color('green','#008000')

调用空闲资源

importslack_notificationsasslackslack.ACCESS_TOKEN='xxx'response=slack.call_resource(slack.Resource('users.info','GET'),params={'user':'W1234567890'})

资源迭代器

importslack_notificationsasslackslack.ACCESS_TOKEN='xxx'foruserinslack.resource_iterator(slack.Resource('users.list','GET'),'members'):pass

如果出现错误,则引发异常

importslack_notificationsasslackslack.ACCESS_TOKEN='xxx'slack.send_notify('channel-name',username='Bot',text='@channel This is test message',raise_exc=True)

程序API

发送通知

  • 渠道
  • 文本:str=无
  • 用户名:str=无
  • icon_url:str=无
  • icon_emoji:str=无
  • 链接名:bool=True
  • raise U exc:bool=错误
  • 附件:列表[附件]=无
  • 块:List[BaseBlock]=无

呼叫资源

  • 资源:资源
  • raise U exc:bool=错误
  • **kwargs(请求库选项)

资源迭代器

  • 资源:资源
  • 起始键:str
  • 光标:str=无
  • raise U exc:bool=错误
  • limit:int=默认的记录数

初始颜色

  • 名称:str
  • 代码:str

依附

  • image_url:str=无
  • 拇指网址:str=无
  • 作者姓名:str=无
  • 作者:无
  • 作者图标:str=无
  • 标题:str=无
  • title_link:str=无
  • 文本:str=无
  • 借口:str=None
  • 页脚:str=无
  • 页脚图标:str=无
  • 时间戳:str=None
  • 字段:列表[附件.字段]=无
  • 颜色:str=无

在附件字段

  • 标题:str=无
  • 值:str=无
  • 短:bool=假

SimpleTextBlock

  • 文本:str
  • mrkdwn:bool=真
  • 区块编号:str=无
  • 字段:列表[SimpleTextBlock.Field]=无

在SimpleTextBlock.Field

  • 文本:str
  • 表情:布尔=假
  • mrkdwn:bool=真

分隔块

  • 区块编号:str=无

图像块

  • 图片网址:str
  • 标题:str=无
  • alt_text:str=无
  • mrkdwn:bool=真
  • 区块编号:str=无

上下文块

  • 元素:列表[联合[ContextBlock.TextElement, ContextBlock.ImageElement]]在
  • 区块编号:str=无

在ContextBlock.TextElement

  • 文本:str
  • mrkdwn:bool=真

在ContextBlock.ImageElement

  • 图片网址:str
  • alt_text:str=无

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在Swing JText标签中显示集合<String>。   java IE10向Spring控制器发送双post请求   java Websphere MQ:限制分布式环境中消耗的最大消息数   java获取Android中选定画廊图像的文件路径和文件名   Java抽象泛型方法,使用具体类型实现通配符   java强制tomcat只使用HTTP 1.0或忽略除头之外的其他内容   如果每个子类型都有唯一的属性,java是获得独立子类型进行协作的正确方法   java如何在特定片段中隐藏动作栏   在构建Android应用程序时,java在特定清单条目上没有签名保护   java广播接收器触发两次   java将Spring升级到最新补丁版本安全吗?   java AlertDialog无法解析或不是字段   java如何实现TableDecorator?   java如何在Android日记应用程序中显示条目并进行编辑   java如何将文件从一个文件夹移动到另一个文件夹