api

package
v0.0.0-...-05e418a Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BreakIterating    = true
	ContinueIterating = false
)
View Source
const DeletedAt = ".deletedAt."

Variables

This section is empty.

Functions

func AbbreviateValues

func AbbreviateValues(m map[string]string, max int) interface{}

func FilterSlice

func FilterSlice(slice []string, m map[string]bool) []string

FilterSlice 根据m过滤切片slice,返回剩余项目

func GetQywxAccessToken

func GetQywxAccessToken(corpID, corpSecret string) (string, error)

GetQywxAccessToken 获得企业微信的令牌

func HandleHome

func HandleHome(app *App, homeTemplate string) func(w http.ResponseWriter, r *http.Request)

func HandleRaw

func HandleRaw(app *App, path string) func(w http.ResponseWriter, r *http.Request)

func HandleRedlist

func HandleRedlist(a *App) func(w http.ResponseWriter, r *http.Request)

func HmacMD5

func HmacMD5(key, data string) string

func SendEWSEmail

func SendEWSEmail(c ews.Client, to []string, subject, body string) error

SendEWSEmail helper method to send Message

func SliceToMap

func SliceToMap(slice []string) map[string]bool

SliceToMap 切片转换为 map[string]bool

func TrimSpaceToLower

func TrimSpaceToLower(s string) string

func WriteErrorJSON

func WriteErrorJSON(statusCode int, w http.ResponseWriter, v interface{}) error

func WriteJSON

func WriteJSON(w http.ResponseWriter, v interface{}) error

Types

type AlibabaAliqinFcSmsNumSendRequest

type AlibabaAliqinFcSmsNumSendRequest struct {
	// 公共回传参数,在“消息返回”中会透传回该参数;举例:用户可以传入自己下级的会员ID,
	// 在消息返回时,该会员ID会包含在内,用户可以根据该会员ID识别是哪位会员使用了你的应用
	Extend string `json:"extend"`

	// 短信接收号码。支持单个或多个手机号码,传入号码为11位手机号码,不能加0或+86。
	// 群发短信需传入多个号码,以英文逗号分隔,一次调用最多传入200个号码。示例:18600000000,13911111111,13322222222
	RecNum string `json:"rec_num"`

	// 短信签名,传入的短信签名必须是在阿里大鱼“管理中心-短信签名管理”中的可用签名。
	// 如“阿里大鱼”已在短信签名管理中通过审核,则可传入”阿里大鱼“(传参时去掉引号)作为短信签名。
	// 短信效果示例:【阿里大鱼】欢迎使用阿里大鱼服务。
	SmsFreeSignName string `json:"sms_free_sign_name"`

	// 短信模板变量,传参规则{"key":"value"},key的名字须和申请模板中的变量名一致,多个变量之间以逗号隔开。
	// 示例:针对模板“验证码${code},您正在进行${product}身份验证,打死不要告诉别人哦!”,
	// 传参时需传入{"code":"1234","product":"alidayu"}
	SmsParam string `json:"sms_param"`

	// 短信模板ID,传入的模板必须是在阿里大鱼“管理中心-短信模板管理”中的可用模板。示例:SMS_585014
	SmsTemplateCode string `json:"sms_template_code"`

	// 短信类型,传入值请填写normal
	SmsType string `json:"sms_type"`
}

Top API: alibaba.aliqin.fc.sms.num.send 详细参数请参考官方Api文档:https://api.alidayu.com/docs/api.htm?apiId=25450

func NewAlibabaAliqinFcSmsNumSendRequest

func NewAlibabaAliqinFcSmsNumSendRequest() *AlibabaAliqinFcSmsNumSendRequest

func (*AlibabaAliqinFcSmsNumSendRequest) GetMethodName

func (req *AlibabaAliqinFcSmsNumSendRequest) GetMethodName() string

func (*AlibabaAliqinFcSmsNumSendRequest) ParamsIsValid

func (req *AlibabaAliqinFcSmsNumSendRequest) ParamsIsValid() error

type AlibabaRequest

type AlibabaRequest interface {
	GetMethodName() string
	ParamsIsValid() error
}

type AlidayuTester

type AlidayuTester struct {
	Config AliyunDaYuSms    `json:"config"`
	Data   AliyunDaYuSmsReq `json:"data"`
}

