3
0
2021-01-25 18:05:24 +01:00

56 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package service
import (
"context"
"github.com/cortezaproject/corteza-server/messaging/types"
)
type (
command struct {
}
CommandService interface {
Do(ctx context.Context, channelID uint64, command, input string) (*types.Message, error)
}
)
func Command() CommandService {
return &command{}
}
func (svc command) Do(ctx context.Context, channelID uint64, command, input string) (*types.Message, error) {
switch command {
case "me":
if input != "" {
return DefaultMessage.Create(ctx, &types.Message{
Type: types.MessageTypeIlleism,
ChannelID: channelID,
Message: input,
})
}
return nil, nil
case "tableflip":
fallthrough
case "unflip":
fallthrough
case "shrug":
messages := map[string]string{
"tableflip": `(╯°□°)╯︵ ┻━┻`,
"unflip": `┬─┬ ( ゜-゜ノ)`,
"shrug": `¯\\_(ツ)_/¯`,
}
msg := &types.Message{
ChannelID: channelID,
Message: messages[command],
}
if input != "" {
msg.Message = input + " " + msg.Message
}
return DefaultMessage.Create(ctx, msg)
}
return nil, nil
}