-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client::bot): ability to dispatch event through event command
- Loading branch information
1 parent
69f69db
commit 64768d4
Showing
3 changed files
with
46 additions
and
1 deletion.
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
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package bot | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/Necroforger/dgrouter/exrouter" | ||
"github.com/rumblefrog/source-chat-relay/server/protocol" | ||
"github.com/rumblefrog/source-chat-relay/server/relay" | ||
) | ||
|
||
func eventCommand(ctx *exrouter.Context) { | ||
if len(ctx.Args) < 2 { | ||
ctx.Reply("Missing arguments") | ||
|
||
return | ||
} | ||
|
||
channel, err := ctx.Channel(ctx.Msg.ChannelID) | ||
|
||
if err != nil { | ||
ctx.Reply("Unable to fetch channel") | ||
|
||
return | ||
} | ||
|
||
message := &protocol.EventMessage{ | ||
BaseMessage: protocol.BaseMessage{ | ||
Type: protocol.MessageChat, | ||
SenderID: ctx.Msg.ChannelID, | ||
EntityName: strings.Title(channel.Name), | ||
}, | ||
Event: ctx.Args.Get(0), | ||
Data: ctx.Args.Get(1), | ||
} | ||
|
||
relay.Instance.Router <- message | ||
} |