webhook

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Post

func Post(webhookType string, context Context) error

Post posts the message to webhook.

Types

type Context

type Context struct {
	URL          string
	Level        Level
	Title        string
	Description  string
	Link         string
	CreatorName  string
	CreatorEmail string
	CreatedTs    int64
	MetaList     []Meta
}

Context is the context of webhook.

type DingTalkReceiver

type DingTalkReceiver struct {
}

DingTalkReceiver is the receiver for DingTalk.

type DingTalkWebhook

type DingTalkWebhook struct {
	MessageType string                  `json:"msgtype"`
	Markdown    DingTalkWebhookMarkdown `json:"markdown"`
}

DingTalkWebhook is the API message for DingTalk webhook.

type DingTalkWebhookMarkdown

type DingTalkWebhookMarkdown struct {
	Title string `json:"title"`
	Text  string `json:"text"`
}

DingTalkWebhookMarkdown is the API message for DingTalk webhook markdown.

type DingTalkWebhookResponse

type DingTalkWebhookResponse struct {
	ErrorCode    int    `json:"errcode"`
	ErrorMessage string `json:"errmsg"`
}

DingTalkWebhookResponse is the API message for DingTalk webhook response.

type DiscordReceiver

type DiscordReceiver struct {
}

DiscordReceiver is the receiver for Discord.

type DiscordWebhook

type DiscordWebhook struct {
	EmbedList []DiscordWebhookEmbed `json:"embeds"`
}

DiscordWebhook is the API message for Discord webhook.

type DiscordWebhookEmbed

type DiscordWebhookEmbed struct {
	Title       string                     `json:"title"`
	Type        string                     `json:"type"`
	Description string                     `json:"description,omitempty"`
	URL         string                     `json:"url,omitempty"`
	Timestamp   string                     `json:"timestamp"`
	Author      DiscordWebhookEmbedAuthor  `json:"author"`
	FieldList   []DiscordWebhookEmbedField `json:"fields,omitempty"`
}

DiscordWebhookEmbed is the API message for Discord webhook embed.

type DiscordWebhookEmbedAuthor

type DiscordWebhookEmbedAuthor struct {
	Name string `json:"name"`
}

DiscordWebhookEmbedAuthor is the API message for Discord webhook embed Author.

type DiscordWebhookEmbedField

type DiscordWebhookEmbedField struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

DiscordWebhookEmbedField is the API message for Discord webhook embed field.

type DiscordWebhookResponse

type DiscordWebhookResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

DiscordWebhookResponse is the API message for Discord webhook response.

type FeishuReceiver

type FeishuReceiver struct {
}

FeishuReceiver is the receiver for Feishu.

type FeishuWebhook

type FeishuWebhook struct {
	MessageType string               `json:"msg_type"`
	Content     FeishuWebhookContent `json:"content"`
}

FeishuWebhook is the API message for Feishu webhook.

type FeishuWebhookContent

type FeishuWebhookContent struct {
	Post FeishuWebhookPostLanguage `json:"post"`
}

FeishuWebhookContent is the API message for Feishu webhook content.

type FeishuWebhookPost

type FeishuWebhookPost struct {
	Title       string                       `json:"title"`
	ContentList [][]FeishuWebhookPostSection `json:"content"`
}

FeishuWebhookPost is the API message for Feishu webhook POST.

type FeishuWebhookPostLanguage

type FeishuWebhookPostLanguage struct {
	English FeishuWebhookPost `json:"en_us"`
}

FeishuWebhookPostLanguage is the API message for Feishu webhook POST language.

type FeishuWebhookPostLine

type FeishuWebhookPostLine struct {
	SectionList []FeishuWebhookPostSection `json:""`
}

FeishuWebhookPostLine is the API message for Feishu webhook POST line.

type FeishuWebhookPostSection

type FeishuWebhookPostSection struct {
	Tag  string `json:"tag"`
	Text string `json:"text"`
	Href string `json:"href,omitempty"`
}

FeishuWebhookPostSection is the API message for Feishu webhook POST section.

type FeishuWebhookResponse

type FeishuWebhookResponse struct {
	Code    int    `json:"code"`
	Message string `json:"msg"`
}

FeishuWebhookResponse is the API message for Feishu webhook response.

type Level