func (*AlidayuTester) FilterRedList

func (r *AlidayuTester) FilterRedList(list redList) bool

func (AlidayuTester) Send

func (r AlidayuTester) Send(app *App) NotifyRsp

type AliyunDaYuSms

type AliyunDaYuSms struct {
	AppKey       string `json:"appKey"`
	AppSecret    string `json:"appSecret"`
	TemplateCode string `json:"templateCode"`
	SignName     string `json:"signName" faker:"-"`
}

AliyunDaYuSms 表示阿里云大于短信发送器

func (AliyunDaYuSms) ChannelName

func (s AliyunDaYuSms) ChannelName() string

func (*AliyunDaYuSms) Config

func (s *AliyunDaYuSms) Config(config string) error

Config 创建发送器,要求参数 config 是{AppKey}/{AppSecret}/{TemplateCode}/{SignName}的格式

func (AliyunDaYuSms) ConvertRequest

func (s AliyunDaYuSms) ConvertRequest(r *SmsReq) Request

func (*AliyunDaYuSms) InitMeaning

func (s *AliyunDaYuSms) InitMeaning()

func (AliyunDaYuSms) NewRequest

func (s AliyunDaYuSms) NewRequest() Request

func (AliyunDaYuSms) Notify

func (s AliyunDaYuSms) Notify(_ *App, request Request) NotifyRsp

Notify 发送短信 https://api.alidayu.com/doc2/apiDetail?apiId=25450

type AliyunDaYuSmsErrorRsp

type AliyunDaYuSmsErrorRsp struct {
	SubMsg  string `json:"sub_msg"`
	Code    int    `json:"code"`
	SubCode string `json:"sub_code"`
	Msg     string `json:"msg"`
}

type AliyunDaYuSmsReq

type AliyunDaYuSmsReq struct {
	TemplateCode   string            `json:"templateCode" faker:"-"`
	TemplateParams map[string]string `json:"templateParams"`
	SignName       string            `json:"signName" faker:"-"`
	Mobiles        []string          `json:"mobiles" faker:"china_mobile_number"`
}

func (*AliyunDaYuSmsReq) FilterRedList

func (a *AliyunDaYuSmsReq) FilterRedList(list redList) bool

type AliyunDaYuSmsRsp

type AliyunDaYuSmsRsp struct {
	Response map[string]interface{} `json:"alibaba_aliqin_fc_sms_num_send_response"`
	AliyunDaYuSmsErrorRsp
}

type AliyunSms

type AliyunSms struct {
	AccessKeyID     string `json:"accessKeyID"`
	AccessKeySecret string `json:"accessKeySecret"`
	TemplateCode    string `json:"templateCode"`
	SignName        string `json:"signName" faker:"-"`
}

AliyunSms 表示阿里云短信发送器

func (AliyunSms) ChannelName

func (s AliyunSms) ChannelName() string

func (*AliyunSms) Config

func (s *AliyunSms) Config(config string) error

Config 创建发送器,要求参数 config 是{accessKeyId}/{accessKeySecret}/{templateCode}/{signName}的格式

func (AliyunSms) ConvertRequest

func (s AliyunSms) ConvertRequest(r *SmsReq) Request

func (*AliyunSms) InitMeaning

func (s *AliyunSms) InitMeaning()

func (AliyunSms) NewRequest

func (s AliyunSms) NewRequest() Request

func (AliyunSms) Notify

func (s AliyunSms) Notify(_ *App, request Request) NotifyRsp

Notify 发送短信

type AliyunSmsReq

type AliyunSmsReq struct {
	TemplateCode   string            `json:"templateCode" faker:"-"`
	TemplateParams map[string]string `json:"templateParams"`
	SignName       string            `json:"signName" faker:"-"`
	Mobiles        []string          `json:"mobiles" faker:"china_mobile_number"`
}

func (*AliyunSmsReq) FilterRedList

func (a *AliyunSmsReq) FilterRedList(list redList) bool

type AliyunSmsRsp

type AliyunSmsRsp struct {
	OutID string `json:"outId"`

	Code      string `json:"code"`      // eg. OK 请求状态码。 返回OK代表请求成功。 其他错误码详见错误码列表。
	Message   string `json:"message"`   // eg. OK 状态码的描述。
	RequestID string `json:"requestID"` // eg. F655A8D5-B967-440B-8683-DAD6FF8DE990	 请求ID。

	BizID string `json:"bizID"` // eg. 900619746936498440^0,  发送回执ID,可根据该ID在接口QuerySendDetails中查询具体的发送状态。
}

