linebot

package
v0.0.0-...-e739775 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIEndpointBase = "https://api.line.me"

	APIEndpointPushMessage       = "/v2/bot/message/push"
	APIEndpointReplyMessage      = "/v2/bot/message/reply"
	APIEndpointGetMessageContent = "/v2/bot/message/%s/content"
	APIEndpointLeaveGroup        = "/v2/bot/group/%s/leave"
	APIEndpointLeaveRoom         = "/v2/bot/room/%s/leave"
	APIEndpointGetProfile        = "/v2/bot/profile/%s"
)

APIEndpoint constants

Variables

View Source
var (
	ErrInvalidSignature = errors.New("invalid signature")
)

errors

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code     int
	Response *ErrorResponse
}

APIError type

func (*APIError) Error

func (e *APIError) Error() string

Error method

type AudioMessage

type AudioMessage struct {
	ID                 string
	OriginalContentURL string
	Duration           int
}

AudioMessage type

func NewAudioMessage

func NewAudioMessage(originalContentURL string, duration int) *AudioMessage

NewAudioMessage function

func (*AudioMessage) MarshalJSON

func (m *AudioMessage) MarshalJSON() ([]byte, error)

MarshalJSON method of AudioMessage

type BasicResponse

type BasicResponse struct {
}

BasicResponse type

type Beacon

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

Beacon type

type BeaconEventType

type BeaconEventType string

BeaconEventType type

const (
	BeaconEventTypeEnter BeaconEventType = "enter"
)

BeaconEventType constants

type ButtonsTemplate

type ButtonsTemplate struct {
	ThumbnailImageURL string
	Title             string
	Text              string
	Actions           []TemplateAction
}

ButtonsTemplate type

func NewButtonsTemplate

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

NewButtonsTemplate function `thumbnailImageURL` and `title` are optional. they can be empty.

func (*ButtonsTemplate) MarshalJSON

func (t *ButtonsTemplate) MarshalJSON() ([]byte, error)

MarshalJSON method of ButtonsTemplate

type CarouselColumn

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

CarouselColumn type

func NewCarouselColumn

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

NewCarouselColumn function `thumbnailImageURL` and `title` are optional. they can be empty.

type CarouselTemplate

type CarouselTemplate struct {
	Columns []*CarouselColumn
}

CarouselTemplate type

func NewCarouselTemplate

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

NewCarouselTemplate function

func (*CarouselTemplate) MarshalJSON

func (t *CarouselTemplate) MarshalJSON() ([]byte, error)

MarshalJSON method of CarouselTemplate

type Client

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

Client type

func New

func New(channelSecret, channelToken string, options ...ClientOption) (*Client, error)

New returns a new bot client instance.

func (*Client) GetMessageContent

func (client *Client) GetMessageContent(messageID string) *GetMessageContentCall

GetMessageContent method

func (*Client) GetProfile

func (client *Client) GetProfile(userID string) *GetProfileCall

GetProfile method

func (*Client) LeaveGroup

func (client *Client) LeaveGroup(groupID string) *LeaveGroupCall

LeaveGroup method

func (*Client) LeaveRoom

func (client *Client) LeaveRoom(roomID string) *LeaveRoomCall

LeaveRoom method

func (*Client) ParseRequest

func (client *Client) ParseRequest(r *http.Request) ([]*Event, error)

ParseRequest method

func (*Client) PushMessage

func (client *Client) PushMessage(to string, messages ...Message) *PushMessageCall

PushMessage method

func (*Client) ReplyMessage

func (client *Client) ReplyMessage(replyToken string, messages ...Message) *ReplyMessageCall

ReplyMessage method

type ClientOption

type ClientOption func(*Client) error

ClientOption type

func WithEndpointBase

func WithEndpointBase(endpointBase string) ClientOption

WithEndpointBase function

func WithHTTPClient

func WithHTTPClient(c *http.Client) ClientOption

WithHTTPClient function

type ConfirmTemplate

type ConfirmTemplate struct {
	Text    string
	Actions []TemplateAction
}

ConfirmTemplate type

func NewConfirmTemplate

func NewConfirmTemplate(text string, left, right TemplateAction) *ConfirmTemplate

NewConfirmTemplate function

func (*ConfirmTemplate) MarshalJSON

func (t *ConfirmTemplate) MarshalJSON() ([]byte, error)

MarshalJSON method of ConfirmTemplate

type ErrorResponse

type ErrorResponse struct {
	Message string                `json:"message"`
	Details []errorResponseDetail `json:"details"`
}

