mattermost的简单bot

mattermost_bot的Python项目详细描述


[![pypi](https://badge.fury.io/py/mattermost_bot.svg)(https://pypi.python.org/pypi/mattermost_bot)
[![密码](https://api.codacy.com/project/badge/grade/b06f3af1d8a04c6faa9a76a4ae3cb483)(https://www.codacy.com/app/gotlium/mattermost_bot)
[![代码运行状况](https://landscape.io/github/lpgenerator/mattermost_bot/master/landscape.svg?style=flat)(https://landscape.io/github/lpgenerator/mattermost\u bot/master)
[![Python支持](https://img.shields.io/badge/python-2.7,3.5-blue.svg)(https://pypi.python.org/pypi/mattermost_bot/)
[![马特莫斯特](https://img.shields.io/badge/mattermost-1.4+-blue.svg)](http://www.mattermost.org)
[![许可证](http s://img.shields.io/badge/license-mit green.svg)(https://pypi.pypi.org/pypi/pypi/mattermost-bot/mattermost-bot/)


[阅读文档](http://mattermost-bot.read the docs.org/)[阅读文档](http://mattermost.org/http://www.mattermost.org.mattermost.mattermost(http://www.mattermost.org.http://www.mattermost.org.http://www.mattermost.mattermost.org.http://www.mattermost.mattermost/br/>




br/>*基于mattermost[WebSocket API](https://api.mattermost.com)
*简单的插件机制
*消息可以同时处理
*当连接丢失时自动重新连接到mattermost
*python3支持



|> 1.0.19 |
| >= 3.3 && <= 3.4 | 1.0.18 |
| >= 3.0 && <= 3.2 | 1.0.17 |
| < 3.0 | < 1.0.16 |


## Installation

```
pip install mattermost_bot
```

## Usage

### Registration

First you need create the mattermost email/password 对于您的bot。






>然后您需要在python模块中配置"bot_url"、"botu登录名"、"botu密码"和"botu团队",该模块必须位于python导入路径中。








>










sslu verify=true\是否执行SSL证书版本通知
bot_url='http://<;mm.example.com>;/api/v3'带有'http://'和'/api/v3'路径。没有尾随斜线。/API/v1'-针对3.0版<;3.0
bot\u登录登录名<;bot电子邮件地址>;'
>bot\u密码<;bot密码>;'
>bot\u团队='<;你的团队>;'''''''lt;可能需要小写
```




>或者,你可以使用环境变量"mattermost.bot.bot.url"、
"mattermost.bot.bot登录名"、"mattermost.bot.bot.bot.bot密码"、"mattermost.bot.bot.bot.bot.bot.bot.bot.bot登录名"、"mat_团队`,
` mattermost _bot _ssl ru verify`


>或者` mattermost _bot _bot _bot _bot _bot _bot _bot _bot _bot _bot _bot _bot
```





>使用内置的cli脚本,指向自定义设置文件。






``bash
物质most_bot_settings_module=mattermost_bot_settings matterbot
```

,或者您可以创建自己的启动文件。例如"run.py":

``python
from mattermost戋bot.bot import bot



if戋u name戋uu main戋uu":
bot().run()
````











``python
",
‘文本’:"此处有些文本…",
"颜色":"59afe1"
}
消息.回复webapi(
"附件示例",附件,
用户名='mattermost-bot',
图标url='https://goo.gl/of4dbq',
)可选:将消息发送到指定频道
消息.发送webapi('',附件,频道id=message.channel)
```

*非管理员用户必须允许集成。*

当与模式匹配的消息发送到bot时(在频道/群聊中为direct message或@botname)
-当在频道/群聊中发送与模式匹配的消息时(不是直接发送到bot),调用一个用"listen"修饰的函数

`` python
从mattermost_bot导入re

。bot import从mattermost_bot侦听
。bot import respond_to


@respond_to('hi',re.ignorecase)
def hi(消息):
message.reply('i can understand hi or hi!')


@回复"我爱你"
定义爱(消息):
消息。回复("我也爱你!")


@听我说('有人能帮我吗?')
def help_me(消息):
消息已答复发件人(前缀为@user)
消息.答复('yes,i can!')

消息在频道上发送
message.send('我可以帮助所有人!')
```

要从消息中提取参数,您可以使用正则表达式:
``python
从mattermost bot.bot import respond\u to



@respond\u to('give me(.*)
def give-me(message,something):
message.reply('here is%s'%something)
````

如果希望有一个类似"stats"和"stats start\u date end\u date"的命令,您可以创建这样的REG EX:

``python
从mattermost\u bot.bot import respond\u to
import re


@respond\u to('stat$,re.ignorecase)
@respond\u to('stat(.*)(.*)、re.ignorecase)
def stats(message,开始日期=无,结束日期=无):
传递
````



odule:domain:devops plugins.git
"programmers.plugins",例如python package:package\name.plugins
"frontend.plugins",例如project tree:apps.bot.plugins
]
````
*例如,可以将git存储库与团队中的插件分离。*



您正在从'slack'迁移到'mattermost',以前使用的是'slackbot',
您可以毫无问题地使用此电池。在大多数情况下,如果您使用标准的api或进行最小的修改,您的插件将正常工作。

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

推荐PyPI第三方库


热门话题
java如何在中间的AcLtCudio中“椭圆”标题?   java如何使用Hibernate获取不完整的集合?   将xml代码解码为Java对象的最佳方法?   java如何在本地和远程服务器上存储内容   java如何解决CWE ID 501信任边界冲突   regex Java word finder程序不会捕获字符串中的所有唯一项   sql将存储过程消息直接打印到Java控制台   java删除JTable行   Java中的泛型转换   datetime Java DateTimeFormatter在时区为+0000时添加Z   java根据报告中的变量显示不同的标头   java文件管理器总是抛出FilerException   递归为什么我在递归java方法中得到“线程中的异常”main“java.lang.StackOverflowerr”?