main.go 903 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "github.com/whyrusleeping/hellabot"
  6. )
  7. func main() {
  8. nick := flag.String("nick", "longBot", "nickname for the bot")
  9. serv := flag.String("server", "irc.defcamp.ro:6667", "hostname and port for irc server to connect to")
  10. ichan := flag.String("chan", "#longdev", "channel for bot to join")
  11. flag.Parse()
  12. irc, err := hbot.NewIrcConnection(*serv, *nick, false)
  13. if err != nil {
  14. panic(err)
  15. }
  16. // Say a message from a file when prompted
  17. irc.AddTrigger(OpPeople)
  18. irc.AddTrigger(FollowInvite)
  19. irc.AddTrigger(TopScore)
  20. // Start up bot
  21. irc.Start()
  22. // Join a channel
  23. mychannel := irc.Join(*ichan)
  24. mychannel.Say("here2serve")
  25. // Read off messages from the server
  26. for mes := range irc.Incoming {
  27. if mes == nil {
  28. fmt.Println("Disconnected.")
  29. return
  30. }
  31. // Log raw message struct
  32. fmt.Printf("%+v\n", mes)
  33. }
  34. fmt.Println("Bot shutting down.")
  35. }