sdkwa

package module
v0.0.0-...-6364639 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: MIT Imports: 14 Imported by: 0

README

SDKWA API Client Go

CI Go Version Go Report Card

A Go client library for the SDKWA API supporting both WhatsApp and Telegram messengers.

Features

  • Multi-Messenger Support: WhatsApp and Telegram
  • Flexible Configuration: Set default messenger or override per-request
  • Complete API Coverage: All API methods supported
  • Type-Safe: Fully typed request/response structs
  • Context Support: All methods support context.Context
  • Telegram-Specific Methods: CreateApp, SendConfirmationCode, SignInWithConfirmationCode

Installation

go get github.com/sdkwa/whatsapp-api-client-go

Quick Start

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/sdkwa/whatsapp-api-client-go"
)

func main() {
	// Create a WhatsApp client (default)
	client, err := sdkwa.NewClient(sdkwa.Options{
		IDInstance:       "your_instance_id",
		APITokenInstance: "your_api_token",
		MessengerType:    sdkwa.MessengerWhatsApp, // Optional: defaults to WhatsApp
	})
	if err != nil {
		log.Fatalf("Failed to create client: %v", err)
	}

	ctx := context.Background()

	// Send a WhatsApp message
	response, err := client.SendMessage(ctx, sdkwa.SendMessageParams{
		ChatID:  "79999999999@c.us",
		Message: "Hello from WhatsApp!",
	})
	if err != nil {
		log.Fatalf("Failed to send message: %v", err)
	}

	fmt.Printf("Message sent with ID: %s\n", response.IDMessage)

	// Send a Telegram message (override messenger type)
	response, err = client.SendMessage(ctx, sdkwa.SendMessageParams{
		ChatID:  "123456789",
		Message: "Hello from Telegram!",
	}, &sdkwa.RequestOptions{
		MessengerType: sdkwa.MessengerTelegram,
	})
	if err != nil {
		log.Fatalf("Failed to send Telegram message: %v", err)
	}

	fmt.Printf("Telegram message sent with ID: %s\n", response.IDMessage)
}

Supported Messengers

WhatsApp (Default)
client, _ := sdkwa.NewClient(sdkwa.Options{
    IDInstance:       "your_instance_id",
    APITokenInstance: "your_api_token",
    MessengerType:    sdkwa.MessengerWhatsApp, // Default
})
Telegram
client, _ := sdkwa.NewClient(sdkwa.Options{
    IDInstance:       "your_instance_id",
    APITokenInstance: "your_api_token",
    MessengerType:    sdkwa.MessengerTelegram,
})
Per-Request Override
// Use Telegram for a specific call, even if client defaults to WhatsApp
client.SendMessage(ctx, params, &sdkwa.RequestOptions{
    MessengerType: sdkwa.MessengerTelegram,
})

📖 Full Telegram Documentation

API Methods

All methods support both WhatsApp and Telegram through default messenger type or per-request override.

Telegram-Specific Methods
  • CreateApp - Create a Telegram application
  • SendConfirmationCode - Send authorization confirmation code
  • SignInWithConfirmationCode - Sign in with confirmation code
Account Management
  • Get/Set account settings
  • Get account state
  • Reboot/Logout account
  • QR code authorization
  • Phone number authorization
Messaging
  • Send text messages
  • Send files (by upload or URL)
  • Send contacts
  • Send locations
  • Upload files
Receiving
  • Receive notifications
  • Get chat history
  • Delete notifications
Chat Management
  • Get contacts and chats
  • Set profile picture/name/status
  • Get avatar
  • Check account availability
  • Mark messages as read
  • Archive/Unarchive chats
  • Delete messages
Group Management
  • Create groups
  • Update group name
  • Get group data
  • Add/Remove participants
  • Set/Remove admin rights
  • Leave group
  • Set group picture
Queue Management
  • Show messages queue
  • Clear messages queue
Instance Management (with user credentials)
  • Get instances
  • Create instances
  • Extend instances
  • Delete instances
  • Restore instances
Webhooks & Real-time Events
  • HTTP webhook handler
  • WebSocket client
  • Notification polling
  • Event callbacks

Configuration

The client accepts the following options:

