-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddee7ac
commit 61dfe70
Showing
2 changed files
with
62 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package command | ||
|
||
import ( | ||
"context" | ||
"log/slog" | ||
) | ||
|
||
// EchoIn sends a plain text message to any channel. | ||
// - in: Name of the channel to send to. | ||
// - msg: Message to send. | ||
func EchoIn(ctx context.Context, robo *Robot, call *Invocation) { | ||
t := call.Args["in"] | ||
ch := robo.Channels[t] | ||
if ch == nil { | ||
robo.Log.WarnContext(ctx, "echo into unknown channel", slog.String("target", t)) | ||
return | ||
} | ||
ch.Message(ctx, "", call.Args["msg"]) | ||
} | ||
|
||
// Echo sends a plain text message to the channel in which it is invoked. | ||
// - msg: Message to send. | ||
func Echo(ctx context.Context, robo *Robot, call *Invocation) { | ||
call.Channel.Message(ctx, "", call.Args["msg"]) | ||
} |
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