linebot

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndPoint          = "https://api.line.me"
	PushMessage       = "/v2/bot/message/push"
	ReplyMessage      = "/v2/bot/message/reply"
	GetMessageContent = "/v2/bot/message/%s/content"
	LeaveGroup        = "/v2/bot/group/%s/leave"
	LeaveRoom         = "/v2/bot/room/%s/leave"
	GetProfile        = "/v2/bot/profile/%s"
)

API URLs

Variables

This section is empty.

Functions

func Middleware

func Middleware(next http.Handler) http.Handler

Middleware ...

Types

type APISendResult

type APISendResult struct {
	Message string `json:"message"`
}

APISendResult ...

type AudioMessage

type AudioMessage struct {
	Type               MessageType `json:"type"`
	OriginalContentURL string      `json:"originalContentUrl"`
	Duration           int         `json:"duration"`
}

AudioMessage ...

func NewAudioMessage

func NewAudioMessage(originalContentURL string, duration int) *AudioMessage

NewAudioMessage ...

type BasicResponse

type BasicResponse struct {
}

BasicResponse ...

type Beacon

type Beacon struct {
	Hwid string `json:"hwid"`
	Type string `json:"type"`
}

Beacon ...

type ButtonsTemplate

type ButtonsTemplate struct {
	Type              TemplateType     `json:"type"`
	ThumbnailImageURL string           `json:"thumbnailImageUrl,omitempty"`
	Title             string           `json:"title,omitempty"`
	Text              string           `json:"text"`
	Actions           []TemplateAction `json:"actions"`
}

ButtonsTemplate ...

func NewButtonsTemplate

func NewButtonsTemplate(thumbnailImageURL, title, text string, actions ...TemplateAction) *ButtonsTemplate

NewButtonsTemplate ...

type CarouselColumn

type CarouselColumn struct {
	ThumbnailImageURL string           `json:"thumbnailImageUrl,omitempty"`
	Title             string           `json:"title,omitempty"`
	Text              string           `json:"text"`
	Actions           []TemplateAction `json:"actions"`
}

CarouselColumn ...

func NewCarouselColumn

func NewCarouselColumn(thumbnailImageURL, title, text string, actions ...TemplateAction) *CarouselColumn

NewCarouselColumn ...

type CarouselTemplate

type CarouselTemplate struct {
	Type    TemplateType      `json:"type"`
	Columns []*CarouselColumn `json:"columns"`
}

CarouselTemplate ...

func NewCarouselTemplate

func NewCarouselTemplate(columns ...*CarouselColumn) *CarouselTemplate

NewCarouselTemplate ...

type Client

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

Client ...

func NewClient

func NewClient(channelAccessToken string) *Client

NewClient ...

func (*Client) GetMessageContent

func (c *Client) GetMessageContent(messageID string) (*MessageContentResponse, error)

GetMessageContent ...

func (*Client) GetProfile

func (c *Client) GetProfile(userID string) (*UserProfileResponse, error)

GetProfile ...

func (*Client) LeaveGroup

func (c *Client) LeaveGroup(groupID string) (*BasicResponse, error)

LeaveGroup ...

func (*Client) LeaveRoom

func (c *Client) LeaveRoom(roomID string) (*BasicResponse, error)

LeaveRoom ...

func (*Client) PushMessage added in v0.0.2

func (c *Client) PushMessage(to string, messages ...Message) (*APISendResult, error)

PushMessage ...

func (*Client) ReplyMessage

func (c *Client) ReplyMessage(replyToken string, messages ...Message) (*APISendResult, error)

ReplyMessage ...

func (*Client) SetChannelSecret

func (c *Client) SetChannelSecret(secret string)

SetChannelSecret ...

func (*Client) SetEventHandler

func (c *Client) SetEventHandler(event EventHandler)

SetEventHandler ...

type ConfirmTemplate

type ConfirmTemplate struct {
	Type    TemplateType     `json:"type"`
	Text    string           `json:"text"`
	Actions []TemplateAction `json:"actions"`
}

ConfirmTemplate ...

func NewConfirmTemplate

func NewConfirmTemplate(text string, actions ...TemplateAction) *ConfirmTemplate

NewConfirmTemplate ...

type Event

type Event struct {
	ReplyToken string      `json:"replyToken"`
	Type       EventType   `json:"type"`
	Timestamp  int64       `json:"timestamp"`
	Source     EventSource `json:"source"`
	Message    struct {
		ID        string      `json:"id"`
		Type      MessageType `json:"type"`
		Text      string      `json:"text"`
		Duration  int         `json:"duration"`
		Title     string      `json:"title"`
		Address   string      `json:"address"`
		Latitude  float64     `json:"latitude"`
		Longitude float64     `json:"longitude"`
		PackageID string      `json:"packageId"`
		StickerID string      `json:"stickerId"`
	} `json:"message"`
	Postback `json:"postback"`
	Beacon   `json:"beacon"`
}

