-
-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the bees CreateEvent method in ircbee.go
Another example for the usage of the new CreateEvent method which comes in pretty handy.
- Loading branch information
Showing
1 changed file
with
12 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
* | ||
* Authors: | ||
* Christian Muehlhaeuser <[email protected]> | ||
* Nicolas Martin <[email protected]> | ||
*/ | ||
|
||
// Package ircbee is a Bee that can connect to an IRC server. | ||
|
@@ -153,23 +154,12 @@ func (mod *IrcBee) statusChange(eventChan chan bees.Event, conn *irc.Conn, line | |
|
||
channel := line.Args[0] | ||
user := line.Src[:strings.Index(line.Src, "!")] | ||
ev := bees.Event{ | ||
Bee: mod.Name(), | ||
Name: strings.ToLower(line.Cmd), | ||
Options: []bees.Placeholder{ | ||
{ | ||
Name: "channel", | ||
Type: "string", | ||
Value: channel, | ||
}, | ||
{ | ||
Name: "user", | ||
Type: "string", | ||
Value: user, | ||
}, | ||
}, | ||
|
||
properties := map[string]interface{}{ | ||
"channel": channel, | ||
"user": user, | ||
} | ||
eventChan <- ev | ||
eventChan <- mod.CreateEvent(strings.ToLower(line.Cmd), properties) | ||
} | ||
|
||
// Run executes the Bee's event loop. | ||
|
@@ -226,33 +216,12 @@ func (mod *IrcBee) Run(eventChan chan bees.Event) { | |
user := line.Src[:strings.Index(line.Src, "!")] | ||
hostmask := line.Src[strings.Index(line.Src, "!")+2:] | ||
|
||
ev := bees.Event{ | ||
Bee: mod.Name(), | ||
Name: "message", | ||
Options: []bees.Placeholder{ | ||
{ | ||
Name: "channel", | ||
Type: "string", | ||
Value: channel, | ||
}, | ||
{ | ||
Name: "user", | ||
Type: "string", | ||
Value: user, | ||
}, | ||
{ | ||
Name: "hostmask", | ||
Type: "string", | ||
Value: hostmask, | ||
}, | ||
{ | ||
Name: "text", | ||
Type: "string", | ||
Value: msg, | ||
}, | ||
}, | ||
} | ||
eventChan <- ev | ||
eventChan <- mod.CreateEvent("message", map[string]interface{}{ | ||
"channel": channel, | ||
"user": user, | ||
"hostmask": hostmask, | ||
"text": msg, | ||
}) | ||
}) | ||
|
||
waitForDisconnect := false | ||
|