line

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

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

Go to latest
Published: Apr 11, 2016 License: MIT Imports: 11 Imported by: 0

README

LINE Bot API in Go

Go binding for LINE Bot API ( https://developers.line.me/bot-api/overview ).

LINE Bot API is a trial phase, so some specification may change.

Installing

go get github.com/stanaka/line-bot-api

An echo bot example

see https://github.com/stanaka/line-bot-api/blob/master/examples/echo.go

License

MIT

Documentation

Index

Constants

View Source
const (
	ContentTypeText int = 1 + iota
	ContentTypeImage
	ContentTypeVideo
	ContentTypeAudio
	ContentTypeUndefined5
	ContentTypeUndefined6
	ContentTypeLocation
	ContentTypeSticker
	ContentTypeUndefined9
	ContentTypeContact
)

ContentType constants

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Logger *log.Logger
	Debug  bool
	// contains filtered or unexported fields
}

API represents LINE BOT API

func New

func New(channelID string, channelSecret string, mid string) *API

New creates an API instance

func (*API) DecodeMessage

func (api *API) DecodeMessage(body io.Reader) (*ReceivedMessage, error)

DecodeMessage decodes body to ReceivedMessage struct.

func (*API) GetUserProfiles

func (api *API) GetUserProfiles(userMIDs []string) (*UserProfiles, error)

GetUserProfiles obtains profiles of users

func (*API) SendMessage

func (api *API) SendMessage(to []string, text string) error

SendMessage sends a text to LINE

func (*API) SetProxy

func (api *API) SetProxy(proxyURL string) error

SetProxy set Proxy from URL string.

type Content

type Content struct {
	ID             string          `json:"id"`
	ContentType    int             `json:"contentType"`
	From           string          `json:"from"`
	CreatedTime    int             `json:"createdTime"`
	To             []string        `json:"to"`
	ToType         int             `json:"toType"`
	ConentMetadata ContentMetadata `json:"contentMetadata"`
	Text           string          `json:"text"`
	Location       Location        `json:"location"`
}

Content is a content of a message

type ContentMetadata

type ContentMetadata struct {
	STKPKGID    string `json:"STKPKGID"`
	STKID       string `json:"STKID"`
	STKVER      string `json:"STKVER"`
	STKTXT      string `json:"STKTXT"`
	Mid         string `json:"mid"`
	DisplayName string `json:"displayName"`
}

ContentMetadata is a metadata of content

type Location

type Location struct {
	Title     string `json:"title"`
	Address   string `json:"address"`
	Latitude  int    `json:"latitude"`
	Longitude int    `json:"Longitude"`
}

Location is a location related data

type ReceivedMessage

type ReceivedMessage struct {
	Results []Result `json:"result"`
}

ReceivedMessage is a body of callback sent by LINE

type Response

type Response struct {
	Failed    []interface{} `json:"failed"`
	MessageID string        `json:"messageId"`
	Timestamp float64       `json:"timestamp"`
	Version   int           `json:"version"`
}

Response is a body returned by LINE

type Result

type Result struct {
	ID          string   `json:"id"`
	From        string   `json:"from"`
	FromChannel int      `json:"fromChannel"`
	To          []string `json:"to"`
	ToChannel   int      `json:"toChannel"`
	EventType   string   `json:"eventType"`
	Content     Content  `json:"content"`
}

Result is a message or a operation.

type SendingMessage

type SendingMessage struct {
	To        []string `json:"to"`
	ToChannel int      `json:"toChannel"`
	EventType string   `json:"eventType"`
	Content   Content  `json:"content"`
}

SendingMessage is a body for Posting API

type UserProfile

type UserProfile struct {
	DisplayName   string `json:"displayName"`
	Mid           string `json:"mid"`
	PictureURL    string `json:"pictureUrl"`
	StatusMessage string `json:"statusMessage"`
}

UserProfile is user's profile

type UserProfiles

type UserProfiles struct {
	Contacts []UserProfile `json:"contacts"`
	Count    int           `json:"count"`
	Total    int           `json:"total"`
	Start    int           `json:"start"`
	Display  int           `json:"display"`
}

UserProfiles is users' profile

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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