Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team c aki #154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions shira/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
editedBody: null,
}
},
// Tutorial 1-2. ユーザー名を表示しよう
// Tutorial 1-2. ユーザー名を表示しよう
template: `
<div class="message">
<div v-if="editing">
Expand All @@ -25,9 +25,11 @@
</div>
</div>
<div class="message-body" v-else>
<span>{{ body }} - {{ username }}</span>
<span>{{ username }} - <a href="{{ body }}"">{{ body }}</a></span>
<!--
<span class="action-button u-pull-right" v-on:click="edit">&#9998;</span>
<span class="action-button u-pull-right" v-on:click="remove">&#10007;</span>
-->
</div>
</div>
`,
Expand Down
17 changes: 17 additions & 0 deletions shira/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,20 @@ func NewKeywordBot(out chan *model.Message) *Bot {
processor: processor,
}
}

//食べたいbot
func NewEliteBot(out chan *model.Message) *Bot {
in := make(chan *model.Message)

checker := NewRegexpChecker("\\A.*が食べたい")

processor := &EliteProcessor{}

return &Bot{
name: "elitebot",
in: in,
out: out,
checker: checker,
processor: processor,
}
}
9 changes: 9 additions & 0 deletions shira/bot/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type (
KeywordProcessor struct{}

TalkProcessor struct{}

EliteProcessor struct{}
)

// Process は"hello, world!"というbodyがセットされたメッセージのポインタを返します
Expand Down Expand Up @@ -116,3 +118,10 @@ func (p *TalkProcessor) Process(msgIn *model.Message) (*model.Message, error) {
Body: "OK",
}, nil
}

func (p *EliteProcessor) Process(msgIn *model.Message) (*model.Message, error) {
// r := regexp.MustCompile("\\A(.*)が食べたい\\z")
return &model.Message{
Body: "店名: 松屋(渋谷店)\nURL:hoge",
}, nil
}
2 changes: 2 additions & 0 deletions shira/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func (s *Server) Init(dbconf, env string) error {
s.bots = append(s.bots, gachaBot)
talkBot := bot.NewTalkBot(s.poster.In)
s.bots = append(s.bots, talkBot)
eliteBot := bot.NewEliteBot(s.poster.In)
s.bots = append(s.bots, eliteBot)

return nil
}
Expand Down