type AliyunsmsTester

type AliyunsmsTester struct {
	Config AliyunSms    `json:"config"`
	Data   AliyunSmsReq `json:"data"`
}

func (*AliyunsmsTester) FilterRedList

func (r *AliyunsmsTester) FilterRedList(list redList) bool

func (AliyunsmsTester) Send

func (r AliyunsmsTester) Send(app *App) NotifyRsp

type App

type App struct {
	// contains filtered or unexported fields
}

func CreateApp

func CreateApp(snapshotDir, nopConfID string) *App

func (*App) DeleteConfig

func (a *App) DeleteConfig(w http.ResponseWriter, l int, subs []string) error

func (*App) GetConfig

func (a *App) GetConfig(w http.ResponseWriter, l int, subs []string) error
GetConfig ...

nolint gomnd

func (*App) NotifyByConfig

func (a *App) NotifyByConfig(removePath string) func(w http.ResponseWriter, r *http.Request)

func (*App) NotifyByConfigID

func (a *App) NotifyByConfigID(configID string, req Request) NotifyRsp

func (*App) PostConfig

func (a *App) PostConfig(w http.ResponseWriter, r *http.Request, l int, subs []string) error

func (*App) ServeByConfig

func (a *App) ServeByConfig(path string) func(w http.ResponseWriter, r *http.Request)

type Config

type Config interface {
	Config(config string) error
	Notify(app *App, req Request) NotifyRsp
	ChannelName() string
	InitMeaning()
	NewRequest() Request
}

func NewConfig

func NewConfig(typ string) (Config, error)

type DingResponse

type DingResponse struct {
	Errcode int    `json:"code"`
	Errmsg  string `json:"message"`
}

type Dingtalk

type Dingtalk struct {
	AccessToken string `json:"accessToken"`
}

Dingtalk 表示钉钉消息发送器

func (Dingtalk) ChannelName

func (s Dingtalk) ChannelName() string

func (*Dingtalk) Config

func (s *Dingtalk) Config(config string) error

Config 创建发送器,要求参数 config 是{accessToken}的格式

func (*Dingtalk) InitMeaning

func (s *Dingtalk) InitMeaning()

func (Dingtalk) NewRequest

func (s Dingtalk) NewRequest() Request

func (Dingtalk) Notify

func (s Dingtalk) Notify(app *App, request Request) NotifyRsp

Notify 发送信息

type DingtalkReq

type DingtalkReq struct {
	Message   string   `json:"message"`
	AtMobiles []string `json:"atMobiles" faker:"china_mobile_number"`
	AtAll     bool     `json:"atAll"`
}

func (*DingtalkReq) FilterRedList

func (s *DingtalkReq) FilterRedList(list redList) bool

type DingtalkReqTester

type DingtalkReqTester struct {
	Config Dingtalk    `json:"config"`
	Data   DingtalkReq `json:"data"`
}

func (*DingtalkReqTester) FilterRedList

func (r *DingtalkReqTester) FilterRedList(list redList) bool

func (DingtalkReqTester) Send

func (r DingtalkReqTester) Send(app *App) NotifyRsp

type ExchangeWebService

type ExchangeWebService struct {
	EwsAddr  string `json:"ewsAddr"`
	Username string `json:"username"`
	Password string `json:"password" `
}

ExchangeWebService is Exchange Web Service

func (ExchangeWebService) ChannelName

func (q ExchangeWebService) ChannelName() string

func (*ExchangeWebService) Config

func (q *ExchangeWebService) Config(config string) error

Config 加载配置

func (*ExchangeWebService) InitMeaning

func (q *ExchangeWebService) InitMeaning()

func (ExchangeWebService) NewRequest

func (q ExchangeWebService) NewRequest() Request

func (ExchangeWebService) Notify

func (q ExchangeWebService) Notify(_ *App, request Request) NotifyRsp

Notify 发送邮件

type HomeData

type HomeData struct {
	Sha1ver   string
	BuildTime string
	Items     []NotifierItem
}

type Mail

