Skip to content

Commit

Permalink
Merge pull request #16 from aurumbot/development
Browse files Browse the repository at this point in the history
Merge Development -> Master for v1.2.0
  • Loading branch information
Whitman Huntley authored Oct 6, 2018
2 parents e92b169 + 04c5f7c commit 595b841
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module github.com/aurumbot/core

require (
github.com/aurumbot/flags v1.0.1
github.com/aurumbot/lib v1.0.0-beta.1
github.com/aurumbot/lib v1.0.0-beta.2
github.com/bwmarrin/discordgo v0.18.0
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ github.com/aurumbot/flags v1.0.1 h1:E0G/hPvRYWsYhucHSXA7QThgaEiqsPxlFI0cGk5byjs=
github.com/aurumbot/flags v1.0.1/go.mod h1:GL/p72gRpH3OVFO/yMRkDoMdrndsizeQCzxNeNHg958=
github.com/aurumbot/lib v1.0.0-beta.1 h1:tMZToXq1M2oGBNVnTM3PtltgL+f5lCzA2iwJSS/+6JU=
github.com/aurumbot/lib v1.0.0-beta.1/go.mod h1:13UHB9Z4X2zC5DHXAmw896seZlmVc914PdqRFq4nRBY=
github.com/aurumbot/lib v1.0.0-beta.1.0.20181002162019-1991551cc917 h1:EWDj1SJYyyQMefCnwPm2Fj6LCOiKguCAtv7S8rZScDo=
github.com/aurumbot/lib v1.0.0-beta.1.0.20181002162019-1991551cc917/go.mod h1:13UHB9Z4X2zC5DHXAmw896seZlmVc914PdqRFq4nRBY=
github.com/aurumbot/lib v1.0.0-beta.1.0.20181004164731-d270fcb69cb7 h1:R2K7DSI+59mcAHU1ODs20jHNwHflVNas4F1egazVxcQ=
github.com/aurumbot/lib v1.0.0-beta.1.0.20181004164731-d270fcb69cb7/go.mod h1:13UHB9Z4X2zC5DHXAmw896seZlmVc914PdqRFq4nRBY=
github.com/aurumbot/lib v1.0.0-beta.1.0.20181006163334-2d7df8930704 h1:+P1Y06bzY80ZdFMrzIrm1N5x0g+r5jZGmOKTHSIjEUg=
github.com/aurumbot/lib v1.0.0-beta.1.0.20181006163334-2d7df8930704/go.mod h1:13UHB9Z4X2zC5DHXAmw896seZlmVc914PdqRFq4nRBY=
github.com/aurumbot/lib v1.0.0-beta.2 h1:fWuTHWYJ5QfM8SDSXntwhuIs7PRPbf5KxeDUsRwYnQE=
github.com/aurumbot/lib v1.0.0-beta.2/go.mod h1:13UHB9Z4X2zC5DHXAmw896seZlmVc914PdqRFq4nRBY=
github.com/bwmarrin/discordgo v0.18.0 h1:XopVQXCIFy7Cr2eT7NcYcm4k0l2PYX+AP5RUbIWX2/8=
github.com/bwmarrin/discordgo v0.18.0/go.mod h1:5NIvFv5Z7HddYuXbuQegZ684DleQaCFqChP2iuBivJ8=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b h1:2b9XGzhjiYsYPnKXoEfL7klWZQIt8IfyRCz62gCqqlQ=
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 h1:Vk3wNqEZwyGyei9yq5ekj7frek2u7HUfffJ1/opblzc=
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
13 changes: 9 additions & 4 deletions goaurum
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _start() {
path=`grep "NAME=\"$1\"" $HOME/.aurumfile | perl -pe "s/^NAME=\"$1\":PATH=\"|\"$//g"`
cd $path
rm './dat/logs/nohup.out' >> /dev/null 2>&1
nohup ./.$1 >./dat/logs/nohup.out 2>&1 &
nohup ./.$1 $path >./dat/logs/nohup.out 2>&1 &
if [ $? -ne 0 ] ; then echo "Failed to start up $1" ; else echo "Started up $1." ; fi
cd -
}
Expand Down Expand Up @@ -49,6 +49,10 @@ _remove() {
}

_update() {
if [ "$EUID" -ne 0 ] ; then
echo "Goaurum's updater needs to run as root. Please use sudo."
exit 1
fi
mkdir $HOME/.autmp
cd $HOME/.autmp
if [ ! -z "$2" ] ; then
Expand Down Expand Up @@ -80,6 +84,7 @@ EOF
_stop $1 > /dev/null 2>&1
rm $path/.$1
env CGO_ENABLED=1 GO111MODULE=on go build -o $path/.$1 ./main.go
rm -rf $HOME/.autmp
if [ "$?" -ne "0" ] ; then exit 1 ; else echo "Successfully updated $1." ; fi
}

Expand All @@ -95,9 +100,9 @@ _installplugin() {
if [ $? -ne 0 ] ; then exit 1 ; fi
pluginname=`ls ./bin | perl -pe "s/\.so$//g"`
mv ./bin/* $path/plugins/
if [ -d ./json ] ; then
if [ -d ./dat ] ; then
mkdir $path/dat/cfg/$pluginname
mv ./json/* $path/dat/cfg/$pluginname
mv ./dat/* $path/dat/cfg/$pluginname/
fi
echo "Compiled and installed plugin to $1."
cd - >> /dev/null
Expand Down Expand Up @@ -258,7 +263,7 @@ _install() {
echo "Fetching most recent version of aurum"
mkdir ./.tmp
if [ ! -z `which git` ] ; then
git clone --branch $au_latestversion https://github.com/aurumbot/core.git ./.tmp/
git clone https://github.com/aurumbot/core.git ./.tmp/
if [ "$?" -ne "0" ] ; then echo "Error $? encountered when cloning latest version. Panicing." ; exit 1 ; fi
else
echo "You don't appear to have git. how does that work?" ; exit 1
Expand Down
10 changes: 3 additions & 7 deletions handler/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,19 @@ func init() {
Name: "Reload bot plugins",
Help: "Reloads plugins from the ./plugin directory.",
Perms: dsg.PermissionAdministrator,
Version: "1.0.",
Version: "1.0.0",
Action: func(session *dsg.Session, message *dsg.Message) {
err := reloadPlugins()
err := ReloadPlugins()
if err != nil {
dat.AlertDiscord(session, message, err)
} else {
session.ChannelMessageSend(message.ChannelID, "Successfully reloaded plugins")
}
},
}
err := reloadPlugins()
if err != nil {
dat.Log.Println(err)
}
}

func reloadPlugins() error {
func ReloadPlugins() error {
var files []string
// A painfully complex `ls`
filesUnchecked, err := ioutil.ReadDir("./plugins/")
Expand Down
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import (

var bot *f.Bot

func init() {
if len(os.Args) <= 2 {
dat.SetPath(os.Args[1])
}
}

func main() {
runBot()
// And the main should end here. so what to do about this?
Expand Down Expand Up @@ -44,6 +50,13 @@ func runBot() {
}
f.Session = dg
f.Config = *bot
dat.Log.Println("Loading Plugins")
err = cmd.ReloadPlugins()
if err != nil {
dat.Log.Fatalln(err)
} else {
dat.Log.Println("Successfully loaded plugins")
}

sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
Expand Down

0 comments on commit 595b841

Please sign in to comment.