Documentation
¶
Index ¶
- Constants
- func GetAlgoliaAPIClient(botConfig BotConfig) (*algoliasearch.Client, error)
- func GetGoogleAPIClient(botConfig BotConfig) (*http.Client, error)
- func GetRingCentralAPIClient(botConfig BotConfig) (*rc.APIClient, error)
- func GetSheetsMap(googClient *http.Client, spreadsheetID string, sheetTitle string) (sheetsmap.SheetsMap, error)
- func HandleAWSLambda(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func ServeAWSLambda(intentRouter IntentRouter)
- func ServeNetHTTP(intentRouter IntentRouter, mux *http.ServeMux)
- type Bot
- func (bot *Bot) HandleAwsLambda(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func (bot *Bot) HandleNetHTTP(res http.ResponseWriter, req *http.Request)
- func (bot *Bot) Initialize() (hum.ResponseInfo, error)
- func (bot *Bot) ProcessEvent(reqBodyBytes []byte) (*hum.ResponseInfo, error)
- func (bot *Bot) SendGlipPost(glipPostEventInfo *GlipPostEventInfo, reqBody rc.GlipCreatePost) (*hum.ResponseInfo, error)
- type BotConfig
- type GlipPostEventInfo
- type Intent
- type IntentRouter
- type IntentType
Constants ¶
View Source
const ( CharQuoteLeft = "“" CharQuoteRight = "”" )
View Source
const ValidationTokenHeader = "Validation-Token"
Variables ¶
This section is empty.
Functions ¶
func GetAlgoliaAPIClient ¶ added in v0.2.0
func GetAlgoliaAPIClient(botConfig BotConfig) (*algoliasearch.Client, error)
func GetGoogleAPIClient ¶ added in v0.2.2
func GetRingCentralAPIClient ¶ added in v0.2.0
func GetSheetsMap ¶
func HandleAWSLambda ¶ added in v0.2.2
func HandleAWSLambda(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
func ServeAWSLambda ¶ added in v0.2.2
func ServeAWSLambda(intentRouter IntentRouter)
func ServeNetHTTP ¶ added in v0.2.2
func ServeNetHTTP(intentRouter IntentRouter, mux *http.ServeMux)
Types ¶
type Bot ¶
type Bot struct { BotConfig BotConfig IntentRouter IntentRouter RingCentralClient *rc.APIClient GoogleClient *http.Client SheetsMap sheetsmap.SheetsMap SheetsMapMeta sheetsmap.SheetsMap }
func (*Bot) HandleAwsLambda ¶
func (bot *Bot) HandleAwsLambda(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
func (*Bot) HandleNetHTTP ¶
func (bot *Bot) HandleNetHTTP(res http.ResponseWriter, req *http.Request)
func (*Bot) Initialize ¶
func (bot *Bot) Initialize() (hum.ResponseInfo, error)
func (*Bot) ProcessEvent ¶
func (bot *Bot) ProcessEvent(reqBodyBytes []byte) (*hum.ResponseInfo, error)
func (*Bot) SendGlipPost ¶
func (bot *Bot) SendGlipPost(glipPostEventInfo *GlipPostEventInfo, reqBody rc.GlipCreatePost) (*hum.ResponseInfo, error)
func (bot *Bot) SendGlipPosts(glipPostEventInfo *GlipPostEventInfo, reqBodies []rc.GlipCreatePost) (*hum.ResponseInfo, error) { res := &hum.ResponseInfo{} var err error for _, reqBody := range reqBodies { res, err = bot.SendGlipPost(GlipPostEventInfo, reqBody) if err != nil { return res, err } } return res, err }
type BotConfig ¶
type BotConfig struct { Port int64 `env:"PORT"` BotbloxRequestFuzzyAtMentionMatch bool `env:"CHATBLOX_REQUEST_FUZZY_AT_MENTION_MATCH"` BotbloxResponseAutoAtMention bool `env:"CHATBLOX_RESPONSE_AUTO_AT_MENTION"` BotbloxPostSuffix string `env:"CHATBLOX_POST_SUFFIX"` BotbloxCharQuoteLeft string `env:"CHATBLOX_CHAR_QUOTE_LEFT"` BotbloxCharQuoteRight string `env:"CHATBLOX_CHAR_QUOTE_RIGHT"` RingCentralToken string `env:"RINGCENTRAL_TOKEN"` RingCentralTokenJSON string `env:"RINGCENTRAL_TOKEN_JSON"` RingCentralServerURL string `env:"RINGCENTRAL_SERVER_URL"` RingCentralWebhookDefinitionJSON string `env:"RINGCENTRAL_WEBHOOK_DEFINITION_JSON"` RingCentralBotID string `env:"RINGCENTRAL_BOT_ID"` RingCentralBotName string `env:"RINGCENTRAL_BOT_NAME"` GoogleSvcAccountJWT string `env:"GOOGLE_SERVICE_ACCOUNT_JWT"` GoogleSpreadsheetID string `env:"GOOGLE_SPREADSHEET_ID"` GoogleSheetTitleRecords string `env:"GOOGLE_SHEET_TITLE_RECORDS"` GoogleSheetTitleMetadata string `env:"GOOGLE_SHEET_TITLE_METADATA"` AlgoliaAppCredentialsJSON string `env:"ALGOLIA_APP_CREDENTIALS_JSON"` AlgoliaIndex string `env:"ALGOLIA_INDEX"` }
func (*BotConfig) AppendPostSuffix ¶
type GlipPostEventInfo ¶
type GlipPostEventInfo struct { PostEvent *rc.GlipPostEvent GroupMemberCount int64 CreatorInfo *rc.GlipPersonInfo TryCommandsLc []string }
type Intent ¶
type Intent struct { Type IntentType Strings []string Regexps []*regexp.Regexp HandleIntent func(bot *Bot, matchResults map[string]string, glipPostEventInfo *GlipPostEventInfo) (*hum.ResponseInfo, error) }
type IntentRouter ¶
type IntentRouter struct {
Intents []Intent
}
type EventResponse struct { StatusCode int `json:"statusCode,omitempty"` Headers map[string]string `json:"headers,omitempty"` Message string `json:"message,omitempty"` }
func (er *EventResponse) ToJson() []byte { if len(er.Message) == 0 { er.Message = "" } msgJson, err := json.Marshal(er) if err != nil { return []byte(`{"statusCode":500,"message":"Cannot Marshal to JSON"}`) } return msgJson }
func NewIntentRouter ¶
func NewIntentRouter() IntentRouter
func (*IntentRouter) ProcessRequest ¶
func (ir *IntentRouter) ProcessRequest(bot *Bot, glipPostEventInfo *GlipPostEventInfo) (*hum.ResponseInfo, error)
func (*IntentRouter) ProcessRequestSingle ¶
func (ir *IntentRouter) ProcessRequestSingle(bot *Bot, textNoBotMention string, glipPostEventInfo *GlipPostEventInfo) (*hum.ResponseInfo, error)
type IntentType ¶
type IntentType int
const ( MatchString IntentType = iota MatchStringLowerCase MatchRegexp MatchRegexpCapture MatchAny )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.