activity

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package activity acts as a handler for any received activity and the user defined operation on that activity. It then is responsible for sending a reply to the connector service.

Index

Constants

View Source
const (
	// APIVersion for response URLs
	APIVersion = "v3"
)

Variables

This section is empty.

Functions

func ApplyConversationReference

func ApplyConversationReference(activity schema.Activity, reference schema.ConversationReference, isIncoming bool) schema.Activity

ApplyConversationReference sets delivery information to the activity from conversation reference

func GetCoversationReference

func GetCoversationReference(activity schema.Activity) schema.ConversationReference

GetCoversationReference returns conversation reference from the activity

func PrepareActivityContext

func PrepareActivityContext(handler Handler, context *TurnContext) (schema.Activity, error)

PrepareActivityContext routes the received Activity to respective handler function. Returns the result of the handler function.

Types

type DefaultResponse

type DefaultResponse struct {
	Client client.Client
}

DefaultResponse is the default implementation of Response.

func (*DefaultResponse) DeleteActivity

func (response *DefaultResponse) DeleteActivity(activity schema.Activity) error

DeleteActivity sends a Delete activity method to the BOT connector service.

func (*DefaultResponse) SendActivity

func (response *DefaultResponse) SendActivity(activity schema.Activity) error

SendActivity sends an activity to the BOT connector service.

type Handler

type Handler interface {
	OnMessage(context *TurnContext) (schema.Activity, error)
	OnInvoke(context *TurnContext) (schema.Activity, error)
}

Handler acts as the interface for the client program to define actions on various events from connector service.

type HandlerFuncs

type HandlerFuncs struct {
	OnMessageFunc func(turn *TurnContext) (schema.Activity, error)
	OnInvokeFunc  func(turn *TurnContext) (schema.Activity, error)
}

HandlerFuncs is an adaptor to let client program specify as many or as few functions to handle events of the connector service while still implementing Handler.

func (HandlerFuncs) OnInvoke

func (r HandlerFuncs) OnInvoke(turn *TurnContext) (schema.Activity, error)

OnInvoke handles a 'invoke' event from connector service.

func (HandlerFuncs) OnMessage

func (r HandlerFuncs) OnMessage(turn *TurnContext) (schema.Activity, error)

OnMessage handles a 'message' event from connector service.

type MsgOption

type MsgOption func(*schema.Activity) error

MsgOption option provided when sending an activity.

func MsgOptionAttachments

func MsgOptionAttachments(attachments []schema.Attachment) MsgOption

MsgOptionAttachments adds attachment to the activity.

func MsgOptionText

func MsgOptionText(text string) MsgOption

MsgOptionText adds text to the activity.

type Response

type Response interface {
	SendActivity(activity schema.Activity) error
	DeleteActivity(activity schema.Activity) error
}

Response provides functionalities to send activity to the connector service.

func NewActivityResponse

func NewActivityResponse(connectorClient client.Client) (Response, error)

NewActivityResponse provides a DefaultResponse implementaton of Response.

type TurnContext

type TurnContext struct {
	Activity schema.Activity
}

TurnContext wraps the Activity received and provides operations for the user program of this SDK.

The return value is Activity as provided by the client program, to be send to the connector service.

func (*TurnContext) SendActivity

func (t *TurnContext) SendActivity(options ...MsgOption) (schema.Activity, error)

SendActivity sends an activity to user. TODO: Change comment

Jump to

Keyboard shortcuts

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