Giter VIP home page Giter VIP logo

matterhook's Introduction

matterhook

Simply send messages to your Mattermost team using incoming webhooks.

Getting the API key

  • Login to your Mattermost team site and go to Account Settings -> Integrations
  • Next to Incoming Webhooks click Edit
  • Select the channel or private group to receive webhook payloads, then click Add to create the webhook
  • The API key is the last part of the URL (eg: u2x8rkfugj8zbqby9pw3huqnyc)

Usage

Basic usage

matterhook is very simple and efficient to use:

from matterhook import Webhook

# mandatory parameters are url and your webhook API key
mwh = Webhook('https://mattermost.MYCOMPANY.com', 'API_KEY')

# send a message to the API_KEY's channel
mwh.send('coconut webhook message')

Advanced usage

from matterhook import Webhook

# mandatory parameters are url and your webhook API key
mwh = Webhook('https://mattermost.MYCOMPANY.com', 'API_KEY')

# personalized bot name and icon
mwh.username = 'cocobot'
mwh.icon_url = 'http://3.bp.blogspot.com/-bEcLJDp_u7o/UJKPRGazv6I/AAAAAAAABGY/75z_6bbegao/s1600/coconut-oil-alzheimers-study.jpg'

# send a message to the specified channel
mwh.send('coconut is da thruth', channel='special_channel')

# override the username for this message
mwh.send('secret message', channel='special_channel', username='secret_user')

# for convenience, you can also do this...
mwh['incredible_channel'] = 'incredible message'

# ...and even this
mwh['incredible_channel'] = {'text': 'incredible message', username='incredible user'}

# or create fancy messages using attachments (https://docs.mattermost.com/developer/message-attachments.html)
attachments = []
message = {}
message['color'] = '#88fc03'
message['image_url'] = 'https://about.mattermost.com/wp-content/uploads/2017/08/Mattermost-Logo-Blue.svg'
message['fallback'] = 'A fallback message'
markdown_msg = '#### Title\n'
markdown_msg += 'This is a line of text\n'
markdown_msg += 'All markdown syntax works in attachments, like tables :\n'
markdown_msg += '''
| name                               |   date |
|------------------------------------|--------|
| Monty Python and the Holy Grail    |   1975 |
| Monty Python's Life of Brian       |   1979 |
| Monty Python's The Meaning of Life |   1983 |
'''
message['text'] = markdown_msg
attachments.append(message)
mwh.send(attachments=attachments)

matterhook's People

Contributors

lujeni avatar ultrabug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

matterhook's Issues

support for receiving messages on a channel

Hi,

I am using your lib and it works super for sending out message. I would like to extend the functionality though, so the mattermost user can send some information back - for example to regulate the verbosity of messages.

Is it supported?

More examples for markdown attachments

I have a few examples to illustrate how to make fancy notifications, like :

Title

This is a line of text
All markdown syntax works in attachments, like tables :

name date
Monty Python and the Holy Grail โœ… 1975
Monty Python's Life of Brian โŒ 1979
Monty Python's The Meaning of Life ๐Ÿคทโ€โ™‚๏ธ 1983

with tables generated from tabulate :

data = [{'name': 'Monty Python and the Holy Grail', 'date': '1975'}, {'name': 'Monty Python\'s Life of Brian', 'date': '1979'}, {'name': 'Monty Python\'s The Meaning of Life', 'date': '1983'}]
markdown_table = tabulate.tabulate(data, headers='keys')

Maybe an 'examples' dir would be a good idea ?

Mattermost moving to API version 4

Hey @ultrabug!

First, hugely appreciate you sharing this project back with the world. Fantastic work!

I wanted to let you know about our plans moving to API v4:

To make the Mattermost API web service easier to use and to offer more powerful options for these integrations, Mattermost will be moving to a new API version soon. Highlights include:

  • Fully documented API endpoints
  • More in-depth access to server functionality
  • Wider use of established HTTP verbs
  • Consistent endpoint structures
  • A new and improved Go driver

We plan to release API version 4 on March 16th, with Mattermost server 3.7. While the current API version 3 will be supported until September 16th, we recommend you begin using API version 4 soon after its release.

Contributing

API version 4 is an active and on-going project. If you're interested in helping contribute, please join our Mattermost community instance and the APIv4 channel.

We've prepared a contribution process for APIv4 and a progress tracker for new APIv4 enpoints to help you get started.

We're also open for suggestions on adding new API endpoints to help with your integration.

python2 deprecation + code qa enforcement

Quick note to:

  • update setup.py to newer python versions
  • deprecate python2
  • update code syntax to python3
  • enforce some code qa : black, isort, flake8
  • travis that enforcement?

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.