pipe

package
v1.800.4 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeType

func NormalizeType(typ string) string

Types

type DiscordPipe

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

func NewDiscordPipe

func NewDiscordPipe(botToken string, publicKeyHex string, httpClient *http.Client) (*DiscordPipe, error)

func (*DiscordPipe) GetWebhookResponse

func (p *DiscordPipe) GetWebhookResponse(body []byte, header http.Header) (*WebhookResponse, error)

func (*DiscordPipe) ParseWebhookRequest

func (p *DiscordPipe) ParseWebhookRequest(body []byte) (*IncomingMessage, error)

func (*DiscordPipe) SendMessage

func (p *DiscordPipe) SendMessage(chatId string, text string) error

func (*DiscordPipe) SetWebhook

func (p *DiscordPipe) SetWebhook(webhookUrl string) error

type ImmediateWebhookResponder

type ImmediateWebhookResponder interface {
	GetWebhookResponse(body []byte, header http.Header) (*WebhookResponse, error)
}

ImmediateWebhookResponder is implemented by pipes that must reply to the webhook HTTP request before processing the message (e.g. Discord interactions).

type IncomingMessage

type IncomingMessage struct {
	ChatId   string
	UserId   string
	Text     string
	Username string
}

type Pipe

type Pipe interface {
	SendMessage(chatId string, text string) error
	ParseWebhookRequest(body []byte) (*IncomingMessage, error)
	SetWebhook(webhookUrl string) error
}

Pipe is the core interface every pipe platform must implement.

func Get

func Get(typ string, token string, secretKey string, pipeName string, lang string) (Pipe, error)

Get returns a Pipe implementation for the given pipe type. pipeName is passed to implementations that use it as part of their configuration (e.g. WhatsApp uses it as the webhook verify token).

type TelegramPipe

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

func NewTelegramPipe

func NewTelegramPipe(botToken string, httpClient *http.Client) (*TelegramPipe, error)

func (*TelegramPipe) ParseWebhookRequest

func (p *TelegramPipe) ParseWebhookRequest(body []byte) (*IncomingMessage, error)

func (*TelegramPipe) SendMessage

func (p *TelegramPipe) SendMessage(chatId string, text string) error

func (*TelegramPipe) SetWebhook

func (p *TelegramPipe) SetWebhook(webhookUrl string) error

type WebhookResponse

type WebhookResponse struct {
	StatusCode  int
	ContentType string
	Body        []byte
}

type WebhookVerifier

type WebhookVerifier interface {
	VerifyWebhook(params map[string]string) (*WebhookResponse, error)
}

WebhookVerifier is implemented by pipes that verify webhook ownership via a GET request challenge (e.g. WhatsApp Cloud API hub.challenge handshake).

type WhatsAppPipe

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

func NewWhatsAppPipe

func NewWhatsAppPipe(accessToken string, phoneNumberId string, verifyToken string, httpClient *http.Client) (*WhatsAppPipe, error)

func (*WhatsAppPipe) ParseWebhookRequest

func (p *WhatsAppPipe) ParseWebhookRequest(body []byte) (*IncomingMessage, error)

func (*WhatsAppPipe) SendMessage

func (p *WhatsAppPipe) SendMessage(chatId string, text string) error

func (*WhatsAppPipe) SetWebhook

func (p *WhatsAppPipe) SetWebhook(webhookUrl string) error

SetWebhook returns nil because WhatsApp webhooks are configured manually in the Meta Developer Console. The caller displays the webhook URL to the user.

func (*WhatsAppPipe) VerifyWebhook

func (p *WhatsAppPipe) VerifyWebhook(params map[string]string) (*WebhookResponse, error)

VerifyWebhook handles the Meta webhook verification challenge (GET request). The verify token is the pipe name, which must match what is configured in the Meta Developer Console as the webhook verify token.

Jump to

Keyboard shortcuts

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