Coder Social home page Coder Social logo

glennneiger / mattermoster-todo-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tribal2/mattermoster-todo-plugin

0.0 2.0 0.0 117 KB

ToDo plugin for 'mattermoster-base' based on Node.js + Express + MySQL

License: MIT License

JavaScript 100.00%

mattermoster-todo-plugin's Introduction

Mattermoster ToDo Plugin (mattermoster-todo-plugin)

ToDo plugin for Mattermoster based on Node.js + Express + MySQL.

Mattermoster is a Node.js + Express base API for Mattermost slash command integrations.

Mattermost is an Open source, private cloud Slack-alternative.

Features

  • Use the same MySQL database server you use for Mattermost
  • i18n ready
  • Open source!

Installation

$ npm install --save mattermoster-todo-plugin

Adding plugin to Mattermoster

const MattermosterClass = require('mattermoster');
const mattermoster = new MattermosterClass;

// ...

/**
 * Mattermoster todo plugin
 */
const todoPlugin = require('mattermoster-todo-plugin');
const endpoint = '/todo'; // you can change this
mattermoster.addPlugin(endpoint, todoPlugin);

// ...

mattermoster.init();

MySQL database

--
-- Schema creation
-- Replace 'DBNAME' below with your desired database name
--
CREATE SCHEMA DBNAME DEFAULT CHARACTER SET utf8 ;
USE DBNAME;

--
-- User creation
-- Replace DBUSER, DBPASS and DBNAME with your own
--
CREATE USER 'DBUSER'@'localhost' IDENTIFIED BY 'DBPASS';
GRANT ALL PRIVILEGES ON 'DBNAME'.* TO 'DBUSER'@'localhost';
FLUSH PRIVILEGES;

--
-- 'todo' table creation
--
CREATE TABLE `todo` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `channel_id` varchar(30) DEFAULT NULL,
  `description` VARCHAR(120) NULL,
  `completed` TINYINT NOT NULL DEFAULT 0,
  `created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` varchar(30) DEFAULT NULL,
  `updated_by` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`id`));

The MySQL connection class will use this parameters:

Parameter Environment variable Default value
host MM_TODO_DBHOST localhost
port MM_TODO_DBPORT 3306
user MM_TODO_DBUSER mattermoster
password MM_TODO_DBPASS mattermoster
database MM_TODO_DBNAME mattermoster

If you use a parameter with a non default value, you must set the corresponding environment variable.

Mattermoster API Server

Run your Mattermoster API Server:

$ node index.js

You can supply a different port number for your server (defaults to 3000):

$ node index.js 12345

For more information on running Mattermoster API Server read the documentation at Mattermoster's Github repository.

Setting a Custom Slash Command in Mattermost

To create a Custom Slash Command, follow this instructions from Mattermost's documentation:

In Mattermost client (web or desktop application)...

1 - First, go to Main Menu > Integrations > Slash Commands. If you don’t have the Integrations option in your Main Menu, slash commands may not be enabled on your Mattermost server or may be disabled for non-admins. Enable them from System Console > Integrations > Custom Integrations or ask your System Administrator to do so.

2 - Click Add Slash Command and add name and description for the command.

3 - Set the Command Trigger Word. The trigger word must be unique and cannot begin with a slash or contain any spaces. It also cannot be one of the built-in commands.

Note:

Mattermoster ToDo Plugin Command Trigger Word is dependent on language set on Mattermoster API project.

To find out Command Trigger Word, navigate to Mattermoster_API_root > node_modules > mattermoster-todo-plugin > locales. Open the XX.json file of the language you set (defaults to 'en.json').

In XX.json look for "slash_command".

This is the Command Trigger Word you must use in Mattermost.

4 - Set the Request URL and Request Method. The request URL is the endpoint that Mattermost hits to reach your application, and the request method is either POST or GET and specifies the type of request sent to the request URL.

Note:

This is the host:port of your Mattermoster API server.

Request Method must be set to POST.

5 - (Optional) Set the response username and icon the command will post messages as in Mattermost. If not set, the command will use your username and profile picture.

6 - (Optional) Include the slash command in the command autocomplete list, displayed when typing / in an empty input box. Use it to make your command easier to discover by your teammates. You can also provide a hint listing the arguments of your command and a short description displayed in the autocomplete list.

7 - Hit Save.

You are done. Now try your new Custom Slash Command in any channel or direct message in Mattermost.

Development

Want to contribute? Great, we are waiting for your PRs.

$ git clone https://github.com/swordf1zh/mattermoster-todo-plugin.git
$ cd mattermoster-todo-plugin
$ npm install
$ npm run dev

Todos

  • Write tests
  • Expand troubleshooting section

Troubleshooting

If you are running Mattermoster in the same machine that is running Mattermost, you must modify Mattermost's config.json file to allow unstrusted internal connections.

License

MIT

Free Software, Hell Yeah!

mattermoster-todo-plugin's People

Contributors

oli-ver avatar tribal2 avatar

Watchers

 avatar  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.