mirror of
https://code.dnix.de/da/flokatirc
synced 2026-07-27 07:39:44 +02:00
Rework of module system.
This commit is contained in:
@@ -16,15 +16,8 @@ import (
|
||||
"github.com/nickvanw/ircx"
|
||||
"github.com/sorcix/irc"
|
||||
|
||||
"flokatirc/modules"
|
||||
"flokatirc/version"
|
||||
|
||||
modfortune "flokatirc/modules/fortune"
|
||||
modrss "flokatirc/modules/rss"
|
||||
modsaytime "flokatirc/modules/saytime"
|
||||
modsc "flokatirc/modules/sc"
|
||||
modstoll "flokatirc/modules/stoll"
|
||||
modtwitch "flokatirc/modules/twitch"
|
||||
modweather "flokatirc/modules/weather"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -33,7 +26,7 @@ var (
|
||||
channels = flag.String("chan", "#test", "Channels to join")
|
||||
nsname = flag.String("nsname", "NickServ", "NickServ name")
|
||||
nspass = flag.String("nspass", "", "NickServ password")
|
||||
modules = flag.String("modules", "rss,starcitizen,fortune,saytime", "Module list, comma separated")
|
||||
params = flag.String("params", "", "Module params")
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -59,28 +52,7 @@ func main() {
|
||||
//mods := strings.Split(*modules, ",")
|
||||
//TODO: implement more robust list parsing
|
||||
|
||||
//XXX: this sucks
|
||||
if strings.Contains(*modules, "rss") {
|
||||
go modrss.Init(sayCh, "newsfeeds.conf")
|
||||
}
|
||||
if strings.Contains(*modules, "starcitizen") {
|
||||
go modsc.Init(sayCh)
|
||||
}
|
||||
if strings.Contains(*modules, "fortune") {
|
||||
go modfortune.Init(sayCh)
|
||||
}
|
||||
if strings.Contains(*modules, "stoll") {
|
||||
go modstoll.Init(sayCh)
|
||||
}
|
||||
if strings.Contains(*modules, "saytime") {
|
||||
go modsaytime.Init(sayCh)
|
||||
}
|
||||
if strings.Contains(*modules, "twitch") {
|
||||
go modtwitch.Init(sayCh)
|
||||
}
|
||||
if strings.Contains(*modules, "weather") {
|
||||
go modweather.Init(sayCh)
|
||||
}
|
||||
modules.Initialize(sayCh)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
@@ -150,12 +122,7 @@ func PingHandler(s ircx.Sender, m *irc.Message) {
|
||||
func PrivmsgHandler(s ircx.Sender, m *irc.Message) {
|
||||
//TODO: implement message handler table
|
||||
HandleMessage(m)
|
||||
modsc.HandleMessage(m)
|
||||
modfortune.HandleMessage(m)
|
||||
modstoll.HandleMessage(m)
|
||||
modsaytime.HandleMessage(m)
|
||||
modtwitch.HandleMessage(m)
|
||||
modweather.HandleMessage(m)
|
||||
modules.HandleMessage(m)
|
||||
}
|
||||
|
||||
func HandleMessage(m *irc.Message) {
|
||||
|
||||
Reference in New Issue
Block a user