type Mail struct {
	SMTPAddr string `json:"smtpAddr"`           // smtp.gmail.com
	SMTPPort int    `json:"smtpPort"`           // 587
	From     string `json:"from" faker:"email"` // ...@gmail.com
	Username string `json:"username"`           // ...
	Pass     string `json:"pass"`               // ...
}

Mail 表示邮件发送器

func (Mail) ChannelName

func (q Mail) ChannelName() string

func (*Mail) Config

func (q *Mail) Config(config string) error

Config 加载配置

func (*Mail) InitMeaning

func (q *Mail) InitMeaning()

func (Mail) NewRequest

func (q Mail) NewRequest() Request

func (Mail) Notify

func (q Mail) Notify(_ *App, request Request) NotifyRsp

Notify 发送邮件

type MailReq

type MailReq struct {
	Subject string   `json:"subject"`
	Message string   `json:"message"`
	To      []string `json:"to" faker:"email"`
}

func (*MailReq) FilterRedList

func (m *MailReq) FilterRedList(list redList) bool

type MailTester

type MailTester struct {
	Config Mail    `json:"config"`
	Data   MailReq `json:"data"`
}

func (*MailTester) FilterRedList

func (r *MailTester) FilterRedList(list redList) bool

func (MailTester) Send

func (r MailTester) Send(app *App) NotifyRsp

type NotifierItem

type NotifierItem struct {
	Name      string
	Channel   string
	ConfigIDs []string
}

type NotifyConfig

type NotifyConfig struct {
	Type   string `json:"type"`
	Config Config `json:"config"`
}

func ParseNotifyConfig

func ParseNotifyConfig(content []byte) (*NotifyConfig, error)

type NotifyConfigCache

type NotifyConfigCache struct {
	C        *cache.Cache
	Snapshot SnapshotService
	// contains filtered or unexported fields
}

func NewCache

func NewCache(snapshotDir string) *NotifyConfigCache

func (*NotifyConfigCache) Delete

func (t *NotifyConfigCache) Delete(key string)

func (*NotifyConfigCache) Read

func (t *NotifyConfigCache) Read(key string) *NotifyConfig

func (*NotifyConfigCache) ReadRedList

func (t *NotifyConfigCache) ReadRedList() (redlist RedList)

func (*NotifyConfigCache) Walk

func (t *NotifyConfigCache) Walk(fn func(k string, v *NotifyConfig))

func (*NotifyConfigCache) Write

func (t *NotifyConfigCache) Write(k string, v *NotifyConfig, persist bool) error

func (*NotifyConfigCache) WriteRedList

func (t *NotifyConfigCache) WriteRedList(v RedList, persist bool) error

type NotifyRsp

type NotifyRsp struct {
	Status  int           `json:"status"`  // 状态,0成功
	Message string        `json:"message"` // 消息
	Data    NotifyRspData `json:"data"`    // 原始返回
}

func MakeRsp

func MakeRsp(err error, ok bool, channel string, raw interface{}) NotifyRsp

type NotifyRspData

type NotifyRspData struct {
	Channel string      `json:"channel"` // 发送渠道
	Raw     interface{} `json:"raw"`
}

type QcloudBase

type QcloudBase struct {
	Sdkappid string `json:"sdkappid"`
	Appkey   string `json:"appkey"`
}

func (QcloudBase) CreateSignature

func (q QcloudBase) CreateSignature(rand string, t int64, nums ...string) string

type QcloudSms

type QcloudSms struct {
	QcloudBase
	TplID        int      `json:"tplID"`
	Sign         string   `json:"sign" faker:"-"`
	TmplVarNames []string `json:"tmplVarNames"`
}

QcloudSms 表示腾讯云短信发送器

func (QcloudSms) ChannelName

func (q QcloudSms) ChannelName() string

func (*QcloudSms) Config

func (q *QcloudSms) Config(config string) error

Config 加载配置

func (QcloudSms) ConvertRequest

func (q QcloudSms) ConvertRequest(r *SmsReq) Request

func (*QcloudSms) InitMeaning

func (q *QcloudSms) InitMeaning()

func (QcloudSms) NewRequest

func (q QcloudSms) NewRequest() Request

func (QcloudSms) Notify

func (q QcloudSms) Notify(app *App, request Request) NotifyRsp

Notify 发送信息

type QcloudSmsReq

