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
Hubotを捨ててGolangに書き直す #10
Comments
正規表現でユーザー入力を解析して特定のときに特定のことをするみたいなハンドラーをどう書くのか謎い 雰囲気的には構造体を用意してパターンマッチかな? type Command struct {
pattern string
handler func()
}
var commands []Command
commands.append(&Command{"^ping", pingHandler})
...
for _, c := range commands {
if regexp.MatchString(c.pattern, input) {
c.handler()
}
} こんな感じ。色々とできるのか不安だけど、そこら辺は調べるしか無い |
正規表現じゃなくてコマンド式にすると、扱いやすそうに思える |
ctftimesの奴、coffeescript見ながら取得するだけの奴作ってみたけど、replace-goに置く感じでも大丈夫?
|
@tukeJonny replacing-go ブランチに直接PRを出してください。 |
This was referenced Jun 20, 2017
Closed
This was referenced Jul 17, 2017
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
表題通り。もう流石にCoffeescriptなんか書きたくないし時代は変わったw
Golangで書き直してやりたい。
Refs:
The text was updated successfully, but these errors were encountered: