commit 65e10c4665d32d325c0a174999bef69ac89e0ab4 parent 96b801ae47c442691635467f2607d3e11e4b8267 Author: sin <sin@2f30.org> Date: Fri, 3 May 2013 13:12:07 +0100 add error checking Diffstat:
M | src/irc/events.go | | | 9 | ++++++++- |
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/irc/events.go b/src/irc/events.go @@ -13,9 +13,16 @@ type IrcEvent struct { Fn func(IrcMessage) } -func (i *IrcContext) AddEventHandler(ev IrcEvent) { +func (i *IrcContext) AddEventHandler(ev IrcEvent) error { + for j := 0; j < i.evnum; j++ { + if i.ev[j].Command == ev.Command { + return fmt.Errorf("Event %s already handled", + ev.Command) + } + } i.ev = append(i.ev, ev) i.evnum++ + return nil } func (i *IrcContext) DelEventHandler(ev *IrcEvent) error {