Mirror of github.com/gissleh/irc
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.

32 lines
560 B

  1. package irctest
  2. import "github.com/gissleh/irc"
  3. type EventLog struct {
  4. events []*irc.Event
  5. }
  6. func (l *EventLog) First(kind, verb string) *irc.Event {
  7. for _, e := range l.events {
  8. if e.Verb() == verb && e.Kind() == kind {
  9. return e
  10. }
  11. }
  12. return nil
  13. }
  14. func (l *EventLog) Last(kind, verb string) *irc.Event {
  15. for i := len(l.events) - 1; i >= 0; i-- {
  16. e := l.events[i]
  17. if e.Verb() == verb && e.Kind() == kind {
  18. return e
  19. }
  20. }
  21. return nil
  22. }
  23. func (l *EventLog) Handler(event *irc.Event, _ *irc.Client) {
  24. l.events = append(l.events, event)
  25. }