Skip to main content

Forked from attzonko/mmpy_bot

PyPI Maintainability Python Support Mattermost License

Documentation available at Read the Docs.

Description

A Python based chat bot framework for Mattermost. The code for this bot framework was heavily re-factored in v2.0.0 and will only work with Python 3.8 or higher. For Python 2 and Python3 < 3.8 support, please use versions v1.3.9 or lower.

Features

  • Based on Mattermost WebSocket API(V4.0.0)
  • Simple plugins mechanism
  • Concurrent message handling
  • Attachment support
  • Auto-reconnect to Mattermost after connection loss
Additional features added in v2.x:
  • Multi-threading and asyncio execution
  • Integrated webhook server
  • Support for click functions
  • Job scheduling

Compatibility

Mattermost mmpy_bot_mk2
>= 4.0 > 1.2.0
< 4.0 unsupported

Installation

:warning: Warning: pip will grab v1.x if your Python version is less than 3.8!

v2.x (latest)
pip install mmpy-bot
v1.3.9 (force legacy)
pip install mmpy-bot==1.3.9

Usage (v2.x)

Registration

First you need to create a bot account on your Mattermost server. Note: Enable Bot Account Creation must be enabled under System Console

  1. Login to your Mattermost server as a user with Administrative privileges.
  2. Navigate to Integrations -> Bot Accounts -> Add Bot Account
  3. Fill in the configuration options and upon creation take note of the Access Token

Note that some API functions, such as ephemeral message replies, will require the bot to be part of the System Admin group, however most API functions will work with a regular Member account role. Just be aware that if some API functions are not working, it may be due to a lack of appropriate permissions.

Configure and run the bot

Create an entrypoint file (or copy the one provided), that defines your Mattermost server and bot account settings and imports the desired modules.

Example my_bot.py:

#!/usr/bin/env python

from mmpy_bot_mk2 import Bot, Settings
from my_plugin import MyPlugin

bot = Bot(
    settings=Settings(
        MATTERMOST_URL = "http://chat.example.com",
        MATTERMOST_PORT = 443,
        BOT_TOKEN = "a69155mvlsobcnqpfdceqihaa",
        BOT_TEAM = "test",
        SSL_VERIFY = True,
    ),  # Either specify your settings here or as environment variables.
    plugins=[MyPlugin()],  # Add your own plugins here.
)
bot.run()

Set the executable bit on the entrypoint file (i.e. chmod +x my_bot.py) and start your bot from the command prompt. Now you can talk to your bot in your Mattermost client!

In order to get the most out of your bot, you will need to write your own plugins. Refer to the Plugins Documentation to get started.

Talk to us

The primary channel for communication is GitHub via Issues or Pull requests

Metadata

Release files for mmpy-bot-mk2 2.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mmpy-bot-mk2 2.1.6
File Size Uploaded
mmpy_bot_mk2-2.1.6.tar.gz 27.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mmpy-bot-mk2 2.1.6
File Interpreter ABI Platform
mmpy_bot_mk2-2.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 59.0 kB

Release files / mmpy_bot_mk2-2.1.6.tar.gz

Download URL mmpy_bot_mk2-2.1.6.tar.gz
Size 27.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cfb4601fceb778f0252bb699068c3ba70e4157d7f778c8106c32518bc5520c7b
BLAKE2b-256 checksum
How to use checksums
441fa5d8e153ee53907d2387693add57b3c5baceacc1e5ea670c6f048692018a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release files / mmpy_bot_mk2-2.1.6-py3-none-any.whl

Download URL mmpy_bot_mk2-2.1.6-py3-none-any.whl
Size 31.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f61c074257deaeacd806e69e69a4865b50a373dc1b7181016d5fd9d2a118dfa7
BLAKE2b-256 checksum
How to use checksums
aca503c705b3664644ea2c5aff058f32d2126bd1ac8d7b513593cc15f8e89e6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

2.1.6 This release

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page