forked from git.klmp200.net/ALFRED
Plugins in plugin folder
This commit is contained in:
parent
9b5c849dcc
commit
d43ffcb445
@ -4,6 +4,7 @@ pipeline:
|
|||||||
group: build
|
group: build
|
||||||
commands:
|
commands:
|
||||||
- go get -v -d ./...
|
- go get -v -d ./...
|
||||||
|
- sh build_plugins.sh
|
||||||
- go build .
|
- go build .
|
||||||
test:
|
test:
|
||||||
image: golang
|
image: golang
|
||||||
@ -12,6 +13,7 @@ pipeline:
|
|||||||
environment: [ test_api_token ]
|
environment: [ test_api_token ]
|
||||||
commands:
|
commands:
|
||||||
- go get -v -d ./...
|
- go get -v -d ./...
|
||||||
|
- sh build_plugins.sh
|
||||||
- go test ./...
|
- go test ./...
|
||||||
publish:
|
publish:
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
12
build_plugins.sh
Executable file
12
build_plugins.sh
Executable 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
|
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"./plugin_manager"
|
"../plugin_manager"
|
||||||
tb "gopkg.in/tucnak/telebot.v2"
|
tb "gopkg.in/tucnak/telebot.v2"
|
||||||
)
|
)
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
package plugin_manager
|
|
||||||
|
|
||||||
import (
|
|
||||||
tb "gopkg.in/tucnak/telebot.v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Context struct {
|
|
||||||
bot *tb.Bot
|
|
||||||
}
|
|
@ -21,13 +21,13 @@ type PluginCtrl struct {
|
|||||||
var pluginDir string
|
var pluginDir string
|
||||||
var pluginsRunning bool
|
var pluginsRunning bool
|
||||||
var plugins map[string]PluginCtrl
|
var plugins map[string]PluginCtrl
|
||||||
var context Context
|
var context *tb.Bot
|
||||||
|
|
||||||
func Init(_pluginDir string, bot *tb.Bot) {
|
func Init(_pluginDir string, bot *tb.Bot) {
|
||||||
pluginDir = _pluginDir
|
pluginDir = _pluginDir
|
||||||
pluginsRunning = false
|
pluginsRunning = false
|
||||||
plugins = make(map[string]PluginCtrl)
|
plugins = make(map[string]PluginCtrl)
|
||||||
context.bot = bot
|
context = bot
|
||||||
for _, fileName := range GetSoFiles(pluginDir) {
|
for _, fileName := range GetSoFiles(pluginDir) {
|
||||||
var p PluginCtrl
|
var p PluginCtrl
|
||||||
p.plugin = LoadSoFile(pluginDir + "/" + fileName)
|
p.plugin = LoadSoFile(pluginDir + "/" + fileName)
|
||||||
@ -111,10 +111,10 @@ func HandleMessage(msg *tb.Message) {
|
|||||||
split := strings.Split(msg.Text, " ")
|
split := strings.Split(msg.Text, " ")
|
||||||
split[0] = split[0][1:]
|
split[0] = split[0][1:]
|
||||||
if Contains(split[0], ExecGetCommands(val.plugin)) {
|
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 {
|
} else {
|
||||||
ExecHandleMessage(val.plugin, context.bot, msg)
|
ExecHandleMessage(val.plugin, context, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user