Documentation
¶
Index ¶
- func NewFactory() im.AdapterFactory
- type Adapter
- func (a *Adapter) DownloadFile(ctx context.Context, msg *im.IncomingMessage) (io.ReadCloser, string, error)
- func (a *Adapter) EndStream(ctx context.Context, incoming *im.IncomingMessage, streamID string) error
- func (a *Adapter) FinalizeStream(ctx context.Context, incoming *im.IncomingMessage, streamID string, ...) error
- func (a *Adapter) HandleURLVerification(c *gin.Context) bool
- func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error)
- func (a *Adapter) Platform() im.Platform
- func (a *Adapter) SendReply(ctx context.Context, incoming *im.IncomingMessage, reply *im.ReplyMessage) error
- func (a *Adapter) SendStreamChunk(ctx context.Context, incoming *im.IncomingMessage, streamID string, ...) error
- func (a *Adapter) StartStream(ctx context.Context, incoming *im.IncomingMessage) (string, error)
- func (a *Adapter) UpdateStreamContent(ctx context.Context, incoming *im.IncomingMessage, streamID string, ...) error
- func (a *Adapter) VerifyCallback(c *gin.Context) error
- type LongConnClient
- type MessageHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFactory ¶
func NewFactory() im.AdapterFactory
NewFactory returns an im.AdapterFactory for DingTalk channels. Supports "websocket" (Stream) only.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements im.Adapter for DingTalk.
func NewAdapter ¶
NewAdapter creates a DingTalk adapter for stream (websocket) mode. The stream connection itself is managed separately by the supervisor; the adapter only sends replies (via sessionWebhook or OpenAPI).
func NewWebhookAdapter ¶
NewWebhookAdapter creates a DingTalk adapter for HTTP callback mode.
func (*Adapter) DownloadFile ¶
func (a *Adapter) DownloadFile(ctx context.Context, msg *im.IncomingMessage) (io.ReadCloser, string, error)
DownloadFile downloads a file/picture the user sent to the robot. DingTalk does not deliver the bytes directly: the callback carries a downloadCode that is exchanged for a temporary downloadUrl via robot/messageFiles/download, which is then fetched. robotCode comes from the callback (webhook mode) or the app client ID (stream mode). Implements im.FileDownloader (issue #1771).
func (*Adapter) FinalizeStream ¶
func (*Adapter) HandleURLVerification ¶
func (*Adapter) ParseCallback ¶
func (*Adapter) SendReply ¶
func (a *Adapter) SendReply(ctx context.Context, incoming *im.IncomingMessage, reply *im.ReplyMessage) error
func (*Adapter) SendStreamChunk ¶
func (*Adapter) StartStream ¶
func (*Adapter) UpdateStreamContent ¶
type LongConnClient ¶
type LongConnClient struct {
// contains filtered or unexported fields
}
LongConnClient manages a DingTalk Stream mode connection.
func NewLongConnClient ¶
func NewLongConnClient(clientID, clientSecret string, handler MessageHandler) *LongConnClient
NewLongConnClient creates a DingTalk stream client.
func (*LongConnClient) Close ¶
func (c *LongConnClient) Close()
Close tears down the stream connection. AutoReconnect is disabled first so that closing the connection does not trigger the SDK's internal reconnect.
func (*LongConnClient) Start ¶
func (c *LongConnClient) Start(ctx context.Context) error
Start establishes the stream connection. The underlying SDK's Start is non-blocking: it dials the websocket, spawns its internal read/reconnect loops, and returns once the connection is established (or the attempt fails).
type MessageHandler ¶
type MessageHandler func(ctx context.Context, msg *im.IncomingMessage) error
MessageHandler is called when an IM message is received via stream connection.