Skip to content

Commit

Permalink
Notify the IRC channel of loaded plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
enmand committed May 13, 2018
1 parent d2b2356 commit e43d73e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmd/quaridirc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func main() {
c.GetBool("irc.tls.verify"),
)

plugins, err := plugin.LoadPlugins(c.GetStringSlice("plugins_dirs"))
if err != nil {
logrus.Fatalf("error loading plugins: %s", err)
}

a.Handle(
[]adapter.Filter{
adapter.IRCFilter{
Expand All @@ -45,6 +50,11 @@ func main() {
Command: irc.IRC_JOIN,
Parameters: c.GetStringSlice("irc.channels"),
})

r.Write(&adapter.Event{
Command: irc.IRC_PRIVMSG,
Parameters: append(c.GetStringSlice("irc.channels"), fmt.Sprintf("hello, I have %d plugins loaded", len(plugins))),
})
},
)

Expand All @@ -70,13 +80,6 @@ func main() {

ircbot := bot.New([]adapter.Adapter{a})

plugins, err := plugin.LoadPlugins(c.GetStringSlice("plugin_dirs"))
if err != nil {
logrus.Fatalf("error loading plugins: %s", err)
}

fmt.Printf("%# v", plugins)

errCh := make(chan error)
go start(ircbot, errCh)

Expand Down

0 comments on commit e43d73e

Please sign in to comment.