package main import ( "net/http" "github.com/gorilla/mux" "github.com/mattermost/mattermost/server/public/model" "github.com/mattermost/mattermost/server/public/plugin" "github.com/mattermost/mattermost/server/public/pluginapi" "github.com/fmartingr/mattermost-plugin-cleanup-channel/server/command" ) type Plugin struct { plugin.MattermostPlugin client *pluginapi.Client commandClient command.Command router *mux.Router } func (p *Plugin) OnActivate() error { p.client = pluginapi.NewClient(p.API, p.Driver) p.commandClient = command.NewCommandHandler(p.client, p.cleanupChannel) p.router = p.initRouter() return nil } func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) { response, err := p.commandClient.Handle(args) if err != nil { return nil, model.NewAppError("ExecuteCommand", "plugin.command.execute_command.app_error", nil, err.Error(), http.StatusInternalServerError) } return response, nil }