client, err := sdkwa.NewClient(sdkwa.Options{
	APIHost:            "https://api.sdkwa.pro", // Optional, defaults to official API
	IDInstance:         "your_instance_id",      // Required
	APITokenInstance:   "your_api_token",        // Required
	UserID:             "your_user_id",          // Optional, for instance management
	UserToken:          "your_user_token",       // Optional, for instance management
	Timeout:            30 * time.Second,        // Optional, HTTP timeout
	InsecureSkipVerify: false,                   // Optional, skip TLS verification
})

Environment Variables

You can use environment variables for configuration:

  • SDKWA_API_HOST - API host URL
  • SDKWA_ID_INSTANCE - Instance ID
  • SDKWA_API_TOKEN - API token
  • SDKWA_USER_ID - User ID (for instance management)
  • SDKWA_USER_TOKEN - User token (for instance management)

Examples

Send Message
response, err := client.SendMessage(ctx, sdkwa.SendMessageParams{
	ChatID:  "79999999999@c.us",
	Message: "Hello World!",
})
Send File by Upload
file, err := os.Open("document.pdf")
if err != nil {
	log.Fatal(err)
}
defer file.Close()

response, err := client.SendFileByUpload(ctx, sdkwa.SendFileByUploadParams{
	ChatID:   "79999999999@c.us",
	File:     file,
	FileName: "document.pdf",
	Caption:  "Here's the document",
})
Create Group
response, err := client.CreateGroup(ctx, "My Group", []string{
	"79999999999@c.us",
	"79999999998@c.us",
})
Handle Webhooks
handler := sdkwa.NewWebhookHandler()

// Register message handler
handler.OnIncomingMessageText(func(data map[string]interface{}) error {
	fmt.Printf("Received message: %+v\n", data)
	return nil
})

// Use as HTTP handler
http.Handle("/webhook", handler)
http.ListenAndServe(":8080", nil)
WebSocket Real-time Events
handler := sdkwa.NewWebhookHandler()
handler.OnIncomingMessageText(func(data map[string]interface{}) error {
	fmt.Printf("Real-time message: %+v\n", data)
	return nil
})

wsClient := client.NewWebSocketClient(handler)
if err := wsClient.Connect(ctx); err != nil {
	log.Fatal(err)
}

// Listen for messages
if err := wsClient.Listen(ctx); err != nil {
	log.Fatal(err)
}
Polling for Notifications
handler := sdkwa.NewWebhookHandler()
handler.OnIncomingMessageText(func(data map[string]interface{}) error {
	fmt.Printf("Polled message: %+v\n", data)
	return nil
})

// Start polling (blocks until context is cancelled)
err := client.StartReceivingNotifications(ctx, handler)

Error Handling

The client returns structured errors:

response, err := client.SendMessage(ctx, params)
if err != nil {
	if apiError, ok := err.(*sdkwa.ErrorResponse); ok {
		fmt.Printf("API Error: %s (Status: %d)\n", apiError.Message, apiError.StatusCode)
	} else {
		fmt.Printf("Network Error: %v\n", err)
	}
}

Testing

Run tests with:

go test ./...

For integration tests, set environment variables:

export SDKWA_API_HOST="https://api.sdkwa.pro"
export SDKWA_ID_INSTANCE="your_instance_id"
export SDKWA_API_TOKEN="your_api_token"
go test ./...

Examples

See the examples/ directory for complete working examples:

  • send_message/ - Basic message sending
  • get_qr/ - QR code authorization
  • webhook_server/ - HTTP webhook server
  • create_group/ - Group creation
  • instance_management/ - Instance management

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Documentation

Overview

Package sdkwa provides a Go client for the SDKWA WhatsApp HTTP API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddGroupParticipantResponse

type AddGroupParticipantResponse struct {
	AddParticipant bool `json:"addParticipant"`
}

AddGroupParticipantResponse represents the response from adding group participant

type CheckWhatsAppResponse

type CheckWhatsAppResponse struct {
	ExistsWhatsApp bool `json:"existsWhatsapp"`
}

CheckWhatsAppResponse represents the response from checking WhatsApp availability

type ClearMessagesQueueResponse

type ClearMessagesQueueResponse struct {
	IsCleared bool `json:"isCleared"`
}

ClearMessagesQueueResponse represents the response from clearing messages queue

type Client

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

Client represents the SDKWA API client

func NewClient

func NewClient(opts Options) (*Client, error)

NewClient creates a new SDKWA client with the provided options

func (*Client) AddGroupParticipant

