Exemplo n.º 1
0
func TestFill(t *testing.T) {
	my := &MyThing{Value: 3}
	schema.Fill(my)
	if my.SchemaType != "http://github.com/sarifsystems/sarif/pkg/schema_test/MyThing" {
		t.Error("wrong type:", my.SchemaType)
	}

	my2 := MySpecialThing{Name: "Shiny"}
	schema.Fill(&my2)
	if my2.SchemaType != "http://schema.org/Thing" {
		t.Error("wrong type:", my2.SchemaType)
	}
}
Exemplo n.º 2
0
func (s *Service) handleAsk(msg sarif.Message) {
	q := msg.Text
	if q == "" {
		q = "What is the answer to life, the universe and everything?"
	}

	pl := schema.Fill(&questionMessage{
		Question: q,
		Action: schema.Fill(&schema.TextEntryAction{
			Reply: "question/answer/ultimate",
			Name:  "Answer this question.",
		}),
	})
	s.Reply(msg, sarif.CreateMessage("question", pl))
}