Commit 9357f3c4 authored by Benjamin Pill's avatar Benjamin Pill

Merge branch 'master' into 'master'

Added ability to include Channel's 'purpose' text

See merge request !2
parents 8c2f7505 87fb04c9
......@@ -2,7 +2,7 @@
"id": "mattermost-plugin-newchannelnotify",
"name": "New Channel Notify",
"description": "Notifies people for newly created channels",
"version": "0.9.2",
"version": "0.9.3",
"min_server_version": "5.10.0",
"server": {
"executables": {
......@@ -34,6 +34,13 @@
"help_text": "Trigger the bot for new private channels too",
"default": false
},
{
"key": "IncludeChannelPurpose",
"display_name": "Include purpose of the channel",
"type": "bool",
"help_text": "Add the Channel's purpose/description text to the announcement",
"default": false
},
{
"key": "Mention",
"display_name": "Mention",
......
......@@ -24,6 +24,7 @@ type configuration struct {
ChannelToPost string
BotUserName string
IncludePrivateChannels bool
IncludeChannelPurpose bool
Mention string
}
......
......@@ -31,6 +31,7 @@ func (p *NewChannelNotifyPlugin) ChannelHasBeenCreated(c *plugin.Context, channe
p.API.LogDebug(log)
config := p.getConfiguration()
ChannelPurpose := ""
if config.BotUserName == "" {
config.BotUserName = defaultBotName
......@@ -40,6 +41,10 @@ func (p *NewChannelNotifyPlugin) ChannelHasBeenCreated(c *plugin.Context, channe
config.ChannelToPost = model.DEFAULT_CHANNEL
}
if config.IncludeChannelPurpose == true && channel.Purpose != "" {
ChannelPurpose = "\n **" + channel.Name + "'s Purpose:** " + channel.Purpose
}
newChannelName := channel.Name
if channel.Type == model.CHANNEL_DIRECT || channel.Type == model.CHANNEL_GROUP {
......@@ -69,7 +74,7 @@ func (p *NewChannelNotifyPlugin) ChannelHasBeenCreated(c *plugin.Context, channe
post, err := p.API.CreatePost(&model.Post{
ChannelId: mainChannel.Id,
UserId: bot.Id,
Message: fmt.Sprintf("%sHello there :wave:. You might want to check out the new channel ~%s created by @%s :).", config.Mention, newChannelName, creator.Username),
Message: fmt.Sprintf("%sHello there :wave:. You might want to check out the new channel ~%s created by @%s %s", config.Mention, newChannelName, creator.Username, ChannelPurpose),
})
p.API.LogDebug(fmt.Sprintf("Created post %s", post.Id))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment