The server component of this demo plugin is written in Go and net/rpc. It relies on configuration in plugin.json to implement each of the supported hooks.
Each of the included files or folders is outlined below.
These are metadata files managed by vgo for dependency management. While vgo is currently in beta, it will launch as part of the standard Go 1.11 tooling and stabilize in subsequent releases. It was preferred for this project over dep since it does not require locating your plugin in the $GOPATH
.
This is the entry point of your plugin binary, that in turn invokes plugin.ClientMain to wire up RPC communication between your plugin and the Mattermost Server.
This is a file generated by the build/manifest tool that captures the plugin id from plugin.json. It simplifies the need to hard-code the plugin id in multiple places by exporting a constant for use instead.
This file defines the Plugin
struct, embedding plugin.MattermostPlugin to automatically handle the wiring up the API when the plugin starts. It contains public fields that are automatically unmarshalled from plugin.json as part of the OnConfiguration
hook in configuration.go.
This demo implementation logs a message to the demo channel whenever the plugin is activated.
This demo implementation logs a message to the demo channel whenever the plugin is deactivated.
This demo implementation ensures the configured demo user and channel are created for use by the plugin. Also, if a configuration change is detected then the plugin will log a message to the demo channel with the updated configuration values.
This demo implementation logs a message to the demo channel whenever a channel is created.
This demo implementation logs a message to the demo channel whenever a user joins a channel.
This demo implementation logs a message to the demo channel whenever a user leaves a channel.
This demo implementation responds to a /demo_plugin
command, allowing the user to enable
or disable the demo plugin's hooks functionality (but leave the command and webapp enabled).
The /ephemeral
command demonstrates ephemeral interactive usage of SendEphemeralPost,
UpdateEphemeralPost, and DeleteEphemeralPost.
The /crash
command demonstrates crashing the plugin (and the server recovering/restarting the plugin).
This demo implementation sends back whether or not the plugin hooks are currently enabled. It is used by the web app to recover from a network reconnection and synchronize the state of the plugin's hooks.
This demo implementation rejects posts in the demo channel, as well as posts that @-mention the demo plugin user.
This demo implementation rejects posts that @-mention the demo plugin user.
This demo implementation logs a message to the demo channel whenever a message is posted, unless by the demo plugin user itself.
This demo implementation logs a message to the demo channel whenever a message is updated, unless by the demo plugin user itself.
This demo implementation logs a message to the demo channel in the team whenever a user joins the team.
This demo implementation logs a message to the demo channel in the team whenever a user leaves the team.
This demo implementation rejects login attempts by the demo user.
This demo implementation logs a message to the demo channel whenever a user logs in.
This demo implementation logs a message to demo channel whenever a new user is created.
This demo implementation logs a message to demo channel whenever a file is uploaded.
The following settings are available in the demo plugin system console page to demonstrate what is available via the Mattermost Plugin Settings Schema.
A text
setting type to define the channel that the demo plugin will create and use to post messages.
A text
setting type to define the username value that will be given to the demo user.
A radio
setting type to define the last name value that will be given to the demo user.
A dropdown
setting type that changes the text style of messages posted by the demo plugin. Options include italics and bold.
A generated
setting type for a random string that can be generated in the demo plugin settings page of the system console. The demo plugin will look for this value in any message posted and will paste the secret message to the demo channel when it is found.
A longtext
setting type to define the message that is posted to the demo channel when the random secret is posted.
A bool
setting type to control whether the mention user is tagged(@'ed) on all demo plugin messages.
A username
setting type to define the user that will be tagged(@'ed) on all demo plugin messages.