mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
added text formatting (bold & italic) for normal/native mode
This commit is contained in:
@@ -295,7 +295,7 @@ func (s *MessageMention) toString() string {
|
||||
|
||||
func (s *SignalClient) send(number string, message string,
|
||||
recipients []string, base64Attachments []string, isGroup bool, sticker string, mentions []MessageMention,
|
||||
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []MessageMention) (*SendResponse, error) {
|
||||
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []MessageMention, textMode *string) (*SendResponse, error) {
|
||||
|
||||
var resp SendResponse
|
||||
|
||||
@@ -303,6 +303,11 @@ func (s *SignalClient) send(number string, message string,
|
||||
return nil, errors.New("Please specify at least one recipient")
|
||||
}
|
||||
|
||||
signalCliTextFormatStrings := []string{}
|
||||
if textMode != nil && *textMode == "styled" {
|
||||
message, signalCliTextFormatStrings = utils.ParseMarkdownMessage(message)
|
||||
}
|
||||
|
||||
var groupId string = ""
|
||||
if isGroup {
|
||||
if len(recipients) > 1 {
|
||||
@@ -400,6 +405,11 @@ func (s *SignalClient) send(number string, message string,
|
||||
cmd = append(cmd, []string{"-g", groupId}...)
|
||||
}
|
||||
|
||||
if len(signalCliTextFormatStrings) > 0 {
|
||||
cmd = append(cmd, "--text-style")
|
||||
cmd = append(cmd, signalCliTextFormatStrings...)
|
||||
}
|
||||
|
||||
if len(attachmentEntries) > 0 {
|
||||
cmd = append(cmd, "-a")
|
||||
for _, attachmentEntry := range attachmentEntries {
|
||||
@@ -527,7 +537,7 @@ func (s *SignalClient) VerifyRegisteredNumber(number string, token string, pin s
|
||||
}
|
||||
|
||||
func (s *SignalClient) SendV1(number string, message string, recipients []string, base64Attachments []string, isGroup bool) (*SendResponse, error) {
|
||||
timestamp, err := s.send(number, message, recipients, base64Attachments, isGroup, "", nil, nil, nil, nil, nil)
|
||||
timestamp, err := s.send(number, message, recipients, base64Attachments, isGroup, "", nil, nil, nil, nil, nil, nil)
|
||||
return timestamp, err
|
||||
}
|
||||
|
||||
@@ -547,7 +557,7 @@ func (s *SignalClient) getJsonRpc2Clients() []*JsonRpc2Client {
|
||||
}
|
||||
|
||||
func (s *SignalClient) SendV2(number string, message string, recps []string, base64Attachments []string, sticker string, mentions []MessageMention,
|
||||
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []MessageMention) (*[]SendResponse, error) {
|
||||
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []MessageMention, textMode *string) (*[]SendResponse, error) {
|
||||
if len(recps) == 0 {
|
||||
return nil, errors.New("Please provide at least one recipient")
|
||||
}
|
||||
@@ -577,7 +587,7 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
||||
|
||||
timestamps := []SendResponse{}
|
||||
for _, group := range groups {
|
||||
timestamp, err := s.send(number, message, []string{group}, base64Attachments, true, sticker, mentions, quoteTimestamp, quoteAuthor, quoteMessage, quoteMentions)
|
||||
timestamp, err := s.send(number, message, []string{group}, base64Attachments, true, sticker, mentions, quoteTimestamp, quoteAuthor, quoteMessage, quoteMentions, textMode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -585,7 +595,7 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
||||
}
|
||||
|
||||
if len(recipients) > 0 {
|
||||
timestamp, err := s.send(number, message, recipients, base64Attachments, false, sticker, mentions, quoteTimestamp, quoteAuthor, quoteMessage, quoteMentions)
|
||||
timestamp, err := s.send(number, message, recipients, base64Attachments, false, sticker, mentions, quoteTimestamp, quoteAuthor, quoteMessage, quoteMentions, textMode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user