Exemple #1
0
func (c *Config) handleModule(b core.Bot, m *slack.Message) error {
	moduleText := "currently loaded modules:\n"
	for key := range b.LoadedModules() {
		moduleText = moduleText + fmt.Sprintf("> `%s`\n", key)
	}
	return b.Say(m.Channel, moduleText)
}
Exemple #2
0
func (c *Config) handleUnloadModule(b core.Bot, m *slack.Message) error {
	messageWithoutMentions := util.TrimWhitespace(core.LessMentions(m.Text))
	parts := core.ExtractSubMatches(messageWithoutMentions, "^module:unload (.+)")
	if len(parts) < 2 {
		return exception.Newf("malformed message for `%s`", ActionModuleUnload)
	}

	key := parts[1]
	if !b.LoadedModules().Contains(key) {
		return b.Sayf(m.Channel, "Module `%s` isn't loaded.", key)
	}
	if !b.RegisteredModules().Contains(key) {
		return b.Sayf(m.Channel, "Module `%s` isn't registered.", key)
	}

	b.UnloadModule(key)
	return b.Sayf(m.Channel, "Unloaded Module `%s`.", key)
}