Compare commits

...

1 Commits

Author SHA1 Message Date
Antoine Bartuccio d43ffcb445
Plugins in plugin folder
the build failed Details
2018-07-25 13:00:14 +02:00
7 changed files with 19 additions and 14 deletions

View File

@ -4,6 +4,7 @@ pipeline:
group: build
commands:
- go get -v -d ./...
- sh build_plugins.sh
- go build .
test:
image: golang
@ -12,6 +13,7 @@ pipeline:
environment: [ test_api_token ]
commands:
- go get -v -d ./...
- sh build_plugins.sh
- go test ./...
publish:
image: plugins/docker

12
build_plugins.sh Executable file
View File

@ -0,0 +1,12 @@
# @Author: Bartuccio Antoine
# @Date: 2018-07-25 12:47:23
# @Last Modified by: klmp200
# @Last Modified time: 2018-07-25 12:58:04
#!/bin/sh
cd plugin
rm -f *.so
FILES=`ls *.go`
for FILE in $FILES
do
go build -buildmode=plugin $FILE
done

View File

@ -1,7 +1,7 @@
package main
import (
"./plugin_manager"
"../plugin_manager"
tb "gopkg.in/tucnak/telebot.v2"
)

View File

@ -1,9 +0,0 @@
package plugin_manager
import (
tb "gopkg.in/tucnak/telebot.v2"
)
type Context struct {
bot *tb.Bot
}

View File

@ -21,13 +21,13 @@ type PluginCtrl struct {
var pluginDir string
var pluginsRunning bool
var plugins map[string]PluginCtrl
var context Context
var context *tb.Bot
func Init(_pluginDir string, bot *tb.Bot) {
pluginDir = _pluginDir
pluginsRunning = false
plugins = make(map[string]PluginCtrl)
context.bot = bot
context = bot
for _, fileName := range GetSoFiles(pluginDir) {
var p PluginCtrl
p.plugin = LoadSoFile(pluginDir + "/" + fileName)
@ -111,10 +111,10 @@ func HandleMessage(msg *tb.Message) {
split := strings.Split(msg.Text, " ")
split[0] = split[0][1:]
if Contains(split[0], ExecGetCommands(val.plugin)) {
ExecHandleCommand(val.plugin, context.bot, msg, split[0], split[1:])
ExecHandleCommand(val.plugin, context, msg, split[0], split[1:])
}
} else {
ExecHandleMessage(val.plugin, context.bot, msg)
ExecHandleMessage(val.plugin, context, msg)
}
}
}