Skip to content

Commit

Permalink
adding command settings
Browse files Browse the repository at this point in the history
	planning to replace the discord session object and just force the plugin to call qilbot methods that can control the access to features etc eg encapsulate there

Ref #21
  • Loading branch information
dmportella committed Sep 20, 2016
1 parent b21dae7 commit 3e0bfda
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
9 changes: 5 additions & 4 deletions bot/qilbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ type Qilbot struct {

// Privates

stopChannel chan struct{}
config *QilbotConfig
session *DiscordSession
commands map[string]*CommandInformation
stopChannel chan struct{}
config *QilbotConfig
session *DiscordSession
commands map[string]*CommandInformation
commandSettings map[string]*commandSettings
}

// QilbotConfig representation of the configuration for qilbot.
Expand Down
9 changes: 5 additions & 4 deletions bot/qilbot_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
// New creates a new instance of Qilbot
func New(config *QilbotConfig) (bot *Qilbot, err error) {
bot = &Qilbot{
config: config,
Plugins: []IPlugin{},
stopChannel: make(chan struct{}),
commands: make(map[string]*CommandInformation),
config: config,
Plugins: []IPlugin{},
stopChannel: make(chan struct{}),
commands: make(map[string]*CommandInformation),
commandSettings: make(map[string]*commandSettings),
}

// Create a new Discord session using the provided login information.
Expand Down
7 changes: 7 additions & 0 deletions bot/qilbotsettings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package bot

type commandSettings struct {
OnlyUsableOnChannelID string
OnlyUsableOnDirectMessage bool
Disabled bool
}
1 change: 1 addition & 0 deletions bot/qilbotsettings_func.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package bot
7 changes: 7 additions & 0 deletions utilities/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utilities
import (
"io/ioutil"
"os"
"path/filepath"
)

// DefaultPermissions Permissions for file and directory creations.
Expand All @@ -22,6 +23,12 @@ func FileOrDirectoryExists(path string) (bool, error) {
return true, err
}

// GetCurrentFolder Returns the
func GetCurrentFolder() (string, error) {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
return dir, err
}

// SaveToFile Saves a byte array to a path.
func SaveToFile(data []byte, path string) error {
return ioutil.WriteFile(path, data, DefaultPermissions)
Expand Down

0 comments on commit 3e0bfda

Please sign in to comment.