func (c *Client) AddGroupParticipant(ctx context.Context, groupID, participantChatID string, opts ...*RequestOptions) (*AddGroupParticipantResponse, error)

AddGroupParticipant adds a specified participant to a group chat

func (*Client) ArchiveChat

func (c *Client) ArchiveChat(ctx context.Context, chatID string, opts ...*RequestOptions) error

ArchiveChat archives a chat

func (*Client) CheckWhatsApp

func (c *Client) CheckWhatsApp(ctx context.Context, phoneNumber int64, opts ...*RequestOptions) (*CheckWhatsAppResponse, error)

CheckWhatsApp checks if an account exists for the specified phone number

func (*Client) ClearMessagesQueue

func (c *Client) ClearMessagesQueue(ctx context.Context, opts ...*RequestOptions) (*ClearMessagesQueueResponse, error)

ClearMessagesQueue clears all pending messages from the sending queue

func (*Client) CreateApp

func (c *Client) CreateApp(ctx context.Context, params CreateAppParams, opts ...*RequestOptions) (*CreateAppResponse, error)

CreateApp creates a new Telegram application

func (*Client) CreateGroup

func (c *Client) CreateGroup(ctx context.Context, groupName string, chatIDs []string, opts ...*RequestOptions) (*CreateGroupResponse, error)

CreateGroup creates a new group chat with the specified name and participants

func (*Client) CreateInstance

func (c *Client) CreateInstance(ctx context.Context, params CreateInstanceParams) (map[string]interface{}, error)

CreateInstance creates a new user instance with the specified tariff and period

func (*Client) DeleteInstance

func (c *Client) DeleteInstance(ctx context.Context, idInstance int64) (map[string]interface{}, error)

DeleteInstance deletes a user instance by its ID

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(ctx context.Context, chatID, messageID string, opts ...*RequestOptions) error

DeleteMessage deletes a message from a chat

func (*Client) DeleteNotification

func (c *Client) DeleteNotification(ctx context.Context, receiptID int64, opts ...*RequestOptions) (*DeleteNotificationResponse, error)

DeleteNotification deletes an incoming notification from the notification queue

func (*Client) ExtendInstance

func (c *Client) ExtendInstance(ctx context.Context, params ExtendInstanceParams) (map[string]interface{}, error)

ExtendInstance renews a paid user instance for the specified period and tariff

func (*Client) GetAuthorizationCode

func (c *Client) GetAuthorizationCode(ctx context.Context, params GetAuthorizationCodeParams, opts ...*RequestOptions) (*GetAuthorizationCodeResponse, error)

GetAuthorizationCode gets authorization code for account authorization

func (*Client) GetAvatar

func (c *Client) GetAvatar(ctx context.Context, chatID string, opts ...*RequestOptions) (map[string]interface{}, error)

GetAvatar returns the avatar URL for a user or group chat

func (*Client) GetChatHistory

func (c *Client) GetChatHistory(ctx context.Context, params GetChatHistoryParams, opts ...*RequestOptions) ([]map[string]interface{}, error)

GetChatHistory returns the message history for a specified chat

func (*Client) GetChats

func (c *Client) GetChats(ctx context.Context, opts ...*RequestOptions) ([]map[string]interface{}, error)

GetChats retrieves a list of all chats for the current account

func (*Client) GetContactInfo

func (c *Client) GetContactInfo(ctx context.Context, chatID string, opts ...*RequestOptions) (map[string]interface{}, error)

GetContactInfo retrieves detailed information about a contact

func (*Client) GetContacts

func (c *Client) GetContacts(ctx context.Context, opts ...*RequestOptions) ([]map[string]interface{}, error)

GetContacts retrieves a list of contacts for the current account

func (*Client) GetGroupData

func (c *Client) GetGroupData(ctx context.Context, groupID string, opts ...*RequestOptions) (map[string]interface{}, error)

GetGroupData retrieves information about a group chat

func (*Client) GetInstances

func (c *Client) GetInstances(ctx context.Context) (map[string]interface{}, error)

GetInstances retrieves all account instances created by the user

func (*Client) GetQR

func (c *Client) GetQR(ctx context.Context, opts ...*RequestOptions) (*QRResponse, error)

GetQR returns a QR code for authorizing your account

func (*Client) GetSettings

func (c *Client) GetSettings(ctx context.Context, opts ...*RequestOptions) (map[string]interface{}, error)

