Mattermost Hostinfo Plugin
This plugin has been based off Mattermost Plugin Starter Template repository.
To learn more about plugins, see our plugin documentation.
What does it do?
The hostinfo plugin provides information about a host (via dns domain name or ip address). In its first draft it provides the geoip address, however incremnetal feature enhancements are planned for the future.
Mattermost Hostinfobot Plugin - Slash Command Help
/hostinfo show [ip address] - retrieves and presents information about the given ip address.
/hostinfo show [DNS domain] - retrieves and presents information about the given DNS domain.
/hostinfo help - shows this help information.
Development
To avoid having to manually install your plugin, build and deploy your plugin using one of the following options.
Deploying with Local Mode
If your Mattermost server is running locally, you can enable local mode to streamline deploying your plugin. Edit your server configuration as follows:
{
"ServiceSettings": {
...
"EnableLocalMode": true,
"LocalModeSocketLocation": "/var/tmp/mattermost_local.socket"
}
}
and then deploy your plugin:
make deploy
You may also customize the Unix socket path:
export MM_LOCALSOCKETPATH=/var/tmp/alternate_local.socket
make deploy
If developing a plugin with a webapp, watch for changes and deploy those automatically:
export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_TOKEN=j44acwd8obn78cdcx7koid4jkr
make watch
Deploying with credentials
Alternatively, you can authenticate with the server's API with credentials:
export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_USERNAME=admin
export MM_ADMIN_PASSWORD=password
make deploy
or with a personal access token:
export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_TOKEN=j44acwd8obn78cdcx7koid4jkr
make deploy
Q&A
How do I make a server-only or web app-only plugin?
Simply delete the server
or webapp
folders and remove the corresponding sections from plugin.json
. The build scripts will skip the missing portions automatically.
How do I include assets in the plugin bundle?
Place them into the assets
directory. To use an asset at runtime, build the path to your asset and open as a regular file:
bundlePath, err := p.API.GetBundlePath()
if err != nil {
return errors.Wrap(err, "failed to get bundle path")
}
profileImage, err := ioutil.ReadFile(filepath.Join(bundlePath, "assets", "profile_image.png"))
if err != nil {
return errors.Wrap(err, "failed to read profile image")
}
if appErr := p.API.SetProfileImage(userID, profileImage); appErr != nil {
return errors.Wrap(err, "failed to set profile image")
}
How do I build the plugin with unminified JavaScript?
Use make dist-debug
and make deploy-debug
in place of make dist
and make deploy
to configure webpack to generate unminified Javascript.