chat

package
v1.1.71 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadUserChatEvent = 301
	ChatEvent         = 103
)

Variables

This section is empty.

Functions

func LocalId

func LocalId() string

func ReplyTime

func ReplyTime() int64

func ReplyTimeStr

func ReplyTimeStr() string

func StartTime

func StartTime() string

Types

type Attachment

type Attachment struct {
	Attributes         Attributes         `json:"attributes"`
	FallbackAttachment FallbackAttachment `json:"fallback_attachment"`
	Id                 int64              `json:"id"`
	Type               int64              `json:"type"`
}

type Attributes

type Attributes struct {
	ProductId      int64          `json:"product_id,omitempty"`
	ProductProfile ProductProfile `json:"product_profile,omitempty"`
	Source         string         `json:"source,omitempty"`
	StickerProfile *Payload       `json:"sticker_profile,omitempty"`
}

type BaseSocketType

type BaseSocketType struct {
	Code uint        `json:"code"`
	Data interface{} `json:"data"`
}

type DataResp

type DataResp struct {
	MsgId             uint           `json:"msg_id"`
	From              string         `json:"from,omitempty"`
	FromUid           string         `json:"from_uid,omitempty"`
	FromUserName      string         `json:"from_user_name,omitempty"`
	FromRole          string         `json:"from_role,omitempty"`
	ReminderTicker    any            `json:"reminder_ticker,omitempty"`
	IsOpposite        bool           `json:"is_opposite,omitempty"`
	ToUid             uint           `json:"to_uid,omitempty"`
	ClientConnectTime string         `json:"client_connect_time,omitempty"`
	Thumbnail         string         `json:"thumbnail,omitempty"`
	Message           *MessageResp   `json:"message,omitempty"`
	StartTime         string         `json:"start_time,omitempty"`
	ShowRating        bool           `json:"show_rating,omitempty"`
	LocalId           string         `json:"local_id,omitempty"`
	Source            string         `json:"source,omitempty"`
	ParentReply       *ParentReply   `json:"parent_reply,omitempty"`
	AttachmentId      int64          `json:"attachment_id,omitempty"`
	Attachment        *Attachment    `json:"attachment,omitempty"`
	Extras            *ExtrasProduct `json:"extras_product,omitempty"`
}

type DataSend

type DataSend struct {
	MessageId      uint            `json:"message_id"`
	Message        string          `json:"message,omitempty"`
	StartTime      string          `json:"start_time,omitempty"`
	ParentReply    *ParentReply    `json:"parent_reply,omitempty"`
	From           string          `json:"from,omitempty"`
	FromUserName   string          `json:"from_user_name,omitempty"`
	LocalId        string          `json:"local_id,omitempty"`
	Source         string          `json:"source,omitempty"`
	AttachmentType int64           `json:"attachment_type,omitempty"`
	ProductProfile *ProductProfile `json:"product_profile,omitempty"`
	Payload        *Payload        `json:"payload,omitempty"`
	Extras         *Extras         `json:"extras,omitempty"`
	FilePath       string          `json:"file_path,omitempty"`
}

type EmitEventSocket

type EmitEventSocket struct {
	*EventCode
	Data interface{} `json:"data"`
}

func (*EmitEventSocket) UnmarshalJSON

func (event *EmitEventSocket) UnmarshalJSON(data []byte) error

type EventCode

type EventCode struct {
	Code EventType `json:"code"`
}

type EventType

type EventType int

type Extras

type Extras struct {
	ExtrasProduct []ExtrasProduct `json:"extras_product"`
}

type ExtrasProduct

type ExtrasProduct struct {
	Url       string `json:"url"`
	ProductId string `json:"product_id"`
}

type FallbackAttachment

type FallbackAttachment struct {
	Html    string `json:"html"`
	Message string `json:"message"`
}

type FreeOngkir

type FreeOngkir struct {
	IsActive bool   `json:"is_active"`
	ImageUrl string `json:"image_url"`
}

type LocationStock

type LocationStock struct {
	Addressid            int64  `json:"address_id"`
	DistrictId           int64  `json:"district_id"`
	DistrictName         string `json:"district_name"`
	DistrictIcon         string `json:"district_icon"`
	DistrictNameFullText string `json:"district_name_full_text"`
	PostalCode           string `json:"postal_code"`
	Latlon               string `json:"latlon"`
}

type Message

type Message struct {
	CensoredReply     string    `json:"censored_reply"`
	OriginalReply     string    `json:"original_reply"`
	Timestamp         time.Time `json:"timestamp"`
	TimestampFmt      string    `json:"timestamp_fmt"`
	TimestampUnix     int64     `json:"timestamp_unix"`
	TimestampUnixNano int64     `json:"timestamp_unix_nano"`
}

type MessageId

type MessageId struct {
	MsgId uint `json:"msg_id"`
}

type MessageResp

type MessageResp struct {
	CensoredReply     string `json:"censored_reply,omitempty"`
	OriginalReply     string `json:"original_reply,omitempty"`
	Timestamp         string `json:"timestamp,omitempty"`
	TimestampFmt      string `json:"timestamp_fmt,omitempty"`
	TimestampUnix     uint   `json:"timestamp_unix,omitempty"`
	TimestampUnixNano uint   `json:"timestamp_unix_nano,omitempty"`
}

type ParentReply

