dingtalk

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

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

func NewAdapter(clientID, clientSecret, cardTemplateID string) *Adapter

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

func NewWebhookAdapter(clientID, clientSecret, cardTemplateID string) *Adapter

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) EndStream

func (a *Adapter) EndStream(ctx context.Context, incoming *im.IncomingMessage, streamID string) error

func (*Adapter) FinalizeStream

func (a *Adapter) FinalizeStream(ctx context.Context, incoming *im.IncomingMessage, streamID string, finalContent string) error

func (*Adapter) HandleURLVerification

func (a *Adapter) HandleURLVerification(c *gin.Context) bool

func (*Adapter) ParseCallback

func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error)

func (*Adapter) Platform

func (a *Adapter) Platform() im.Platform

func (*Adapter) SendReply

func (a *Adapter) SendReply(ctx context.Context, incoming *im.IncomingMessage, reply *im.ReplyMessage) error

func (*Adapter) SendStreamChunk

func (a *Adapter) SendStreamChunk(ctx context.Context, incoming *im.IncomingMessage, streamID string, content string) error

func (*Adapter) StartStream

func (a *Adapter) StartStream(ctx context.Context, incoming *im.IncomingMessage) (string, error)

func (*Adapter) UpdateStreamContent

func (a *Adapter) UpdateStreamContent(ctx context.Context, incoming *im.IncomingMessage, streamID string, fullContent string) error

func (*Adapter) VerifyCallback

func (a *Adapter) VerifyCallback(c *gin.Context) error

VerifyCallback refuses the legacy HTTP protocol because its timestamp-only signature cannot authenticate the message body. Stream events use the SDK.

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.

Jump to

Keyboard shortcuts

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