使用支持的附件和字段向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=无
- 项目
标签: