Debian Codegraph @

pkg/services/chat/signal/signal_textmode.go

raw
1 package signal
2
3 import (
4 "github.com/nicholas-fedor/shoutrrr/pkg/format"
5 "github.com/nicholas-fedor/shoutrrr/pkg/types"
6 )
7
8 // textMode is the signal-cli-rest-api text_mode value.
9 type textMode int
10
11 // textModeVals holds named text mode values and their enum formatter.
12 type textModeVals struct {
13 // None omits text_mode so the server default applies.
14 None textMode
15 // Normal sends text_mode=normal.
16 Normal textMode
17 // Styled sends text_mode=styled.
18 Styled textMode
19 // Enum formats and parses text mode values.
20 Enum types.EnumFormatter
21 }
22
23 const (
24 // TextModeNone omits the JSON text_mode field.
25 TextModeNone textMode = iota
26 // TextModeNormal sends plaintext to the API.
27 TextModeNormal
28 // TextModeStyled enables styled markup in the message body.
29 TextModeStyled
30 )
31
32 // TextModes is the enum helper for textMode.
33 var TextModes = &textModeVals{
34 None: TextModeNone,
35 Normal: TextModeNormal,
36 Styled: TextModeStyled,
37 Enum: format.CreateEnumFormatter(
38 []string{
39 "None",
40 "Normal",
41 "Styled",
42 },
43 ),
44 }
45
46 // String returns the config enum name for this text mode.
47 //
48 // Returns:
49 // - None, Normal, Styled, or Invalid.
50 func (tm textMode) String() string {
51 return TextModes.Enum.Print(int(tm))
52 }
53
54 // payloadValue returns the JSON text_mode value, or empty to omit the field.
55 //
56 // Returns:
57 // - "normal", "styled", or "".
58 func (tm textMode) payloadValue() string {
59 switch tm {
60 case TextModeNone:
61 return ""
62 case TextModeNormal:
63 return "normal"
64 case TextModeStyled:
65 return "styled"
66 default:
67 return ""
68 }
69 }