type QcloudSmsReq struct {
	Params  []string `json:"params"`
	Mobiles []string `json:"mobiles" faker:"china_mobile_number"`
}

func (*QcloudSmsReq) FilterRedList

func (q *QcloudSmsReq) FilterRedList(list redList) bool

type QcloudSmsReqTester

type QcloudSmsReqTester struct {
	Config QcloudSms    `json:"config"`
	Data   QcloudSmsReq `json:"data"`
}

func (*QcloudSmsReqTester) FilterRedList

func (r *QcloudSmsReqTester) FilterRedList(list redList) bool

func (QcloudSmsReqTester) Send

func (r QcloudSmsReqTester) Send(app *App) NotifyRsp

type QcloudSmsRsp

type QcloudSmsRsp struct {
	Result int                     `json:"result"`
	Errmsg string                  `json:"errmsg"`
	Ext    string                  `json:"ext"`
	Detail []RawQcloudSmsRspDetail `json:"detail"`
}

type QcloudSmsVoiceTester

type QcloudSmsVoiceTester struct {
	Config QcloudVoice    `json:"config"`
	Data   QcloudVoiceReq `json:"data"`
}

func (*QcloudSmsVoiceTester) FilterRedList

func (r *QcloudSmsVoiceTester) FilterRedList(list redList) bool

func (QcloudSmsVoiceTester) Send

func (r QcloudSmsVoiceTester) Send(app *App) NotifyRsp

type QcloudVoice

type QcloudVoice struct {
	QcloudBase
	TplID        int      `json:"tplID"`
	PlayTimes    int      `json:"playTimes" faker:"enum=1/2/3"`
	TmplVarNames []string `json:"tmplVarNames"`
}

QcloudVoice 表示腾讯语音短信发送器

func (QcloudVoice) ChannelName

func (s QcloudVoice) ChannelName() string

func (*QcloudVoice) Config

func (s *QcloudVoice) Config(config string) error

Config 加载配置

func (QcloudVoice) ConvertRequest

func (s QcloudVoice) ConvertRequest(r map[string]string) []string

func (*QcloudVoice) InitMeaning

func (s *QcloudVoice) InitMeaning()

func (QcloudVoice) NewRequest

func (s QcloudVoice) NewRequest() Request

func (QcloudVoice) Notify

func (s QcloudVoice) Notify(_ *App, request Request) NotifyRsp

Notify 发送信息

type QcloudVoiceReq

type QcloudVoiceReq struct {
	Params map[string]string `json:"params"`
	Mobile string            `json:"mobile" faker:"china_mobile_number"`
}

func (*QcloudVoiceReq) FilterRedList

func (q *QcloudVoiceReq) FilterRedList(list redList) bool

type Qywx

type Qywx struct {
	CorpID     string `json:"corpID"`
	CorpSecret string `json:"corpSecret"`
	AgentID    string `json:"agentID"`
}

Qywx 表示企业微信消息发送器

func (Qywx) ChannelName

func (s Qywx) ChannelName() string

func (*Qywx) Config

func (s *Qywx) Config(config string) error

Config 创建发送器,要求参数 config 是{corpID}/{corpSecret}/{agentID}的格式

func (*Qywx) InitMeaning

func (s *Qywx) InitMeaning()

func (Qywx) NewRequest

func (s Qywx) NewRequest() Request

func (Qywx) Notify

func (s Qywx) Notify(app *App, request Request) NotifyRsp

Notify 发送企业消息

type QywxReq

type QywxReq struct {
	Msg     string   `json:"msg"`
	UserIds []string `json:"userIds"`
}

func (*QywxReq) FilterRedList

func (q *QywxReq) FilterRedList(list redList) bool

type QywxRsp

type QywxRsp struct {
	Errocode     int    `json:"errcode"`
	Errmsg       string `json:"errmsg"`
	Invaliduser  string `json:"invaliduser"`
	Invalidparty string `json:"invalidparty"`
	Invalidtag   string `json:"invalidtag"`
}

func FastSendQywxMsg

func FastSendQywxMsg(corpID, corpSecret, agentID, content string, userIds []string) (QywxRsp, error)

FastSendQywxMsg 快速发送企业微信消息

func SendQywxMsg

func SendQywxMsg(accessToken, agentID, content string, userIds []string) (QywxRsp, error)

