The new logbot, not committed from the wrong terminal window this time.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
503 B

6 years ago
  1. package bot
  2. import (
  3. "log"
  4. "strings"
  5. "git.aiterp.net/gisle/irc"
  6. )
  7. func handler(event *irc.Event, client *irc.Client) {
  8. bot, ok := client.Value(botKey).(*Bot)
  9. if !ok {
  10. return
  11. }
  12. if event.Kind() == "packet" && len(event.Verb()) == 3 {
  13. log.Printf("(%s) %s %s\n", event.Verb(), strings.Join(event.Args[1:], " "), event.Text)
  14. }
  15. switch event.Name() {
  16. case "hook.ready":
  17. {
  18. go bot.loop()
  19. }
  20. case "client.disconnect":
  21. {
  22. bot.stopLoop()
  23. }
  24. }
  25. }
  26. func init() {
  27. irc.Handle(handler)
  28. }