Commit 87fb04c9 authored by Aaron Rothschild's avatar Aaron Rothschild Committed by Benjamin Pill

Added ability to include Channel's 'purpose' text

parent 0810c219
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"id": "matttermost-plugin-newchannelnotify", "id": "matttermost-plugin-newchannelnotify",
"name": "New Channel Notify", "name": "New Channel Notify",
"description": "Notifies people for newly created channels", "description": "Notifies people for newly created channels",
"version": "0.9.2", "version": "0.9.3",
"min_server_version": "5.10.0", "min_server_version": "5.10.0",
"server": { "server": {
"executables": { "executables": {
...@@ -34,6 +34,13 @@ ...@@ -34,6 +34,13 @@
"help_text": "Trigger the bot for new private channels too", "help_text": "Trigger the bot for new private channels too",
"default": false "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", "key": "Mention",
"display_name": "Mention", "display_name": "Mention",
......
...@@ -24,6 +24,7 @@ type configuration struct { ...@@ -24,6 +24,7 @@ type configuration struct {
ChannelToPost string ChannelToPost string
BotUserName string BotUserName string
IncludePrivateChannels bool IncludePrivateChannels bool
IncludeChannelPurpose bool
Mention string Mention string
} }
......
...@@ -31,6 +31,7 @@ func (p *NewChannelNotifyPlugin) ChannelHasBeenCreated(c *plugin.Context, channe ...@@ -31,6 +31,7 @@ func (p *NewChannelNotifyPlugin) ChannelHasBeenCreated(c *plugin.Context, channe
p.API.LogDebug(log) p.API.LogDebug(log)
config := p.getConfiguration() config := p.getConfiguration()
ChannelPurpose := ""
if config.BotUserName == "" { if config.BotUserName == "" {
config.BotUserName = defaultBotName config.BotUserName = defaultBotName
...@@ -40,6 +41,10 @@ func (p *NewChannelNotifyPlugin) ChannelHasBeenCreated(c *plugin.Context, channe ...@@ -40,6 +41,10 @@ func (p *NewChannelNotifyPlugin) ChannelHasBeenCreated(c *plugin.Context, channe
config.ChannelToPost = model.DEFAULT_CHANNEL config.ChannelToPost = model.DEFAULT_CHANNEL
} }
if config.IncludeChannelPurpose == true && channel.Purpose != "" {
ChannelPurpose = "\n **" + channel.Name + "'s Purpose:** " + channel.Purpose
}
newChannelName := channel.Name newChannelName := channel.Name
if channel.Type == model.CHANNEL_DIRECT || channel.Type == model.CHANNEL_GROUP { if channel.Type == model.CHANNEL_DIRECT || channel.Type == model.CHANNEL_GROUP {
...@@ -69,7 +74,7 @@ func (p *NewChannelNotifyPlugin) ChannelHasBeenCreated(c *plugin.Context, channe ...@@ -69,7 +74,7 @@ func (p *NewChannelNotifyPlugin) ChannelHasBeenCreated(c *plugin.Context, channe
post, err := p.API.CreatePost(&model.Post{ post, err := p.API.CreatePost(&model.Post{
ChannelId: mainChannel.Id, ChannelId: mainChannel.Id,
UserId: bot.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)) 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