ErrorResponse type

type Event

type Event struct {
	ReplyToken string
	Type       EventType
	Timestamp  time.Time
	Source     *EventSource
	Message    Message
	Postback   *Postback
	Beacon     *Beacon
}

Event type

func ParseRequest

func ParseRequest(channelSecret string, r *http.Request) ([]*Event, error)

ParseRequest func

func (*Event) MarshalJSON

func (e *Event) MarshalJSON() ([]byte, error)

MarshalJSON method of Event

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(body []byte) (err error)

UnmarshalJSON method of Event

type EventSource

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

EventSource type

type EventSourceType

type EventSourceType string

EventSourceType type

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

EventSourceType constants

type EventType

type EventType string

EventType type

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

EventType constants

type GetMessageContentCall

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

GetMessageContentCall type

func (*GetMessageContentCall) Do

Do method

func (*GetMessageContentCall) WithContext

WithContext method

type GetProfileCall

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

GetProfileCall type

func (*GetProfileCall) Do

func (call *GetProfileCall) Do() (*UserProfileResponse, error)

Do method

func (*GetProfileCall) WithContext

func (call *GetProfileCall) WithContext(ctx context.Context) *GetProfileCall

WithContext method

type ImageMessage

type ImageMessage struct {
	ID                 string
	OriginalContentURL string
	PreviewImageURL    string
}

ImageMessage type

func NewImageMessage

func NewImageMessage(originalContentURL, previewImageURL string) *ImageMessage

NewImageMessage function

func (*ImageMessage) MarshalJSON

func (m *ImageMessage) MarshalJSON() ([]byte, error)

MarshalJSON method of ImageMessage

type ImagemapAction

type ImagemapAction interface {
	json.Marshaler
	// contains filtered or unexported methods
}

ImagemapAction type

type ImagemapActionType

type ImagemapActionType string

ImagemapActionType type

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

ImagemapActionType constants

type ImagemapArea

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

ImagemapArea type

type ImagemapBaseSize

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

ImagemapBaseSize type

type ImagemapMessage

type ImagemapMessage struct {
	BaseURL  string
	AltText  string
	BaseSize ImagemapBaseSize
	Actions  []ImagemapAction
}

ImagemapMessage type

func NewImagemapMessage

func NewImagemapMessage(baseURL, altText string, baseSize ImagemapBaseSize, actions ...ImagemapAction) *ImagemapMessage

NewImagemapMessage function

func (*ImagemapMessage) MarshalJSON

func (m *ImagemapMessage) MarshalJSON() ([]byte, error)

MarshalJSON method of ImagemapMessage

type LeaveGroupCall

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

LeaveGroupCall type

func (*LeaveGroupCall) Do

func (call *LeaveGroupCall) Do() (*BasicResponse, error)

Do method

func (*LeaveGroupCall) WithContext

func (call *LeaveGroupCall) WithContext(ctx context.Context) *LeaveGroupCall

WithContext method

type LeaveRoomCall

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

LeaveRoomCall type

func (*LeaveRoomCall) Do

func (call *LeaveRoomCall) Do() (*BasicResponse, error)

Do method

func (*LeaveRoomCall) WithContext

func (call *LeaveRoomCall) WithContext(ctx context.Context) *LeaveRoomCall

WithContext method

type LocationMessage

type LocationMessage struct {
	ID        string
	Title     string
	Address   string
	Latitude  float64
	Longitude float64
}

LocationMessage type

func NewLocationMessage

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

NewLocationMessage function

func (*LocationMessage) MarshalJSON

func (m *LocationMessage) MarshalJSON() ([]byte, error)

MarshalJSON method of LocationMessage

type Message

type Message interface {
	json.Marshaler
	// contains filtered or unexported methods
}

Message inteface

type MessageContentResponse

type MessageContentResponse struct {
	Content       io.ReadCloser
	ContentLength int64
	ContentType   string
}

MessageContentResponse type

type MessageImagemapAction

type MessageImagemapAction struct {
	Text string
	Area ImagemapArea
}

MessageImagemapAction type

func NewMessageImagemapAction

func NewMessageImagemapAction(text string, area ImagemapArea) *MessageImagemapAction

NewMessageImagemapAction function

func (*MessageImagemapAction) MarshalJSON

func (a *MessageImagemapAction) MarshalJSON() ([]byte, error)

MarshalJSON method of MessageImagemapAction

type MessageTemplateAction

type MessageTemplateAction struct {
	Label string
	Text  string
}