type ParentReply struct {
	AttachmentId    int64  `json:"attachment_id"`
	AttachmentType  int64  `json:"attachment_type"`
	SenderId        int64  `json:"sender_id"`
	Name            string `json:"string"`
	ReplyTime       int64  `json:"reply_time"`
	ReplyTimeString string `json:"reply_time_string"`
	MainText        string `json:"main_text"`
	Source          string `json:"inbox"`
}

type Payload

type Payload struct {
	GroupId   string `json:"group_id"`
	StickerId string `json:"sticker_id"`
	ImageUrl  string `json:"image_url"`
	Intention string `json:"intention"`
}

type ProductProfile

type ProductProfile struct {
	ImageUrl                  string        `json:"image_url"`
	Name                      string        `json:"name"`
	ParentId                  int64         `json:"parent_id"`
	Price                     string        `json:"price"`
	PriceInt                  int64         `json:"price_int"`
	Url                       string        `json:"url"`
	AndroidUrl                string        `json:"android_url"`
	IosUrl                    string        `json:"ios_url"`
	IsUpcomingCampaignProduct bool          `json:"is_upcoming_campaign_product"`
	PlayStoreProductData      interface{}   `json:"playstore_product_data"`
	ShopId                    int64         `json:"shop_id"`
	Status                    int64         `json:"status"`
	MinOrder                  int64         `json:"mmin_order"`
	Categoryid                int64         `json:"category_id"`
	RemainingStock            int64         `json:"remaining_stock"`
	CategoryBreadCrumb        string        `json:"category_breadcrumb"`
	ListImageUrl              []string      `json:"list_image_url"`
	Variant                   []interface{} `json:"variant"`
	Wishlist                  bool          `json:"wishlist"`
	FreeOngkir                FreeOngkir    `json:"free_ongkir"`
	Rating                    interface{}   `json:"rating"`
	IsFulfillment             bool          `json:"is_fulfillment"`
	IconTokoCabang            string        `json:"icon_tokocabang"`
	DescTokoCabang            string        `json:"desc_tokocabang"`
	StockInfo                 interface{}   `json:"stock_info"`
	LocationStock             LocationStock `json:"location_stock"`
	Type                      string        `json:"type"`
	DefaultChild              int64         `json:"defaultChild"`
	Id                        int64         `json:"id"`
	DropPercentage            string        `json:"dropPercentage"`
	PriceBefore               string        `json:"priceBefore"`
	Text                      string        `json:"text"`
}

type RcvChat

type RcvChat struct {
	MsgID             int64          `json:"msg_id"`
	From              string         `json:"from"`
	FromUID           int            `json:"from_uid"`
	FromUserName      string         `json:"from_user_name"`
	FromRole          string         `json:"from_role"`
	Thumbnail         string         `json:"thumbnail"`
	ReminderTicker    ReminderTicker `json:"reminder_ticker"`
	IsOpposite        bool           `json:"is_opposite"`
	ToUID             int            `json:"to_uid"`
	Message           Message        `json:"message"`
	StartTime         time.Time      `json:"start_time"`
	ShowRating        bool           `json:"show_rating"`
	LocalID           string         `json:"local_id"`
	ClientConnectTime time.Time      `json:"client_connect_time"`
	Source            string         `json:"source"`
}

type RcvEventSocket

type RcvEventSocket struct {
	*EventCode
	Data interface{} `json:"data"`
}

func (*RcvEventSocket) UnmarshalJSON

func (event *RcvEventSocket) UnmarshalJSON(data []byte) error

type ReaduserChat

type ReaduserChat struct {
	MsgID int64 `json:"msg_id"`
}

type ReminderTicker

type ReminderTicker struct {
	Enable       bool   `json:"enable"`
	EnableClose  bool   `json:"enable_close"`
	FeatureID    int    `json:"feature_id"`
	LocalID      string `json:"local_id"`
	MainText     string `json:"main_text"`
	RegexMessage string `json:"regex_message"`
	SubText      string `json:"sub_text"`
	TickerType   string `json:"ticker_type"`
	URL          string `json:"url"`
	URLLabel     string `json:"url_label"`
}

type SendChat

type SendChat struct {
	MessageID    int64     `json:"message_id"`
	Message      string    `json:"message"`
	StartTime    time.Time `json:"start_time"`
	ParentReply  any       `json:"parent_reply"`
	From         string    `json:"from"`
	FromUserName string    `json:"from_user_name"`
	Source       string    `json:"source"`
	LocalID      string    `json:"local_id"`
}

type Session

type Session interface {
	Sync() error
	UserAgent() string
	GetCookies() []*http.Cookie
}

type SocketClient

type SocketClient struct {
	sync.Mutex
	Api     *api.TokopediaApi
	Ctx     context.Context
	Session Session
	Con     *websocket.Conn
}

func NewSocketClient

func NewSocketClient(api *api.TokopediaApi) *SocketClient

func (*SocketClient) Connect

func (socket *SocketClient) Connect(ctx context.Context, eventhandler SocketEventhandler)

func (*SocketClient) EmitEvent

func (socket *SocketClient) EmitEvent(event *EmitEventSocket) error

func (*SocketClient) ListenData

func (socket *SocketClient) ListenData(eventhandler SocketEventhandler)

func (*SocketClient) SendEvent

func (sClient *SocketClient) SendEvent(payload interface{}) error

type SocketEventhandler

type SocketEventhandler func(socket *SocketClient, event *RcvEventSocket) error

Jump to

Keyboard shortcuts

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