Event ...

type EventHandler

type EventHandler interface {
	OnEvent(event Event)
	OnFollowEvent(source EventSource, replyToken string)
	OnUnFollowEvent(source EventSource)
	OnJoinEvent(source EventSource, replyToken string)
	OnLeaveEvent(source EventSource)
	OnPostbackEvent(source EventSource, replyToken, postbackData string)
	OnBeaconEvent(source EventSource, replyToken, beaconHwid string, beaconType string)
	OnTextMessage(source EventSource, replyToken, text string)
	OnImageMessage(source EventSource, replyToken, id string)
	OnVideoMessage(source EventSource, replyToken, id string)
	OnAudioMessage(source EventSource, replyToken, id string)
	OnLocationMessage(source EventSource, replyToken string, title, address string, latitude, longitude float64)
	OnStickerMessage(source EventSource, replyToken, packageID, stickerID string)
}

EventHandler ...

type EventSource

type EventSource struct {
	Type    EventSourceType `json:"type"`
	UserID  string          `json:"userId"`
	GroupID string          `json:"groupId"`
	RoomID  string          `json:"roomId"`
}

EventSource ...

type EventSourceType

type EventSourceType string

EventSourceType ...

const (
	EventSourceTypeUser  EventSourceType = "user"
	EventSourceTypeGroup EventSourceType = "group"
	EventSourceTypeRoom  EventSourceType = "room"
)

EventSourceType ....

type EventType

type EventType string

EventType ...

const (
	EventTypeMessage  EventType = "message"
	EventTypeFollow   EventType = "follow"
	EventTypeUnfollow EventType = "unfollow"
	EventTypeJoin     EventType = "join"
	EventTypeLeave    EventType = "leave"
	EventTypePostback EventType = "postback"
	EventTypeBeacon   EventType = "beacon"
)

EentTypes

type ImageMessage

type ImageMessage struct {
	Type               MessageType `json:"type"`
	OriginalContentURL string      `json:"originalContentUrl"`
	PreviewImageURL    string      `json:"previewImageUrl"`
}

ImageMessage ...

func NewImageMessage

func NewImageMessage(originalContentURL, previewImageURL string) *ImageMessage

NewImageMessage ...

type ImagemapAction

type ImagemapAction interface {
	// contains filtered or unexported methods
}

ImagemapAction ...

type ImagemapActionType

type ImagemapActionType string

ImagemapActionType ...

const (
	ImagemapActionTypeURI     ImagemapActionType = "uri"
	ImagemapActionTypeMessage ImagemapActionType = "message"
)

ImagemapActionType ...

type ImagemapArea

type ImagemapArea struct {
	X      int `json:"x"`
	Y      int `json:"y"`
	Width  int `json:"width"`
	Height int `json:"height"`
}

ImagemapArea ...

func NewImagemapArea

func NewImagemapArea(x, y, width, height int) *ImagemapArea

NewImagemapArea ...

type ImagemapBaseSize

type ImagemapBaseSize struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

ImagemapBaseSize ...

type ImagemapMessage

type ImagemapMessage struct {
	Type     MessageType      `json:"type"`
	BaseURL  string           `json:"baseUrl"`
	AltText  string           `json:"altText"`
	BaseSize ImagemapBaseSize `json:"baseSize"`
	Actions  []ImagemapAction `json:"actions"`
}

ImagemapMessage ...

func NewImagemapMessage

func NewImagemapMessage(baseURL, altText string, baseSizeWidth, baseSizeHeght int, actions ...ImagemapAction) *ImagemapMessage

NewImagemapMessage ...

type ImagemapMessageAction

type ImagemapMessageAction struct {
	Type ImagemapActionType `json:"type"`
	Text string             `json:"text"`
	Area ImagemapArea       `json:"area"`
}

ImagemapMessageAction ...

func NewImagemapMessageAction

func NewImagemapMessageAction(text string, area ImagemapArea) *ImagemapMessageAction

NewImagemapMessageAction ...

type ImagemapURIAction

type ImagemapURIAction struct {
	Type    ImagemapActionType `json:"type"`
	LinkURI string             `json:"linkUri"`
	Area    ImagemapArea       `json:"area"`
}

ImagemapURIAction ...

func NewImagemapURIAction

func NewImagemapURIAction(linkURI string, area ImagemapArea) *ImagemapURIAction

NewImagemapURIAction ...

type LocationMessage