MessageTemplateAction type

func NewMessageTemplateAction

func NewMessageTemplateAction(label, text string) *MessageTemplateAction

NewMessageTemplateAction function

func (*MessageTemplateAction) MarshalJSON

func (a *MessageTemplateAction) MarshalJSON() ([]byte, error)

MarshalJSON method of MessageTemplateAction

type MessageType

type MessageType string

MessageType type

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 constants

type Postback

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

Postback type

type PostbackTemplateAction

type PostbackTemplateAction struct {
	Label string
	Data  string
	Text  string
}

PostbackTemplateAction type

func NewPostbackTemplateAction

func NewPostbackTemplateAction(label, data, text string) *PostbackTemplateAction

NewPostbackTemplateAction function

func (*PostbackTemplateAction) MarshalJSON

func (a *PostbackTemplateAction) MarshalJSON() ([]byte, error)

MarshalJSON method of PostbackTemplateAction

type PushMessageCall

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

PushMessageCall type

func (*PushMessageCall) Do

func (call *PushMessageCall) Do() (*BasicResponse, error)

Do method

func (*PushMessageCall) WithContext

func (call *PushMessageCall) WithContext(ctx context.Context) *PushMessageCall

WithContext method

type ReplyMessageCall

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

ReplyMessageCall type

func (*ReplyMessageCall) Do

func (call *ReplyMessageCall) Do() (*BasicResponse, error)

Do method

func (*ReplyMessageCall) WithContext

func (call *ReplyMessageCall) WithContext(ctx context.Context) *ReplyMessageCall

WithContext method

type StickerMessage

type StickerMessage struct {
	ID        string
	PackageID string
	StickerID string
}

StickerMessage type

func NewStickerMessage

func NewStickerMessage(packageID, stickerID string) *StickerMessage

NewStickerMessage function

func (*StickerMessage) MarshalJSON

func (m *StickerMessage) MarshalJSON() ([]byte, error)

MarshalJSON method of StickerMessage

type Template

type Template interface {
	json.Marshaler
	// contains filtered or unexported methods
}

Template interface

type TemplateAction

type TemplateAction interface {
	json.Marshaler
	// contains filtered or unexported methods
}

TemplateAction interface

type TemplateActionType

type TemplateActionType string

TemplateActionType type

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

TemplateActionType constants

type TemplateMessage

type TemplateMessage struct {
	AltText  string
	Template Template
}

TemplateMessage type

func NewTemplateMessage

func NewTemplateMessage(altText string, template Template) *TemplateMessage

NewTemplateMessage function

func (*TemplateMessage) MarshalJSON

func (m *TemplateMessage) MarshalJSON() ([]byte, error)

MarshalJSON method of TemplateMessage

type TemplateType

type TemplateType string

TemplateType type

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

TemplateType constants

type TextMessage

type TextMessage struct {
	ID   string
	Text string
}

TextMessage type

func NewTextMessage

func NewTextMessage(content string) *TextMessage

NewTextMessage function

func (*TextMessage) MarshalJSON

func (m *TextMessage) MarshalJSON() ([]byte, error)

MarshalJSON method of TextMessage

type URIImagemapAction

type URIImagemapAction struct {
	LinkURL string
	Area    ImagemapArea
}

URIImagemapAction type

func NewURIImagemapAction

func NewURIImagemapAction(linkURL string, area ImagemapArea) *URIImagemapAction

NewURIImagemapAction function

func (*URIImagemapAction) MarshalJSON

func (a *URIImagemapAction) MarshalJSON() ([]byte, error)

MarshalJSON method of URIImagemapAction

type URITemplateAction

type URITemplateAction struct {
	Label string
	URI   string
}

URITemplateAction type

func NewURITemplateAction

func NewURITemplateAction(label, uri string) *URITemplateAction

NewURITemplateAction function

func (*URITemplateAction) MarshalJSON

func (a *URITemplateAction) MarshalJSON() ([]byte, error)

MarshalJSON method of URITemplateAction

type UserProfileResponse

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

UserProfileResponse type

type VideoMessage

type VideoMessage struct {
	ID                 string
	OriginalContentURL string
	PreviewImageURL    string
}

VideoMessage type

func NewVideoMessage

func NewVideoMessage(originalContentURL, previewImageURL string) *VideoMessage

NewVideoMessage function

func (*VideoMessage) MarshalJSON

func (m *VideoMessage) MarshalJSON() ([]byte, error)

MarshalJSON method of VideoMessage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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