Skip to content

Instantly share code, notes, and snippets.

😁
Coding and Writing Posts

Depado

😁
Coding and Writing Posts
Block or report user

Report or block Depado

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View df-main-12.go
func specify(c *gin.Context, dfr *df.Request) {
var err error
var p searchParams
if err = dfr.GetContext("Search-followup", &p); err != nil {
logrus.WithError(err).Error("Couldn't get parameters")
c.AbortWithStatus(http.StatusBadRequest)
return
}
View df-main-11.go
type searchParams struct {
Alcohol string `json:"alcohol"`
DrinkType string `json:"drink-type"`
Name string `json:"name"`
}
func search(c *gin.Context, dfr *df.Request) {
var err error
var p searchParams
View df-main-10.go
out := fmt.Sprintf("I found that cocktail : %s", d.StrDrink)
dff := &df.Fulfillment{
FulfillmentMessages: df.Messages{
{RichMessage: df.Text{Text: []string{out}}},
df.ForGoogle(cardFromDrink(d)),
},
}
c.JSON(http.StatusOK, dff)
View df-main-9.go
func cardFromDrink(d *cocktail.FullDrink) df.BasicCard {
card := df.BasicCard{
Title: d.StrDrink,
FormattedText: d.StrInstructions,
Image: &df.Image{
ImageURI: d.StrDrinkThumb,
},
}
return card
}
View df-main-8.go
// Platform is a simple type intended to be used with responses
type Platform string
// Platform constants, used in the webhook responses
const (
Unspecified Platform = "PLATFORM_UNSPECIFIED"
Facebook Platform = "FACEBOOK"
Slack Platform = "SLACK"
Telegram Platform = "TELEGRAM"
Kik Platform = "KIK"
View df-main-7.go
// Message is a struct holding a platform and a RichMessage.
// Used in the FulfillmentMessages of the response sent back to dialogflow
type Message struct {
Platform
RichMessage RichMessage
}
View 1-main.go
func webhook(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
func main() {
r := gin.Default()
r.POST("/webhook", webhook)
if err := r.Run("127.0.0.1:8001"); err != nil {
panic(err)
}
View df-main-6.go
out := fmt.Sprintf("I found that cocktail : %s", d.StrDrink)
dff := &df.Fulfillment{
FulfillmentMessages: df.Messages{
{RichMessage: df.Text{Text: []string{out}}},
df.ForGoogle(df.SingleSimpleResponse(out, out)),
},
}
c.JSON(http.StatusOK, dff)
View df-main-5.go
func random(c *gin.Context, dfr *df.Request) {
var err error
var d *cocktail.FullDrink
if d, err = cocktail.C.GetRandomDrink(); err != nil {
logrus.WithError(err).Error("Coudln't get random drink")
c.AbortWithStatus(http.StatusInternalServerError)
return
}
fmt.Println(d)
View df-main-4.go
func search(c *gin.Context, dfr *df.Request) {
}
func random(c *gin.Context, dfr *df.Request) {
}
You can’t perform that action at this time.