Documentation
¶
Index ¶
- Constants
- func GetGoogleApiClient(appConfig AppConfig) (*http.Client, error)
- func GetRingCentralApiClient(appConfig AppConfig) (*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)
- type AppConfig
- type GlipPostEventInfo
- type Groupbot
- func (bot *Groupbot) HandleAwsLambda(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func (bot *Groupbot) HandleNetHTTP(res http.ResponseWriter, req *http.Request)
- func (bot *Groupbot) Initialize() (hum.ResponseInfo, error)
- func (bot *Groupbot) ProcessEvent(reqBodyBytes []byte) (*hum.ResponseInfo, error)
- func (bot *Groupbot) SendGlipPost(glipPostEventInfo *GlipPostEventInfo, reqBody rc.GlipCreatePost) (*hum.ResponseInfo, error)
- 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 GetGoogleApiClient ¶ added in v0.1.1
func GetRingCentralApiClient ¶ added in v0.1.1
func GetSheetsMap ¶ added in v0.1.1
func HandleAwsLambda ¶
func HandleAwsLambda(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
func ServeAwsLambda ¶ added in v0.1.1
func ServeAwsLambda(intentRouter IntentRouter)
func ServeNetHttp ¶ added in v0.1.1
func ServeNetHttp(intentRouter IntentRouter)
Types ¶
type AppConfig ¶ added in v0.1.1
type AppConfig struct {
Port int64 `env:"GROUPBOT_PORT"`
GroupbotRequestFuzzyAtMentionMatch bool `env:"GROUPBOT_REQUEST_FUZZY_AT_MENTION_MATCH"`
GroupbotResponseAutoAtMention bool `env:"GROUPBOT_RESPONSE_AUTO_AT_MENTION"`
GroupbotPostSuffix string `env:"GROUPBOT_POST_SUFFIX"`
GroupbotCharQuoteLeft string `env:"GROUPBOT_CHAR_QUOTE_LEFT"`
GroupbotCharQuoteRight string `env:"GROUPBOT_CHAR_QUOTE_RIGHT"`
RingCentralTokenJSON string `env:"RINGCENTRAL_TOKEN_JSON"`
RingCentralServerURL string `env:"RINGCENTRAL_SERVER_URL"`
RingCentralWebhookURL string `env:"RINGCENTRAL_WEBHOOK_URL"`
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"`
}
func (*AppConfig) AppendPostSuffix ¶ added in v0.1.1
type GlipPostEventInfo ¶ added in v0.1.1
type GlipPostEventInfo struct {
PostEvent *rc.GlipPostEvent
GroupMemberCount int64
CreatorInfo *rc.GlipPersonInfo
TryCommandsLc []string
}
type Groupbot ¶ added in v0.1.1
type Groupbot struct {
AppConfig AppConfig
RingCentralClient *rc.APIClient
GoogleClient *http.Client
SheetsMap sheetsmap.SheetsMap
SheetsMapMeta sheetsmap.SheetsMap
IntentRouter IntentRouter
}
func (*Groupbot) HandleAwsLambda ¶ added in v0.1.1
func (bot *Groupbot) HandleAwsLambda(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
func (*Groupbot) HandleNetHTTP ¶ added in v0.1.1
func (bot *Groupbot) HandleNetHTTP(res http.ResponseWriter, req *http.Request)
func (*Groupbot) Initialize ¶ added in v0.1.1
func (bot *Groupbot) Initialize() (hum.ResponseInfo, error)
func (*Groupbot) ProcessEvent ¶ added in v0.1.1
func (bot *Groupbot) ProcessEvent(reqBodyBytes []byte) (*hum.ResponseInfo, error)
func (*Groupbot) SendGlipPost ¶ added in v0.1.1
func (bot *Groupbot) SendGlipPost(glipPostEventInfo *GlipPostEventInfo, reqBody rc.GlipCreatePost) (*hum.ResponseInfo, error)
type Intent ¶ added in v0.1.1
type Intent struct {
Type IntentType
Strings []string
Regexps []*regexp.Regexp
HandleIntent func(bot *Groupbot, glipPostEventInfo *GlipPostEventInfo) (*hum.ResponseInfo, error)
}
type IntentRouter ¶ added in v0.1.1
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 ¶ added in v0.1.1
func NewIntentRouter() IntentRouter
func (*IntentRouter) ProcessRequest ¶ added in v0.1.1
func (ir *IntentRouter) ProcessRequest(bot *Groupbot, glipPostEventInfo *GlipPostEventInfo) (*hum.ResponseInfo, error)
func (*IntentRouter) ProcessRequestSingle ¶ added in v0.1.1
func (ir *IntentRouter) ProcessRequestSingle(bot *Groupbot, textNoBotMention string, glipPostEventInfo *GlipPostEventInfo) (*hum.ResponseInfo, error)
type IntentType ¶ added in v0.1.1
type IntentType int
const ( MatchString IntentType = iota MatchStringLowerCase MatchRegexp MatchAny )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.