Skip to content

Commit

Permalink
changing common for set command now
Browse files Browse the repository at this point in the history
	Most likely going to remove common plugins and move everything into the bot package so it integrated into it.

Refs #21
  • Loading branch information
dmportella committed Sep 22, 2016
1 parent 734ce30 commit e87b85c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
20 changes: 0 additions & 20 deletions plugins/common/common_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ func NewPlugin(qilbot *bot.Qilbot) (plugin *Plugin) {
plugin.setCommand(s, m, commandText)
},
},
{
Command: "get",
Template: "!get-variables",
Description: "Returns a list of available settings on Qilbot.",
Execute: func(s *bot.DiscordSession, m *discordgo.MessageCreate, commandText string) {
plugin.getCommand(s, m, commandText)
},
},
},
},
}
Expand Down Expand Up @@ -108,15 +100,3 @@ func (plugin *Plugin) setCommand(s *bot.DiscordSession, m *discordgo.MessageCrea

s.RespondToUser(m, buffer.String())
}

func (plugin *Plugin) getCommand(s *bot.DiscordSession, m *discordgo.MessageCreate, commandText string) {
var buffer bytes.Buffer

if s.IsOwnerOfGuild(m) {
buffer.WriteString("This would have done something.")
} else {
buffer.WriteString("Only the Server owner can change the bot settings...")
}

s.RespondToUser(m, buffer.String())
}
15 changes: 15 additions & 0 deletions plugins/common/regex_func.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package common

import (
"regexp"
)

const (
keyValueCommandRegex = `^(\w+)\s?(.*)`
)

// regexMatchKeyValueCommand matches a key value pair.
func regexMatchKeyValueCommand(msg string) []string {
placesPattern := regexp.MustCompile(keyValueCommandRegex)
return placesPattern.FindStringSubmatch(msg)
}

0 comments on commit e87b85c

Please sign in to comment.