GetSettings retrieves the current account settings

func (*Client) GetStateInstance

func (c *Client) GetStateInstance(ctx context.Context, opts ...*RequestOptions) (*StateInstanceResponse, error)

GetStateInstance retrieves the current state of the account instance

func (*Client) GetWarmingPhoneStatus

func (c *Client) GetWarmingPhoneStatus(ctx context.Context, opts ...*RequestOptions) (map[string]interface{}, error)

GetWarmingPhoneStatus gets the account warming state

func (*Client) LeaveGroup

func (c *Client) LeaveGroup(ctx context.Context, groupID string, opts ...*RequestOptions) (*LeaveGroupResponse, error)

LeaveGroup allows the current account user to leave a specified group chat

func (*Client) Logout

func (c *Client) Logout(ctx context.Context, opts ...*RequestOptions) (*LogoutResponse, error)

Logout logs out the specified account instance

func (*Client) NewWebSocketClient

func (c *Client) NewWebSocketClient(handler *WebhookHandler) *WebSocketClient

NewWebSocketClient creates a new WebSocket client

func (*Client) ReadChat

func (c *Client) ReadChat(ctx context.Context, params ReadChatParams, opts ...*RequestOptions) (*ReadChatResponse, error)

ReadChat marks messages in a chat as read

func (*Client) Reboot

func (c *Client) Reboot(ctx context.Context, opts ...*RequestOptions) (*RebootResponse, error)

Reboot reboots the specified account instance

func (*Client) ReceiveNotification

func (c *Client) ReceiveNotification(ctx context.Context, opts ...*RequestOptions) (map[string]interface{}, error)

ReceiveNotification retrieves a single incoming notification from the notifications queue

func (*Client) RemoveAdmin

func (c *Client) RemoveAdmin(ctx context.Context, groupID, participantChatID string, opts ...*RequestOptions) (*RemoveAdminResponse, error)

RemoveAdmin revokes administrator rights from a specified participant in a group chat

func (*Client) RemoveGroupParticipant

func (c *Client) RemoveGroupParticipant(ctx context.Context, groupID, participantChatID string, opts ...*RequestOptions) (*RemoveGroupParticipantResponse, error)

RemoveGroupParticipant removes a specified participant from a group chat

func (*Client) RequestRegistrationCode

func (c *Client) RequestRegistrationCode(ctx context.Context, params RequestRegistrationCodeParams, opts ...*RequestOptions) (map[string]interface{}, error)

RequestRegistrationCode requests a phone number registration code via SMS or call

func (*Client) RestoreInstance

func (c *Client) RestoreInstance(ctx context.Context, idInstance int64) (map[string]interface{}, error)

RestoreInstance restores a user instance by its ID

func (*Client) SendConfirmationCode

func (c *Client) SendConfirmationCode(ctx context.Context, params SendConfirmationCodeParams, opts ...*RequestOptions) (*SendConfirmationCodeResponse, error)

SendConfirmationCode sends a confirmation code for Telegram account authorization

func (*Client) SendContact

func (c *Client) SendContact(ctx context.Context, params SendContactParams, opts ...*RequestOptions) (*SendContactResponse, error)

SendContact sends a contact card message to a chat

func (*Client) SendFileByURL

func (c *Client) SendFileByURL(ctx context.Context, params SendFileByURLParams, opts ...*RequestOptions) (*SendFileByURLResponse, error)

SendFileByURL sends a file by providing its URL

func (*Client) SendFileByUpload

func (c *Client) SendFileByUpload(ctx context.Context, params SendFileByUploadParams, opts ...*RequestOptions) (*SendFileByUploadResponse, error)

SendFileByUpload sends a file by uploading it using form-data

func (*Client) SendLocation

func (c *Client) SendLocation(ctx context.Context, params SendLocationParams, opts ...*RequestOptions) (*SendLocationResponse, error)

SendLocation sends a location message to a chat

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, params SendMessageParams, opts ...*RequestOptions) (*SendMessageResponse, error)

SendMessage sends a text message to either a personal or group chat

func (*Client) SendRegistrationCode

func (c *Client) SendRegistrationCode(ctx context.Context, params SendRegistrationCodeParams, opts ...*RequestOptions) (map[string]interface{}, error)

SendRegistrationCode sends the phone number registration code

