gcpine

package
v0.0.0-...-d59dbdd Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	EnvKeyChannelSecret      = "CHANNEL_SECRET"
	EnvKeyChannelAccessToken = "CHANNEL_ACCESS_TOKEN"
)

environment variable key

Variables

View Source
var (
	// ErrEmptyMessages - []linebot.SendingMessage is empty
	ErrEmptyMessages = xerrors.Errorf("no message to send")
	// ErrNoSetFunction - function to be executed individually is not set
	ErrNoSetFunction = xerrors.Errorf("no set function")
	// ErrInvalidMessageType - invalid message type
	ErrInvalidMessageType = xerrors.Errorf("invalid message type")
)

Functions

func ParseEvents

func ParseEvents(data []byte) ([]*linebot.Event, error)

ParseEvents - extract `[]*linebot.Event`

func ValidateSignature

func ValidateSignature(secret, signature string, body []byte) bool

ValidateSignature - perform signature verification

Types

type AppEngineProps

type AppEngineProps interface {
	SetService(service string)
	ParentEvent(ctx context.Context, body []byte) error
	ChildEvent(ctx context.Context, body []byte) error
	Props
}

AppEngineProps - props for App Engine.

func NewAppEngineProps

func NewAppEngineProps(client *cloudtasks.Client, queuePath, relativeURI string) AppEngineProps

NewAppEngineProps - constructor

type CloudFunctionsProps

type CloudFunctionsProps interface {
	ParentEvent(ctx context.Context, message *pubsub.Message) error
	ChildEvent(ctx context.Context, message *pubsub.Message) error
	Props
}

CloudFunctionsProps - props for Cloud Functions.

func NewCloudFunctionsProps

func NewCloudFunctionsProps(parent, child *pubsub.Topic) CloudFunctionsProps

NewCloudFunctionsProps - constructor

type EventType

type EventType = string

EventType - Event type Name

const (
	EventTypeTextMessage     EventType = "TextMessage"
	EventTypeImageMessage    EventType = "ImageMessage"
	EventTypeVideoMessage    EventType = "VideoMessage"
	EventTypeAudioMessage    EventType = "AudioMessage"
	EventTypeFileMessage     EventType = "FileMessage"
	EventTypeLocationMessage EventType = "LocationMessage"
	EventTypeStickerMessage  EventType = "StickerMessage"

	EventTypeFollowEvent       EventType = "follow"
	EventTypeUnfollowEvent     EventType = "unfollow"
	EventTypeJoinEvent         EventType = "join"
	EventTypeLeaveEvent        EventType = "leave"
	EventTypeMemberJoinedEvent EventType = "memberJoined"
	EventTypeMemberLeftEvent   EventType = "memberLeft"
	EventTypePostBackEvent     EventType = "postback"
	EventTypeBeaconEvent       EventType = "beacon"
	EventTypeAccountLinkEvent  EventType = "accountLink"
	EventTypeThingsEvent       EventType = "things"
	EventTypeUnsend            EventType = "unsend"
	EventTypeVideoPlayComplete EventType = "videoPlayComplete"
)

event Name

type GCPine

type GCPine struct {
	ErrMessages []linebot.SendingMessage
	Function    map[EventType]PineFunction
	LiffFunc    map[string]PineLiffFunc
	*linebot.Client
}

GCPine - Toolkit of the LINE Bot to work for Google Cloud Platform.

func (*GCPine) Execute

func (g *GCPine) Execute(ctx context.Context, event *linebot.Event) (err error)

Execute - separate execute for each event

func (*GCPine) SendPushMessage

func (g *GCPine) SendPushMessage(uid string, messages []linebot.SendingMessage) error

SendPushMessage - send push message

func (*GCPine) SendReplyMessage

func (g *GCPine) SendReplyMessage(token string, messages []linebot.SendingMessage) error

SendReplyMessage - send reply message

type PineFunction

type PineFunction func(ctx context.Context, pine *GCPine, event *linebot.Event) ([]linebot.SendingMessage, error)

PineFunction - Event function for reply

type PineLiffFunc

type PineLiffFunc func(r *http.Request, w http.ResponseWriter)

PineLiffFunc - Functions for LIFF(TODO function)

type Props

type Props interface {
	SetGCPine(pine *GCPine)
	SetSecret(secret string)
	ReceiveWebHook(r *http.Request, w http.ResponseWriter) error
}

Props - props for common.

Jump to

Keyboard shortcuts

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