예제 #1
0
func getCommands(times []string) *[]s.OutCommand {
	result := []s.OutCommand{}
	result = append(result, s.OutCommand{
		Title:"Записаться на квест в НОВАТе",
		Action:"enroll",
		Position:0,
		Form: &s.OutForm{
			Title: "Форма записи на квест",
			Type:  "form",
			Name:  "enroll_form",
			Text:  "?(name) ?(sername) ?(birthday) ?(quest_date)",
			Fields: []s.OutField{
				s.OutField{
					Name: "name",
					Type: "text",
					Attributes: s.FieldAttribute{
						Label:    "Имя",
						Required: true,
					},
				},
				s.OutField{
					Name: "sername",
					Type: "text",
					Attributes: s.FieldAttribute{
						Label:    "Фамилия",
						Required: true,
					},
				},
				s.OutField{
					Name: "birthday",
					Type: "text",
					Attributes: s.FieldAttribute{
						Label:    "Дата рождения",
						Required: true,
					},
				},
				s.OutField{
					Name: "quest_date",
					Type: "single_list",
					Attributes: s.FieldAttribute{
						Label:    "Дата квеста",
						Required: true,
					},
					Items:s.FormItems(times),
				},
			},
		},
	})

	return &result
}
예제 #2
0
func getCommands(coffeeHouseConfig *CoffeeHouseConfiguration, isFirst, isActive bool) *[]s.OutCommand {
	drinkString, drinkFields := getCommandsTextAndFieldForDrink(coffeeHouseConfig)
	commands := []s.OutCommand{
		s.OutCommand{
			Title:    "Напитки",
			Action:   "order_drink",
			Position: 0,
			Repeated: true,
			Form: &s.OutForm{
				Title:  "Заказ напитка",
				Type:   "form",
				Name:   "order_drink_form",
				Text:   drinkString,
				Fields: drinkFields,
			},
		},
		s.OutCommand{
			Title:    "Выпечка",
			Action:   "order_bake",
			Position: 1,
			Form: &s.OutForm{
				Title: "Заказ выпечки",
				Type:  "form",
				Name:  "order_bake_form",
				Text:  "Ваш заказ: ?(bake), ?(count) ?(to_time)",
				Fields: []s.OutField{
					s.OutField{
						Name: "bake",
						Type: "list-single",
						Attributes: s.FieldAttribute{
							Label:    "выпечка",
							Required: true,
						},
						Items: s.FormItemsFromSortedWithPrice(coffeeHouseConfig.Bakes),
					},
					s.OutField{
						Name: "count",
						Type: "list-single",
						Attributes: s.FieldAttribute{
							Label:     "количество",
							Required:  false,
							EmptyText: &ONE,
						},
						Items: s.FormItems([]string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}),
					},
					s.OutField{
						Name: "to_time",
						Type: "list-single",
						Attributes: s.FieldAttribute{
							Label:     "когда",
							Required:  false,
							EmptyText: &NOW,
						},
						Items: s.FormItems([]string{"через 10 минут", "через 20 минут", "через 30 минут"}),
					},
				},
			},
		},
	}
	position := 1
	if !isFirst {
		position += 1
		commands = append(commands,
			s.OutCommand{
				Title:    "Повторить предыдущий заказ",
				Action:   "repeat",
				Position: position,
			},
		)
	}
	if isActive {
		position += 1
		commands = append(commands,
			s.OutCommand{
				Title:    "Отменить текущий заказ",
				Action:   "cancel",
				Position: position,
			},
		)
	}
	return &commands
}
func GetCommands(dictUrl string) map[string]*[]s.OutCommand {
	result := make(map[string]*[]s.OutCommand)
	hours := []string{"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"}
	minutes := []string{"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25",
		"26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "39", "40", "41", "42", "43", "44", "45", "46", "48", "48", "49", "50", "51", "52", "53", "54", "54", "55", "56", "57", "58", "59"}
	for i := 0; i < 60; i++ {
		if i < 24 {
			hours = append(hours, fmt.Sprintf("%02d", i))

		}
		minutes = append(minutes, fmt.Sprintf("%02d", i))
	}
	var taxi_call_form = &s.OutForm{
		Title: "Форма вsызова такси",
		Type:  "form",
		Name:  "call_taxi",
		Text:  "Откуда: ?(street_from), ?(house_from), ?(entrance). Куда: ?(street_to), ?(house_to). Когда: ?(thour):?(tmin).",
		Fields: []s.OutField{
			s.OutField{
				Name: "street_from",
				Type: "dict",
				Attributes: s.FieldAttribute{
					Label:    "улица",
					Required: true,
					URL:      &dictUrl,
				},
			},
			s.OutField{
				Name: "house_from",
				Type: "text",
				Attributes: s.FieldAttribute{
					Label:    "дом",
					Required: true,
				},
			},
			s.OutField{
				Name: "entrance",
				Type: "text",
				Attributes: s.FieldAttribute{
					Label:     "подъезд",
					Required:  false,
					EmptyText: &not_point,
				},
			},
			s.OutField{
				Name: "street_to",
				Type: "dict",
				Attributes: s.FieldAttribute{
					Label:    "улицa",
					Required: true,
					URL:      &dictUrl,
				},
			},
			s.OutField{
				Name: "house_to",
				Type: "text",
				Attributes: s.FieldAttribute{
					Label:    "дом",
					Required: true,
				},
			},
			s.OutField{
				Name: "thour",
				Type: "list-single",
				Attributes: s.FieldAttribute{
					Label:     "ЧЧ",
					EmptyText: &NOW,
				},
				Items: s.FormItems(hours),
			},
			s.OutField{
				Name: "tmin",
				Type: "list-single",
				Attributes: s.FieldAttribute{
					Label:     "MM",
					EmptyText: &EMPTY,
				},
				Items: s.FormItems(minutes),
			},
		},
	}

	result[CMDS_CREATED_ORDER] = &[]s.OutCommand{
		s.OutCommand{
			Title:    "Отменить заказ",
			Action:   "cancel_order",
			Position: 0,
		},
		s.OutCommand{
			Title:    "Написать диспетчеру",
			Action:   "write_dispatcher",
			Position: 1,
			Fixed:    true,
			Form: &s.OutForm{
				Type: "form",
				Text: "?(text)",
				Fields: []s.OutField{
					s.OutField{
						Name: "text",
						Type: "text",
						Attributes: s.FieldAttribute{
							Label:    "Текст сообщения",
							Required: true,
						},
					},
				},
			},
		},
	}

	result[CMDS_FEEDBACK] = &[]s.OutCommand{
		s.OutCommand{
			Title:    "Отзыв о поездке",
			Action:   "feedback",
			Position: 0,
			Form: &s.OutForm{
				Type: "form",
				Text: "?(text)",
				Fields: []s.OutField{
					s.OutField{
						Name: "text",
						Type: "text",
						Attributes: s.FieldAttribute{
							Label:    "Ваш отзыв",
							Required: true,
						},
					},
				},
			},
		},

		s.OutCommand{
			Title:    "Вызвать такси",
			Action:   "new_order",
			Position: 1,
			Repeated: true,
			Form:     taxi_call_form,
		},
	}

	result[CMDS_NOT_CREATED_ORDER] = &[]s.OutCommand{
		s.OutCommand{
			Title:    "Вызвать такси",
			Action:   "new_order",
			Position: 0,
			Repeated: true,
			Form:     taxi_call_form,
		},
	}
	return result
}
예제 #4
0
func getCommandsTextAndFieldForDrink(chc *CoffeeHouseConfiguration) (string, []s.OutField) {
	result := "Ваш заказ: ?(drink)"
	resultFields := []s.OutField{
		s.OutField{
			Name: "drink",
			Type: "list-single",
			Attributes: s.FieldAttribute{
				Label:    "напиток",
				Required: true,
			},
			Items: s.FormItemsFromSortedWithPrice(chc.Drinks),
		},
		s.OutField{
			Name: "sugar",
			Type: "list-single",
			Attributes: s.FieldAttribute{
				Label:     "сахар",
				Required:  false,
				EmptyText: &NO_SUGAR,
			},
			Items: s.FormItems([]string{"1 ложка", "2 ложки", "3 ложки", "4 ложки"}),
		},
		s.OutField{
			Name: "count",
			Type: "list-single",
			Attributes: s.FieldAttribute{
				Label:     "количество",
				Required:  false,
				EmptyText: &ONE,
			},
			Items: s.FormItems([]string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}),
		},
		s.OutField{
			Name: "to_time",
			Type: "list-single",
			Attributes: s.FieldAttribute{
				Label:     "когда",
				Required:  false,
				EmptyText: &NOW,
			},
			Items: s.FormItems([]string{"через 10 минут", "через 20 минут", "через 30 минут"}),
		},
	}
	if len(chc.Additives) > 0 {
		result = fmt.Sprintf("%v, ?(additive)", result)
		resultFields = append(resultFields, s.OutField{
			Name: "additive",
			Type: "list-single",
			Attributes: s.FieldAttribute{
				Label:     "добавки",
				Required:  false,
				EmptyText: &NO_ADD,
			},
			Items: s.FormItemsFromSortedWithPrice(chc.Additives),
		})
	}
	if len(chc.Syrups) > 0 {
		result = fmt.Sprintf("%v, ?(syrup),", result)
		resultFields = append(resultFields, s.OutField{
			Name: "syrup",
			Type: "list-single",
			Attributes: s.FieldAttribute{
				Label:     "сироп",
				Required:  false,
				EmptyText: &NO_SYRUP,
			},
			Items: s.FormItemsFromSortedWithPrice(chc.Syrups),
		})
	}
	result = fmt.Sprintf("%v ?(sugar), ?(count) ?(to_time)", result)
	return result, resultFields
}