func (*Client) SetGroupAdmin

func (c *Client) SetGroupAdmin(ctx context.Context, groupID, participantChatID string, opts ...*RequestOptions) (*SetGroupAdminResponse, error)

SetGroupAdmin assigns administrator rights to a specified participant in a group chat

func (*Client) SetGroupPicture

func (c *Client) SetGroupPicture(ctx context.Context, groupID string, file io.Reader, opts ...*RequestOptions) (*SetGroupPictureResponse, error)

SetGroupPicture sets a new picture for a group chat

func (*Client) SetProfileName

func (c *Client) SetProfileName(ctx context.Context, name string, opts ...*RequestOptions) error

SetProfileName sets a new profile name for the account

func (*Client) SetProfilePicture

func (c *Client) SetProfilePicture(ctx context.Context, file io.Reader, opts ...*RequestOptions) (*SetProfilePictureResponse, error)

SetProfilePicture sets a new profile picture for the account

func (*Client) SetProfileStatus

func (c *Client) SetProfileStatus(ctx context.Context, status string, opts ...*RequestOptions) error

SetProfileStatus sets a new status message for the account

func (*Client) SetSettings

func (c *Client) SetSettings(ctx context.Context, settings map[string]interface{}, opts ...*RequestOptions) (*SetSettingsResponse, error)

SetSettings updates the account settings

func (*Client) ShowMessagesQueue

func (c *Client) ShowMessagesQueue(ctx context.Context, opts ...*RequestOptions) ([]map[string]interface{}, error)

ShowMessagesQueue retrieves a list of messages currently in the sending queue

func (*Client) SignInWithConfirmationCode

func (c *Client) SignInWithConfirmationCode(ctx context.Context, params SignInWithConfirmationCodeParams, opts ...*RequestOptions) (*SignInWithConfirmationCodeResponse, error)

SignInWithConfirmationCode signs in using a confirmation code for Telegram

func (*Client) StartReceivingNotifications

func (c *Client) StartReceivingNotifications(ctx context.Context, handler *WebhookHandler) error

StartReceivingNotifications starts receiving notifications via polling

func (*Client) UnarchiveChat

func (c *Client) UnarchiveChat(ctx context.Context, chatID string, opts ...*RequestOptions) error

UnarchiveChat unarchives a chat

func (*Client) UpdateGroupName

func (c *Client) UpdateGroupName(ctx context.Context, groupID, groupName string, opts ...*RequestOptions) (*UpdateGroupNameResponse, error)

UpdateGroupName changes the name of a group chat

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, file io.Reader, opts ...*RequestOptions) (*UploadFileResponse, error)

UploadFile uploads a file to storage for later sending

type Contact

type Contact struct {
	PhoneContact int64  `json:"phoneContact"`
	FirstName    string `json:"firstName,omitempty"`
	MiddleName   string `json:"middleName,omitempty"`
	LastName     string `json:"lastName,omitempty"`
	Company      string `json:"company,omitempty"`
}

Contact represents a contact information

type CreateAppParams

type CreateAppParams struct {
	Title       string `json:"title"`
	ShortName   string `json:"shortName"`
	URL         string `json:"url"`
	Description string `json:"description,omitempty"`
}

CreateAppParams represents parameters for creating a Telegram app

type CreateAppResponse

type CreateAppResponse struct {
	Result bool `json:"result"`
	Data   struct {
		AppID string `json:"appId"`
	} `json:"data"`
}

CreateAppResponse represents the response from creating a Telegram app

type CreateGroupResponse

type CreateGroupResponse struct {
	Created         bool   `json:"created"`
	ChatID          string `json:"chatId"`
	GroupInviteLink string `json:"groupInviteLink"`
}

CreateGroupResponse represents the response from creating a group

type CreateInstanceParams

type CreateInstanceParams struct {
	Tariff      string `json:"tariff"`
	Period      string `json:"period"`
	PaymentType string `json:"paymentType,omitempty"`
}

CreateInstanceParams represents parameters for creating an instance

type DeleteNotificationResponse

type DeleteNotificationResponse struct {
	Result bool `json:"result"`
}

DeleteNotificationResponse represents the response from deleting a notification

type ErrorResponse

type ErrorResponse struct {
	StatusCode int    `json:"statusCode,omitempty"`
	Timestamp  string `json:"timestamp,omitempty"`
	Path       string `json:"path,omitempty"`
	Message    string `json:"message"`
}

