Plugins in plugin folder
the build failed Details

This commit is contained in:
Antoine Bartuccio 2018-07-25 12:59:22 +02:00
parent 9b5c849dcc
commit 8757f7c6aa
Signed by: klmp200
GPG Key ID: E7245548C53F904B
7 changed files with 19 additions and 14 deletions

View File

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

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)
}
}
}