fix Parse

This commit is contained in:
Adam Babik 2017-11-23 13:47:20 +01:00
parent 98b3f330af
commit 47d16bffd0
1 changed files with 7 additions and 3 deletions

View File

@ -167,17 +167,21 @@ func (j *Jail) CreateAndInitCell(chatID string, code ...string) string {
func (j *Jail) Parse(chatID, code string) string {
cell, err := j.cell(chatID)
if err != nil {
// cell does not exist
// cell does not exist, so create and init it
cell, err = j.createAndInitCell(chatID, code)
} else {
// cell already exist, so just execute the code
_, err = cell.Run(code)
// cell already exists, so just reinit it
err = j.initCell(cell)
}
if err != nil {
return newJailErrorResponse(err)
}
if _, err = cell.Run(code); err != nil {
return newJailErrorResponse(err)
}
return j.makeCatalogVariable(cell)
}