ErrorResponse represents an error response from the API

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type ExtendInstanceParams

type ExtendInstanceParams struct {
	IDInstance  int64  `json:"idInstance"`
	Tariff      string `json:"tariff"`
	Period      string `json:"period"`
	PaymentType string `json:"paymentType,omitempty"`
}

ExtendInstanceParams represents parameters for extending an instance

type GetAuthorizationCodeParams

type GetAuthorizationCodeParams struct {
	PhoneNumber int64 `json:"phoneNumber"`
}

GetAuthorizationCodeParams represents parameters for getting authorization code

type GetAuthorizationCodeResponse

type GetAuthorizationCodeResponse struct {
	Status bool   `json:"status"`
	Code   string `json:"code"`
}

GetAuthorizationCodeResponse represents the response from getting authorization code

type GetChatHistoryParams

type GetChatHistoryParams struct {
	ChatID string `json:"chatId"`
	Count  int    `json:"count,omitempty"`
}

GetChatHistoryParams represents parameters for getting chat history

type LeaveGroupResponse

type LeaveGroupResponse struct {
	LeaveGroup bool `json:"leaveGroup"`
}

LeaveGroupResponse represents the response from leaving a group

type LogoutResponse

type LogoutResponse struct {
	IsLogout bool `json:"isLogout"`
}

LogoutResponse represents the response from logging out an account

type MessengerType

type MessengerType string

MessengerType represents the messenger type

const (
	// MessengerWhatsApp represents WhatsApp messenger
	MessengerWhatsApp MessengerType = "whatsapp"
	// MessengerTelegram represents Telegram messenger
	MessengerTelegram MessengerType = "telegram"
)

type Options

type Options struct {
	APIHost            string        // API host URL, defaults to https://api.sdkwa.pro
	IDInstance         string        // Instance ID (required)
	APITokenInstance   string        // API token instance (required)
	MessengerType      MessengerType // Messenger type, defaults to whatsapp
	UserID             string        // User ID (optional, required for instance management)
	UserToken          string        // User token (optional, required for instance management)
	Timeout            time.Duration // HTTP client timeout, defaults to 30 seconds
	InsecureSkipVerify bool          // Skip TLS certificate verification
}

Options contains configuration options for the SDKWA client

type QRResponse

type QRResponse struct {
	Type    string `json:"type"`
	Message string `json:"message"`
}

QRResponse represents the response from getting QR code

type ReadChatParams

type ReadChatParams struct {
	ChatID    string `json:"chatId"`
	IDMessage string `json:"idMessage,omitempty"`
}

ReadChatParams represents parameters for marking chat messages as read

type ReadChatResponse

type ReadChatResponse struct {
	SetRead bool `json:"setRead"`
}

ReadChatResponse represents the response from marking chat messages as read

type RebootResponse

type RebootResponse struct {
	IsReboot bool `json:"isReboot"`
}

RebootResponse represents the response from rebooting an account

type RemoveAdminResponse

type RemoveAdminResponse struct {
	RemoveAdmin bool `json:"removeAdmin"`
}

RemoveAdminResponse represents the response from removing admin rights

type RemoveGroupParticipantResponse

type RemoveGroupParticipantResponse struct {
	RemoveParticipant bool `json:"removeParticipant"`
}

RemoveGroupParticipantResponse represents the response from removing group participant

type RequestOptions

type RequestOptions struct {
	MessengerType MessengerType // Override messenger type for this request
}

RequestOptions contains options for individual API requests

type RequestRegistrationCodeParams

type RequestRegistrationCodeParams struct {
	PhoneNumber int64  `json:"phoneNumber"`
	Method      string `json:"method"` // "sms" or "voice"
}

RequestRegistrationCodeParams represents parameters for requesting registration code

type SendConfirmationCodeParams

type SendConfirmationCodeParams struct {
	PhoneNumber int64 `json:"phoneNumber"`
}

SendConfirmationCodeParams represents parameters for sending confirmation code

type SendConfirmationCodeResponse

type SendConfirmationCodeResponse struct {
	Result  bool   `json:"result"`
	Message string `json:"message"`
}

SendConfirmationCodeResponse represents the response from sending confirmation code

type SendContactParams