https://qydev.weixin.qq.com/wiki/index.php?title=发送接口说明 SendQywxMsg 发送企业微信消息

type QywxTester

type QywxTester struct {
	Config Qywx    `json:"config"`
	Data   QywxReq `json:"data"`
}

func (*QywxTester) FilterRedList

func (r *QywxTester) FilterRedList(list redList) bool

func (QywxTester) Send

func (r QywxTester) Send(app *App) NotifyRsp

type QywxTokenResult

type QywxTokenResult struct {
	ErrCode          int    `json:"errcode"`
	ErrMsg           string `json:"errmsg"`
	AccessToken      string `json:"access_token"`
	ExpiresInSeconds int    `json:"expires_in"`
}

QywxTokenResult 表示企业微信的令牌结果

type RawNotifyConfig

type RawNotifyConfig struct {
	Type   string          `json:"type"`
	Config json.RawMessage `json:"config"`
}

func (RawNotifyConfig) ParseConfig

func (r RawNotifyConfig) ParseConfig() (Config, error)

type RawQcloudSmsReq

type RawQcloudSmsReq struct {
	Ext    string   `json:"ext"`            // 用户的 session 内容,腾讯 server 回包中会原样返回,可选字段,不需要就填空
	Params []string `json:"params"`         // 模板参数,若模板没有参数,请提供为空数组
	Sig    string   `json:"sig"`            // App 凭证,计算公式:sha256(appkey=$appkey&random=$random&time=$time&mobile=$mobile)
	Sign   string   `json:"sign" faker:"-"` // 短信签名,如果使用默认签名,该字段可缺省
	Tel    []Tel    `json:"tel"`
	Time   int64    `json:"time"`   // 请求发起时间,UNIX 时间戳(单位:秒),如果和系统时间相差超过 10 分钟则会返回失败
	TplID  int      `json:"tpl_id"` // 模板 ID,在控制台审核通过的模板 ID
}

RawQcloudSmsReq 表示腾讯云短消息请求体结构

type RawQcloudSmsRspDetail

type RawQcloudSmsRspDetail struct {
	Fee        int    `json:"fee"`
	Mobile     string `json:"mobile" faker:"china_mobile_number"`
	Nationcode string `json:"nationcode"`
	Sid        string `json:"sid"`
	Result     int    `json:"result"`
	Errmsg     string `json:"errmsg"`
}

type RawQcloudVoiceReq

type RawQcloudVoiceReq struct {
	TplID     int      `json:"tpl_id"`                       // 模板 ID,在控制台审核通过的模板 ID
	Params    []string `json:"params"`                       // 模板参数,若模板没有参数,请提供为空数组
	PlayTimes int      `json:"playtimes" faker:"enum=1/2/3"` // 播放次数,可选,最多3次,默认2次。

	Sig  string `json:"sig"` // App 凭证,计算公式:sha256(appkey=$appkey&random=$random&time=$time&mobile=$mobile)
	Tel  Tel    `json:"tel"`
	Time int64  `json:"time"` // 请求发起时间,UNIX 时间戳(单位:秒),如果和系统时间相差超过 10 分钟则会返回失败
	Ext  string `json:"ext"`  // 用户的 session 内容,腾讯 server 回包中会原样返回,可选字段,不需要就填空
}

RawQcloudVoiceReq 表示腾讯云语音短信请求体结构

type RawQcloudVoiceRsp

type RawQcloudVoiceRsp struct {
	Result int    `json:"result"`
	Errmsg string `json:"errmsg"`
	Callid string `json:"callid"`
	Ext    string `json:"ext"`
}

type RedList

type RedList struct {
	Mobiles     []string `json:"mobiles"`
	Mails       []string `json:"mails"`
	QywxUserIds []string `json:"qywxUserIds"`
}

RedList 表示红名单,红名单里面配置的人,不可以被“骚扰”

type RedListFilter

type RedListFilter interface {
	// FilterRedList 过滤,返回true表示还有剩余项目
	FilterRedList(list redList) bool
}

type Request

type Request interface {
	RedListFilter
}

type Robot

type Robot struct {
	Webhook string
}

Robot represents a dingtalk custom robot that can send messages to groups.

func (Robot) SendActionCard

func (r Robot) SendActionCard(title, text, singleTitle, singleURL, btnOrient, hideAvatar string) (DingResponse, error)

