!version cmd added.

This commit is contained in:
Andreas Neue 2016-01-20 07:34:40 +01:00
parent e05446aa34
commit 3982d4e877
1 changed files with 20 additions and 4 deletions

24
main.go
View File

@ -48,6 +48,7 @@ func main() {
//bot := ircx.Classic(*server, *name) //bot := ircx.Classic(*server, *name)
cfg := ircx.Config{User: *name, MaxRetries: 1000} cfg := ircx.Config{User: *name, MaxRetries: 1000}
bot := ircx.New(*server, *name, cfg) bot := ircx.New(*server, *name, cfg)
log.Printf("%s started", SoftwareInfo())
log.Println("Logging in") log.Println("Logging in")
if err := bot.Connect(); err != nil { if err := bot.Connect(); err != nil {
log.Panicln("Unable to dial IRC Server:", err) log.Panicln("Unable to dial IRC Server:", err)
@ -124,10 +125,8 @@ func ConnectHandler(s ircx.Sender, m *irc.Message) {
Params: []string{ch}, Params: []string{ch},
}) })
} }
go func() { time.Sleep(5 * time.Second)
time.Sleep(10 * time.Second) sayCh <- fmt.Sprintf("%s\n*** %s", "*", SoftwareInfo())
sayCh <- fmt.Sprintf("%s\nflokati %s-%d", "*", version.FlokatiVersion, version.FlokatiBuild)
}()
} }
func PingHandler(s ircx.Sender, m *irc.Message) { 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) { func PrivmsgHandler(s ircx.Sender, m *irc.Message) {
//TODO: implement message handler table //TODO: implement message handler table
HandleMessage(m)
modsc.HandleMessage(m) modsc.HandleMessage(m)
modfortune.HandleMessage(m) modfortune.HandleMessage(m)
modstoll.HandleMessage(m) modstoll.HandleMessage(m)
modsaytime.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)
}