type SendContactParams struct {
	ChatID          string  `json:"chatId"`
	Contact         Contact `json:"contact"`
	QuotedMessageID string  `json:"quotedMessageId,omitempty"`
}

SendContactParams represents parameters for sending a contact

type SendContactResponse

type SendContactResponse struct {
	IDMessage string `json:"idMessage"`
}

SendContactResponse represents the response from sending a contact

type SendFileByURLParams

type SendFileByURLParams struct {
	ChatID          string `json:"chatId"`
	URLFile         string `json:"urlFile"`
	FileName        string `json:"fileName"`
	Caption         string `json:"caption,omitempty"`
	QuotedMessageID string `json:"quotedMessageId,omitempty"`
	ArchiveChat     bool   `json:"archiveChat,omitempty"`
}

SendFileByURLParams represents parameters for sending a file by URL

type SendFileByURLResponse

type SendFileByURLResponse struct {
	IDMessage string `json:"idMessage"`
}

SendFileByURLResponse represents the response from sending a file by URL

type SendFileByUploadParams

type SendFileByUploadParams struct {
	ChatID          string    `json:"chatId"`
	File            io.Reader `json:"-"` // File content
	FileName        string    `json:"fileName"`
	Caption         string    `json:"caption,omitempty"`
	QuotedMessageID string    `json:"quotedMessageId,omitempty"`
}

SendFileByUploadParams represents parameters for sending a file by upload

type SendFileByUploadResponse

type SendFileByUploadResponse struct {
	IDMessage string `json:"idMessage"`
}

SendFileByUploadResponse represents the response from sending a file by upload

type SendLocationParams

type SendLocationParams struct {
	ChatID          string  `json:"chatId"`
	NameLocation    string  `json:"nameLocation,omitempty"`
	Address         string  `json:"address,omitempty"`
	Latitude        float64 `json:"latitude"`
	Longitude       float64 `json:"longitude"`
	QuotedMessageID string  `json:"quotedMessageId,omitempty"`
}

SendLocationParams represents parameters for sending a location

type SendLocationResponse

type SendLocationResponse struct {
	IDMessage string `json:"idMessage"`
}

SendLocationResponse represents the response from sending a location

type SendMessageParams

type SendMessageParams struct {
	ChatID          string `json:"chatId"`
	Message         string `json:"message"`
	QuotedMessageID string `json:"quotedMessageId,omitempty"`
	ArchiveChat     bool   `json:"archiveChat,omitempty"`
	LinkPreview     bool   `json:"linkPreview,omitempty"`
}

SendMessageParams represents parameters for sending a text message

type SendMessageResponse

type SendMessageResponse struct {
	IDMessage string `json:"idMessage"`
}

SendMessageResponse represents the response from sending a message

type SendRegistrationCodeParams

type SendRegistrationCodeParams struct {
	Code string `json:"code"`
}

SendRegistrationCodeParams represents parameters for sending registration code

type SetGroupAdminResponse

type SetGroupAdminResponse struct {
	SetGroupAdmin bool `json:"setGroupAdmin"`
}

SetGroupAdminResponse represents the response from setting group admin

type SetGroupPictureResponse

type SetGroupPictureResponse struct {
	SetGroupPicture bool   `json:"setGroupPicture"`
	URLAvatar       string `json:"urlAvatar"`
	Reason          string `json:"reason"`
}

SetGroupPictureResponse represents the response from setting group picture

type SetProfilePictureResponse

type SetProfilePictureResponse struct {
	SetProfilePicture bool   `json:"setProfilePicture"`
	URLAvatar         string `json:"urlAvatar"`
	Reason            string `json:"reason"`
}

SetProfilePictureResponse represents the response from setting profile picture

type SetSettingsResponse

type SetSettingsResponse struct {
	SaveSettings bool `json:"saveSettings"`
}

SetSettingsResponse represents the response from setting account settings

type SignInWithConfirmationCodeParams

type SignInWithConfirmationCodeParams struct {
	Code string `json:"code"`
}

SignInWithConfirmationCodeParams represents parameters for signing in with confirmation code

type SignInWithConfirmationCodeResponse

type SignInWithConfirmationCodeResponse struct {
	Result  bool   `json:"result"`
	Message string `json:"message"`
}

SignInWithConfirmationCodeResponse represents the response from signing in with confirmation code

type StateInstanceResponse

type StateInstanceResponse struct {
	StateInstance string `json:"stateInstance"`
}

