diff --git a/main.go b/main.go index ffe57cd..af8b168 100644 --- a/main.go +++ b/main.go @@ -48,6 +48,7 @@ func main() { //bot := ircx.Classic(*server, *name) cfg := ircx.Config{User: *name, MaxRetries: 1000} bot := ircx.New(*server, *name, cfg) + log.Printf("%s started", SoftwareInfo()) log.Println("Logging in") if err := bot.Connect(); err != nil { log.Panicln("Unable to dial IRC Server:", err) @@ -124,10 +125,8 @@ func ConnectHandler(s ircx.Sender, m *irc.Message) { Params: []string{ch}, }) } - go func() { - time.Sleep(10 * time.Second) - sayCh <- fmt.Sprintf("%s\nflokati %s-%d", "*", version.FlokatiVersion, version.FlokatiBuild) - }() + time.Sleep(5 * time.Second) + sayCh <- fmt.Sprintf("%s\n*** %s", "*", SoftwareInfo()) } func PingHandler(s ircx.Sender, m *irc.Message) { @@ -141,8 +140,25 @@ 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) } + +func HandleMessage(m *irc.Message) { + tok := strings.Split(m.Trailing, " ") + if len(tok) < 1 { + return + } + switch tok[0] { + case "!version": + sayCh <- fmt.Sprintf("%s\n*** %s", "*", SoftwareInfo()) + default: + } +} + +func SoftwareInfo() string { + return fmt.Sprintf("flokatirc %s-%s", version.FlokatiVersion, version.FlokatiBuild) +}