forked from git.klmp200.net/ALFRED
Plugins in plugin folder
This commit is contained in:
parent
9b5c849dcc
commit
d43ffcb445
7 changed files with 19 additions and 14 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue