github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/commands/shrug.go (about)

     1  package commands
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/keybase/client/go/chat/globals"
     7  	"github.com/keybase/client/go/protocol/chat1"
     8  	"github.com/keybase/client/go/protocol/gregor1"
     9  )
    10  
    11  type Shrug struct {
    12  	*baseCommand
    13  }
    14  
    15  func NewShrug(g *globals.Context) *Shrug {
    16  	return &Shrug{
    17  		baseCommand: newBaseCommand(g, "shrug", "", `Appends ¯\_(ツ)_/¯ to your message`, false),
    18  	}
    19  }
    20  
    21  func (s *Shrug) Execute(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
    22  	tlfName, text string, replyTo *chat1.MessageID) (err error) {
    23  	defer s.Trace(ctx, &err, "Execute")()
    24  	if !s.Match(ctx, text) {
    25  		return ErrInvalidCommand
    26  	}
    27  	_, msg, err := s.commandAndMessage(text)
    28  	if err != nil {
    29  		return err
    30  	}
    31  	res := `¯\_(ツ)_/¯`
    32  	if len(msg) > 0 {
    33  		res = msg + " " + res
    34  	}
    35  	_, err = s.G().ChatHelper.SendTextByIDNonblock(ctx, convID, tlfName, res, nil, replyTo)
    36  	return err
    37  }