SendActionCard send a action card type message.

func (r Robot) SendLink(title, text, messageURL, picURL string) (DingResponse, error)

SendLink send a link type message.

func (Robot) SendMarkdown

func (r Robot) SendMarkdown(title, text string, atMobiles []string, isAtAll bool) (DingResponse, error)

SendMarkdown send a markdown type message.

func (Robot) SendText

func (r Robot) SendText(content string, atMobiles []string, isAtAll bool) (DingResponse, error)

SendText send a text type message.

type Roboter

type Roboter interface {
	SendText(content string, atMobiles []string, isAtAll bool) (*DingResponse, error)
	SendLink(title, text, messageURL, picURL string) (*DingResponse, error)
	SendMarkdown(title, text string, atMobiles []string, isAtAll bool) (*DingResponse, error)
	SendActionCard(title, text, singleTitle, singleURL, btnOrientation, hideAvatar string) (*DingResponse, error)
}

Roboter is the interface implemented by Robot that can send multiple types of messages.

type Rsp

type Rsp struct {
	Status  int
	Message string
}

type Sms

type Sms struct {
	ConfigIds []string `json:"configIds"`
	Random    bool     `json:"random"`          // 是否在发送配置中随机发送,不随机时,按照配置顺序发送
	Retry     int      `json:"retry" faker:"-"` // 在发送配置中,重试n次
}

Sms 表示聚合短信发送器

func (Sms) ChannelName

func (r Sms) ChannelName() string

func (*Sms) Config

func (r *Sms) Config(config string) error

Config 创建发送器,要求参数 config 是{accessKeyId}/{accessKeySecret}/{templateCode}/{signName}的格式

func (*Sms) InitMeaning

func (r *Sms) InitMeaning()

func (Sms) NewRequest

func (r Sms) NewRequest() Request

func (Sms) Notify

func (r Sms) Notify(app *App, request Request) NotifyRsp

Notify 发送短信

type SmsNotifier

type SmsNotifier interface {
	ConvertRequest(*SmsReq) Request
}

type SmsReq

type SmsReq struct {
	TemplateParams map[string]string `json:"templateParams"`
	Mobiles        []string          `json:"mobiles" faker:"china_mobile_number"`
	Retry          int               `json:"retry" faker:"-"` // 在发送配置中,重试n次, -1表示使用默认配置
}

func (*SmsReq) FilterRedList

func (q *SmsReq) FilterRedList(list redList) bool

type SmsTester

type SmsTester struct {
	Config Sms    `json:"config"`
	Data   SmsReq `json:"data"`
}

func (*SmsTester) FilterRedList

func (r *SmsTester) FilterRedList(list redList) bool

func (SmsTester) Send

func (r SmsTester) Send(app *App) NotifyRsp

type SnapshotService

type SnapshotService struct {
	Dir string
}

func (SnapshotService) CleanAll

func (s SnapshotService) CleanAll()

func (SnapshotService) Delete

func (s SnapshotService) Delete(file string) error

func (*SnapshotService) Init

func (s *SnapshotService) Init(dir string) error

func (*SnapshotService) InitDefault

func (s *SnapshotService) InitDefault() error

func (SnapshotService) Read

func (s SnapshotService) Read(file string) ([]byte, error)

func (SnapshotService) RecoverCache

func (s SnapshotService) RecoverCache(c *NotifyConfigCache) error

func (SnapshotService) Walk

func (s SnapshotService) Walk(fn func(file string, content []byte)) error

func (SnapshotService) Write

func (s SnapshotService) Write(file string, content []byte) error

type Tel

type Tel struct {
	Mobile     string `json:"mobile" faker:"china_mobile_number"`
	NationCode string `json:"nationcode"`
}

Tel 表示电话号码

type Tester

type Tester interface {
	RedListFilter

	Send(*App) NotifyRsp
}

type TopClient

type TopClient struct {
	AppKey       string
	TargetAppKey string
	Session      string
	Timestamp    string
	Format       string
	V            string
	PartnerID    string
	Simplify     bool
	// contains filtered or unexported fields
}

func NewTopClient

func NewTopClient(appKey string, secretKey string) *TopClient

func (*TopClient) Execute

func (client *TopClient) Execute(req AlibabaRequest) (string, error)

Jump to

Keyboard shortcuts

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