StateInstanceResponse represents the response from getting account state

type UpdateGroupNameResponse

type UpdateGroupNameResponse struct {
	UpdateGroupName bool `json:"updateGroupName"`
}

UpdateGroupNameResponse represents the response from updating group name

type UploadFileResponse

type UploadFileResponse struct {
	URLFile string `json:"urlFile"`
}

UploadFileResponse represents the response from uploading a file

type WebSocketClient

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

WebSocketClient handles WebSocket connections for real-time events

func (*WebSocketClient) Close

func (ws *WebSocketClient) Close() error

Close closes the WebSocket connection

func (*WebSocketClient) Connect

func (ws *WebSocketClient) Connect(ctx context.Context) error

Connect establishes a WebSocket connection

func (*WebSocketClient) Listen

func (ws *WebSocketClient) Listen(ctx context.Context) error

Listen starts listening for WebSocket messages

type WebhookCallback

type WebhookCallback func(data map[string]interface{}) error

WebhookCallback represents a callback function for webhook events

type WebhookHandler

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

WebhookHandler handles webhook events from the SDKWA API

func NewWebhookHandler

func NewWebhookHandler() *WebhookHandler

NewWebhookHandler creates a new webhook handler

func (*WebhookHandler) HandleWebhook

func (w *WebhookHandler) HandleWebhook(data map[string]interface{}) error

HandleWebhook processes a webhook request

func (*WebhookHandler) OnDeviceInfo

func (w *WebhookHandler) OnDeviceInfo(callback WebhookCallback)

OnDeviceInfo registers a callback for device info events

func (*WebhookHandler) OnIncomingMessageContact

func (w *WebhookHandler) OnIncomingMessageContact(callback WebhookCallback)

OnIncomingMessageContact registers a callback for incoming contact message events

func (*WebhookHandler) OnIncomingMessageExtendedText

func (w *WebhookHandler) OnIncomingMessageExtendedText(callback WebhookCallback)

OnIncomingMessageExtendedText registers a callback for incoming extended text message events

func (*WebhookHandler) OnIncomingMessageFile

func (w *WebhookHandler) OnIncomingMessageFile(callback WebhookCallback)

OnIncomingMessageFile registers a callback for incoming file message events

func (*WebhookHandler) OnIncomingMessageLocation

func (w *WebhookHandler) OnIncomingMessageLocation(callback WebhookCallback)

OnIncomingMessageLocation registers a callback for incoming location message events

func (*WebhookHandler) OnIncomingMessageText

func (w *WebhookHandler) OnIncomingMessageText(callback WebhookCallback)

OnIncomingMessageText registers a callback for incoming text message events

func (*WebhookHandler) OnOutgoingMessageStatus

func (w *WebhookHandler) OnOutgoingMessageStatus(callback WebhookCallback)

OnOutgoingMessageStatus registers a callback for outgoing message status events

func (*WebhookHandler) OnStateInstance

func (w *WebhookHandler) OnStateInstance(callback WebhookCallback)

OnStateInstance registers a callback for state instance changed events

func (*WebhookHandler) ServeHTTP

func (w *WebhookHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler interface for webhook handling

type WebhookType

type WebhookType string

WebhookType represents the type of webhook event

const (
	WebhookTypeStateInstanceChanged                       WebhookType = "stateInstanceChanged"
	WebhookTypeOutgoingMessageStatus                      WebhookType = "outgoingMessageStatus"
	WebhookTypeIncomingMessageReceivedTextMessage         WebhookType = "incomingMessageReceived_textMessage"
	WebhookTypeIncomingMessageReceivedImageMessage        WebhookType = "incomingMessageReceived_imageMessage"
	WebhookTypeIncomingMessageReceivedLocationMessage     WebhookType = "incomingMessageReceived_locationMessage"
	WebhookTypeIncomingMessageReceivedContactMessage      WebhookType = "incomingMessageReceived_contactMessage"
	WebhookTypeIncomingMessageReceivedExtendedTextMessage WebhookType = "incomingMessageReceived_extendedTextMessage"
	WebhookTypeDeviceInfo                                 WebhookType = "deviceInfo"
)

Directories

Path Synopsis
examples
comprehensive command
create_group command
get_qr command
send_file_url command
send_message command
telegram_auth command
webhook_server command

Jump to

Keyboard shortcuts

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