Giter Site home page Giter Site logo

mtm_flow's Introduction

Changingtec mattermost bot

This is a Python bot for interacting with the Mattermost chat platform. Currently, the bot has the functionality to push messages to specified channels and users.

Features

  • chat bot - contact info
  • chat bot - the status of meeing rooms
  • chat bot - Error code
  • chat bot - the status of leave
  • notification - push message to the channel
  • notification - push message to the user

Installation

  1. Make sure you have Python 3.6 or higher installed. (Python 3.8 is recommended)

  2. Clone the repository. recommended to use SSH.

    git clone [email protected]:cglab/mtm_bot.git
  3. Install the required packages.

    pip install -r requirements.txt
  4. Set the environment variables.

    export MATTERMOST_TOKEN="the token of the bot"

Usage

Push a message to a channel.

To push messages to a specified channel, use the following function:

def push_msg_channel(message: str, channel_id: str)
  • message: The message to be sent.
  • channel_id: The ID of the channel to which the message will be sent.

Example: Push the message "Hello, world!" to the MTM test channel with the ID "ynm61k6j4f8imrfar35f1dpiqh".

push_msg_channel("Hello, world!", "ynm61k6j4f8imrfar35f1dpiqh")

You can find the channel ID by viewing the channel information in Mattermost.

Push a message to a user.

To push messages to a specified user, use the following function:

def push_msg_user(message: str, user_name: str = None, user_id: str = None)
  • message: The content of the message to be pushed.
  • user_name: The username of the target user (optional).
  • user_id: The ID of the target user (optional).

You must provide either user_name or user_id. If user_name is provided, the bot will attempt to find the user's ID by their username. If the user is not found, a ValueError will be raised.

Example:

Push the message "Hello, world!" to the user with the username "codingman".

push_msg_user("Hello, world!", user_name="codingman")

Configuration

The bot can be configured by modifying the config.py file. The following parameters can be set:

  • MATTERMOST_URL: The URL of the Mattermost server.
  • MATTERMOST_TOKEN: The token of the bot.
  • MATTERMOST_PORT: The port of the Mattermost server.
  • MATTERMOST_VERIFY_SSL: Whether to verify the SSL certificate of the Mattermost server.

Notes

  • Before using the bot, make sure you have created an account in Mattermost and obtained the corresponding API token.
  • The bot currently only supports the functionality of pushing messages. Additional features, such as handling chatbot interactions, may be added in the future.
  • If you encounter any issues while using the bot, please check your configuration and ensure that your Mattermost account has sufficient permissions.

Contributing

Feel free to open issues and suggestions, and submit pull requests to improve this bot.

mtm_flow's People

Contributors

pttcodingman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.