Add a prefix adapter to implement ! commands and ignoring help in public channels

This commit is contained in:
2016-10-15 01:31:11 +01:00
parent 60b647a42f
commit c208a0e00c
2 changed files with 74 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ import (
"github.com/tcolgate/hugot"
"github.com/tcolgate/hugot/adapters/irc"
"ur.gs/lysenko/adapters"
"ur.gs/lysenko/handlers/deadline"
"ur.gs/lysenko/handlers/quotedb"
)
@@ -53,6 +54,11 @@ func main() {
}
adapter := irc.New(config, channelList...)
prefix_adapter := adapters.NewPrefixAdapter(adapter, "!")
prefix_adapter.PrivateHelpOnly = true
ctx := context.Background()
go prefix_adapter.Run(ctx)
db, err := quotedb.New(*quotes)
if err != nil {
@@ -67,5 +73,5 @@ func main() {
mux.HandleCommand(deadline.NewCommand(&quotedb.RandQuoteHandler{QuoteDB: db}))
mux.HandleCommand(deadline.NewCommand(&quotedb.QuoteHandler{QuoteDB: db}))
hugot.ListenAndServe(context.Background(), mux, adapter)
hugot.ListenAndServe(ctx, mux, prefix_adapter)
}