mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 10:36:44 +01:00
Plugins in plugin folder
This commit is contained in:
parent
9b5c849dcc
commit
d43ffcb445
@ -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
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
|
||||
|
||||
import (
|
||||
"./plugin_manager"
|
||||
"../plugin_manager"
|
||||
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 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user