type LocationMessage struct {
	Type      MessageType `json:"type"`
	Title     string      `json:"title"`
	Address   string      `json:"address"`
	Latitude  float64     `json:"latitude"`
	Longitude float64     `json:"longitude"`
}

LocationMessage ...

func NewLocationMessage

func NewLocationMessage(title, address string, latitude, longitude float64) *LocationMessage

NewLocationMessage ...

type Message

type Message interface {
	// contains filtered or unexported methods
}

Message ...

type MessageContentResponse

type MessageContentResponse struct {
	Content       []byte
	ContentLength int64
	ContentType   string
}

MessageContentResponse ...

type MessageType

type MessageType string

MessageType ...

const (
	MessageTypeText     MessageType = "text"
	MessageTypeImage    MessageType = "image"
	MessageTypeVideo    MessageType = "video"
	MessageTypeAudio    MessageType = "audio"
	MessageTypeLocation MessageType = "location"
	MessageTypeSticker  MessageType = "sticker"
	MessageTypeTemplate MessageType = "template"
	MessageTypeImagemap MessageType = "imagemap"
)

MessageType ...

type Postback

type Postback struct {
	Data string `json:"data"`
}

Postback ...

type StickerMessage

type StickerMessage struct {
	Type      MessageType `json:"type"`
	PackageID string      `json:"packageId"`
	StickerID string      `json:"stickerId"`
}

StickerMessage ...

func NewStickerMessage

func NewStickerMessage(packageID, stickerID string) *StickerMessage

NewStickerMessage ...

type Template

type Template interface {
	// contains filtered or unexported methods
}

Template ...

type TemplateAction

type TemplateAction interface {
	// contains filtered or unexported methods
}

TemplateAction ...

type TemplateActionType

type TemplateActionType string

TemplateActionType ...

const (
	TemplateActionTypeURI      TemplateActionType = "uri"
	TemplateActionTypeMessage  TemplateActionType = "message"
	TemplateActionTypePostback TemplateActionType = "postback"
)

TemplateActionType ...

type TemplateMessage

type TemplateMessage struct {
	Type     MessageType `json:"type"`
	AltText  string      `json:"altText"`
	Template Template    `json:"template"`
}

TemplateMessage ...

func NewTemplateMessage

func NewTemplateMessage(altText string, template Template) *TemplateMessage

NewTemplateMessage ...

type TemplateMessageAction

type TemplateMessageAction struct {
	Type  TemplateActionType `json:"type"`
	Label string             `json:"label"`
	Text  string             `json:"text"`
}

TemplateMessageAction ...

func NewTemplateMessageAction

func NewTemplateMessageAction(label, text string) *TemplateMessageAction

NewTemplateMessageAction ...

type TemplatePostbackAction

type TemplatePostbackAction struct {
	Type  TemplateActionType `json:"type"`
	Label string             `json:"label"`
	Data  string             `json:"data"`
	Text  string             `json:"text,omitempty"`
}

TemplatePostbackAction ...

func NewTemplatePostbackAction

func NewTemplatePostbackAction(label, data, text string) *TemplatePostbackAction

NewTemplatePostbackAction ...

type TemplateType

type TemplateType string

TemplateType ...

const (
	TemplateTypeButtons  TemplateType = "buttons"
	TemplateTypeConfirm  TemplateType = "confirm"
	TemplateTypeCarousel TemplateType = "carousel"
)

TemplateType ...

type TemplateURIAction

type TemplateURIAction struct {
	Type  TemplateActionType `json:"type"`
	Label string             `json:"label"`
	URI   string             `json:"uri"`
}

TemplateURIAction ...

func NewTemplateURIAction

func NewTemplateURIAction(label, uri string) *TemplateURIAction

NewTemplateURIAction ...

type TextMessage

type TextMessage struct {
	Type MessageType `json:"type"`
	Text string      `json:"text"`
}

TextMessage ...

func NewTextMessage

func NewTextMessage(text string) *TextMessage

NewTextMessage ...

type UserProfileResponse

type UserProfileResponse struct {
	UserID        string `json:"userId"`
	DisplayName   string `json:"displayName"`
	PictureURL    string `json:"pictureUrl"`
	StatusMessage string `json:"statusMessage"`
}

UserProfileResponse ...

type VideoMessage

type VideoMessage struct {
	Type               MessageType `json:"type"`
	OriginalContentURL string      `json:"originalContentUrl"`
	PreviewImageURL    string      `json:"previewImageUrl"`
}

VideoMessage ...

func NewVideoMessage

func NewVideoMessage(originalContentURL, previewImageURL string) *VideoMessage

NewVideoMessage ...

type Webhook

type Webhook struct {
	Events []Event `json:"events"`
}

Webhook ...

Jump to

Keyboard shortcuts

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