type Level string

Level is the level of webhook.

const (
	// WebhookInfo is the webhook level for INFO.
	WebhookInfo Level = "INFO"
	// WebhookSuccess is the webhook level for SUCCESS.
	WebhookSuccess Level = "SUCCESS"
	// WebhookWarn is the webhook level for WARN.
	WebhookWarn Level = "WARN"
	// WebhookError is the webhook level for ERROR.
	WebhookError Level = "ERROR"
)

type Meta

type Meta struct {
	Name  string
	Value string
}

Meta is the webhook metadata.

type Receiver

type Receiver interface {
	// contains filtered or unexported methods
}

Receiver is the webhook receiver.

type SlackReceiver

type SlackReceiver struct {
}

SlackReceiver is the receiver for Slack.

type SlackWebhook

type SlackWebhook struct {
	Text      string              `json:"text"`
	BlockList []SlackWebhookBlock `json:"blocks"`
}

SlackWebhook is the API message for Slack webhook.

type SlackWebhookBlock

type SlackWebhookBlock struct {
	Type        string                     `json:"type"`
	Text        *SlackWebhookBlockMarkdown `json:"text,omitempty"`
	ElementList []SlackWebhookElement      `json:"elements,omitempty"`
}

SlackWebhookBlock is the API message for Slack webhook block.

type SlackWebhookBlockMarkdown

type SlackWebhookBlockMarkdown struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

SlackWebhookBlockMarkdown is the API message for Slack webhook block markdown.

type SlackWebhookElement

type SlackWebhookElement struct {
	Type   string                    `json:"type"`
	Button SlackWebhookElementButton `json:"text,omitempty"`
	URL    string                    `json:"url,omitempty"`
}

SlackWebhookElement is the API message for Slack webhook element.

type SlackWebhookElementButton

type SlackWebhookElementButton struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

SlackWebhookElementButton is the API message for Slack webhook element button.

type TeamsReceiver

type TeamsReceiver struct {
}

TeamsReceiver is the receiver for Teams.

type TeamsWebhook

type TeamsWebhook struct {
	Type        string                `json:"@type"`
	Context     string                `json:"@context"`
	Summary     string                `json:"summary"`
	ThemeColor  string                `json:"themeColor"`
	Title       string                `json:"title"`
	SectionList []TeamsWebhookSection `json:"sections"`
	ActionList  []TeamsWebhookAction  `json:"potentialAction"`
}

TeamsWebhook is the API message for Teams webhook.

type TeamsWebhookAction

type TeamsWebhookAction struct {
	Type       string                     `json:"@type"`
	Name       string                     `json:"name"`
	TargetList []TeamsWebhookActionTarget `json:"targets"`
}

TeamsWebhookAction is the API message for Teams webhook action.

type TeamsWebhookActionTarget

type TeamsWebhookActionTarget struct {
	OS  string `json:"os"`
	URI string `json:"uri"`
}

TeamsWebhookActionTarget is the API message for Teams webhook action target.

type TeamsWebhookSection

type TeamsWebhookSection struct {
	ActivityTitle    string                    `json:"activityTitle"`
	ActivitySubtitle string                    `json:"activitySubtitle"`
	FactList         []TeamsWebhookSectionFact `json:"facts"`
	Text             string                    `json:"text"`
}

TeamsWebhookSection is the API message for Teams webhook section.

type TeamsWebhookSectionFact

type TeamsWebhookSectionFact struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

TeamsWebhookSectionFact is the API message for Teams webhook section fact.

type WeComReceiver

type WeComReceiver struct {
}

WeComReceiver is the receiver for WeCom.

type WeComWebhook

type WeComWebhook struct {
	MessageType string               `json:"msgtype"`
	Markdown    WeComWebhookMarkdown `json:"markdown"`
}

WeComWebhook is the API message for WeCom webhook.

type WeComWebhookMarkdown

type WeComWebhookMarkdown struct {
	Content string `json:"content"`
}

WeComWebhookMarkdown is the API message for WeCom webhook markdown.

type WeComWebhookResponse

type WeComWebhookResponse struct {
	ErrorCode    int    `json:"errcode"`
	ErrorMessage string `json:"errmsg"`
}

WeComWebhookResponse is the API message for WeCom webhook response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL