Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateRandomString(args *GenerateRandomStringArgs) string
- func PtrBool(b bool) *bool
- func RandomInt(min, max int64) int64
- type Action
- type Behavior
- type Button
- type Card
- type CardLink
- type Color
- type Column
- type ColumnSet
- type Config
- type ConfigColor
- type Element
- type GenerateRandomStringArgs
- type Header
- type I18n
- type I18nElements
- type Icon
- type LarkClient
- type LarkLogger
- type Notification
- func (n *Notification) ConfigFields() []plugin.ConfigField
- func (n *Notification) ConfigReceiver(config []byte) error
- func (n *Notification) GetNewQuestionSubscribers() (userIDs []string)
- func (n Notification) Info() plugin.Info
- func (n *Notification) LarkWsEventHub() *dispatcher.EventDispatcher
- func (n *Notification) LarkWsEventMenuClick(ctx context.Context, event *larkApplication.P2BotMenuV6) error
- func (n *Notification) Notify(msg plugin.NotificationMessage)
- func (n *Notification) UserConfigFields() []plugin.ConfigField
- func (n *Notification) UserConfigReceiver(userID string, config []byte) error
- type NotificationConfig
- type PlainText
- type Show
- type Style
- type Summary
- type Template
- type Text
- type TextSize
- type TextTag
- type UserConfig
- type UserConfigCache
Constants ¶
const ( LarkBindAccountMenuEventKey = "10001" NotificationTypeInteractive = "interactive" MsgTypeText = "text" ReceiveIdTypeOpenId = "open_id" )
Variables ¶
var Info embed.FS
var (
TagColor = []string{"neutral", "blue", "turquoise", "lime", "orange", "violet", "indigo", "wathet", "green", "yellow", "red", "purple", "carmine"}
)
Functions ¶
func GenerateRandomString ¶
func GenerateRandomString(args *GenerateRandomStringArgs) string
GenerateRandomString use crypto to generate a random string
Types ¶
type Behavior ¶
type Behavior struct { Type string `json:"type"` DefaultURL string `json:"default_url"` AndroidURL string `json:"android_url"` IOSURL string `json:"ios_url"` PCURL string `json:"pc_url"` }
Behavior represents the behavior of a button.
type Button ¶
type Button struct { Tag string `json:"tag,omitempty"` Width string `json:"width,omitempty"` Text *Text `json:"text,omitempty"` Behaviors []Behavior `json:"behaviors,omitempty"` Type string `json:"type,omitempty"` HoverTips *Text `json:"hover_tips,omitempty"` Value map[string]any `json:"value,omitempty"` }
Button represents a button component.
func (*Button) MarshalJSON ¶
MarshalJSON customizes the JSON encoding for Button.
type Card ¶
type Card struct { Config *Config `json:"config"` CardLink *CardLink `json:"card_link,omitempty"` I18nElements *I18nElements `json:"i18n_elements,omitempty"` Header *Header `json:"header,omitempty"` }
Card represents the entire JSON structure of a card.
type CardLink ¶
type CardLink struct { URL string `json:"url,omitempty"` PCURL string `json:"pc_url,omitempty"` IOSURL string `json:"ios_url,omitempty"` AndroidURL string `json:"android_url,omitempty"` }
CardLink represents the URLs for different platforms.
type Color ¶
type Color string
Color represents color effects enumeration.
const ( ColorNeutral Color = "neutral" ColorBlue Color = "blue" ColorTurquoise Color = "turquoise" ColorLime Color = "lime" ColorOrange Color = "orange" ColorViolet Color = "violet" ColorIndigo Color = "indigo" ColorWathet Color = "wathet" ColorGreen Color = "green" ColorYellow Color = "yellow" ColorRed Color = "red" ColorPurple Color = "purple" ColorCarmine Color = "carmine" )
type Column ¶
type Column struct { Tag string `json:"tag,omitempty"` Elements []Element `json:"elements,omitempty"` Width string `json:"width,omitempty"` Weight int `json:"weight,omitempty"` BackgroundStyle string `json:"background_style,omitempty"` VerticalAlign string `json:"vertical_align,omitempty"` VerticalSpacing string `json:"vertical_spacing,omitempty"` Padding string `json:"padding,omitempty"` }
Column represents a column in a ColumnSet.
func (*Column) MarshalJSON ¶
MarshalJSON customizes the JSON encoding for Column.
type ColumnSet ¶
ColumnSet represents a set of columns.
func (*ColumnSet) MarshalJSON ¶
MarshalJSON customizes the JSON encoding for ColumnSet.
type Config ¶
type Config struct { StreamingMode *bool `json:"streaming_mode,omitempty"` Summary *Summary `json:"summary,omitempty"` EnableForward *bool `json:"enable_forward,omitempty"` UpdateMulti *bool `json:"update_multi,omitempty"` WidthMode string `json:"width_mode,omitempty"` UseCustomTranslation *bool `json:"use_custom_translation,omitempty"` EnableForwardInteraction *bool `json:"enable_forward_interaction,omitempty"` Style Style `json:"style,omitempty"` }
Config represents the configuration of a card.
type ConfigColor ¶
type ConfigColor struct { LightMode string `json:"light_mode,omitempty"` DarkMode string `json:"dark_mode,omitempty"` }
ConfigColor represents the custom color configuration.
type Element ¶
Element represents a generic element in a card.
func (*Element) MarshalJSON ¶
MarshalJSON customizes the JSON encoding for Element.
type Header ¶
type Header struct { Title *Text `json:"title,omitempty"` Subtitle *Text `json:"subtitle,omitempty"` TextTagList []TextTag `json:"text_tag_list,omitempty"` Template Template `json:"template,omitempty"` UdIcon *Icon `json:"ud_icon,omitempty"` }
Header represents the header component of a card.
type I18nElements ¶
type I18nElements struct { ZhCn []ColumnSet `json:"zh_cn,omitempty"` EnUs []ColumnSet `json:"en_us,omitempty"` }
I18nElements represents internationalized elements.
type Icon ¶
type Icon struct { Tag string `json:"tag,omitempty"` Token string `json:"token,omitempty"` Color string `json:"color,omitempty"` ImgKey string `json:"img_key,omitempty"` Style *struct { Color Color `json:"color,omitempty"` } `json:"style,omitempty"` }
Icon represents an icon component.
type LarkClient ¶
type LarkClient struct {
// contains filtered or unexported fields
}
func (*LarkClient) Start ¶
func (n *LarkClient) Start() error
type LarkLogger ¶
type LarkLogger struct{}
func (LarkLogger) Debug ¶
func (l LarkLogger) Debug(ctx context.Context, args ...interface{})
func (LarkLogger) Error ¶
func (l LarkLogger) Error(ctx context.Context, args ...interface{})
func (LarkLogger) Info ¶
func (l LarkLogger) Info(ctx context.Context, args ...interface{})
func (LarkLogger) Warn ¶
func (l LarkLogger) Warn(ctx context.Context, args ...interface{})
type Notification ¶
type Notification struct {
// contains filtered or unexported fields
}
func (*Notification) ConfigFields ¶
func (n *Notification) ConfigFields() []plugin.ConfigField
func (*Notification) ConfigReceiver ¶
func (n *Notification) ConfigReceiver(config []byte) error
func (*Notification) GetNewQuestionSubscribers ¶
func (n *Notification) GetNewQuestionSubscribers() (userIDs []string)
GetNewQuestionSubscribers returns the subscribers of the new question notification
func (Notification) Info ¶
func (n Notification) Info() plugin.Info
func (*Notification) LarkWsEventHub ¶
func (n *Notification) LarkWsEventHub() *dispatcher.EventDispatcher
func (*Notification) LarkWsEventMenuClick ¶
func (n *Notification) LarkWsEventMenuClick(ctx context.Context, event *larkApplication.P2BotMenuV6) error
LarkWsEventMenuClick is the event handler for the menu click event
func (*Notification) Notify ¶
func (n *Notification) Notify(msg plugin.NotificationMessage)
Notify sends a notification to the user
func (*Notification) UserConfigFields ¶
func (n *Notification) UserConfigFields() []plugin.ConfigField
func (*Notification) UserConfigReceiver ¶
func (n *Notification) UserConfigReceiver(userID string, config []byte) error
type NotificationConfig ¶
type NotificationConfig struct { Version string `json:"version"` AppID string `json:"app_id"` AppSecret string `json:"app_secret"` VerificationToken string `json:"verification_token"` EventEncryptKey string `json:"event_encrypt_key"` }
func (*NotificationConfig) GetAppID ¶
func (n *NotificationConfig) GetAppID() string
func (*NotificationConfig) GetAppSecret ¶
func (n *NotificationConfig) GetAppSecret() string
func (*NotificationConfig) GetEventEncryptKey ¶
func (n *NotificationConfig) GetEventEncryptKey() string
func (*NotificationConfig) GetVerificationToken ¶
func (n *NotificationConfig) GetVerificationToken() string
func (*NotificationConfig) GetVersion ¶
func (n *NotificationConfig) GetVersion() string
type PlainText ¶
type PlainText struct { Tag string `json:"tag,omitempty"` Text *Text `json:"text,omitempty"` Icon *Icon `json:"icon,omitempty"` }
PlainText represents plain text component.
type Show ¶
type Show struct { Tag string `json:"tag"` FlexMode string `json:"flex_mode,omitempty"` HorizontalSpacing string `json:"horizontal_spacing,omitempty"` BackgroundStyle string `json:"background_style,omitempty"` Columns []Column `json:"columns,omitempty"` }
Show represents the display properties of a ColumnSet.
type Style ¶
type Style struct { TextSize map[string]TextSize `json:"text_size,omitempty"` Color map[string]ConfigColor `json:"color,omitempty"` }
Style represents the custom font size and color configuration.
type Summary ¶
type Summary struct { Content string `json:"content,omitempty"` I18nContent map[string]string `json:"i18n_content,omitempty"` }
Summary represents the summary information of a card.
type Template ¶
type Template string
Template represents theme styles enumeration.
const ( ThemeBlue Template = "blue" ThemeWathet Template = "wathet" ThemeTurquoise Template = "turquoise" ThemeGreen Template = "green" ThemeYellow Template = "yellow" ThemeOrange Template = "orange" ThemeRed Template = "red" ThemeCarmine Template = "carmine" ThemeViolet Template = "violet" ThemePurple Template = "purple" ThemeIndigo Template = "indigo" ThemeGrey Template = "grey" ThemeDefault Template = "default" )
type Text ¶
type Text struct { Tag string `json:"tag,omitempty"` Content string `json:"content,omitempty"` I18n *I18n `json:"i18n,omitempty"` TextSize string `json:"text_size,omitempty"` TextAlign string `json:"text_align,omitempty"` TextColor string `json:"text_color,omitempty"` Icon *Icon `json:"icon,omitempty"` }
Text represents a text component with optional internationalization.
type TextSize ¶
type TextSize struct { Default string `json:"default,omitempty"` PC string `json:"pc,omitempty"` Mobile string `json:"mobile,omitempty"` }
TextSize represents the custom text size configuration.
type TextTag ¶
type TextTag struct { Tag string `json:"tag,omitempty"` Text *Text `json:"text,omitempty"` Color string `json:"color,omitempty"` }
TextTag represents a text tag component.
func (*TextTag) MarshalJSON ¶
MarshalJSON customizes the JSON encoding for TextTag.
type UserConfig ¶
type UserConfigCache ¶
func NewUserConfigCache ¶
func NewUserConfigCache() *UserConfigCache
func (*UserConfigCache) SetUserConfig ¶
func (ucc *UserConfigCache) SetUserConfig(userID string, config *UserConfig)