-
Notifications
You must be signed in to change notification settings - Fork 55
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
Improve multi-executors RuleTypes flow #26
Improve multi-executors RuleTypes flow #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a nice feature!
👏
} catch (e) { | ||
let expectedError = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] renames to expectedReply
src/core/exceptions.ts
Outdated
|
||
export function PauseRuleTypeExecutors(name: string) { | ||
this.key = 'pauseRuleTypeExecutors'; | ||
this.message = `Rule "${name}" should pause exection`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
src/types.ts
Outdated
|
||
export interface RuleTypeExecutor { | ||
validators?: RuleValidator[]; | ||
transform?: (value: any, rule?: Rule, bot?: YveBot) => Promise<any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a type RuleTypeTransform
src/core/bot.ts
Outdated
@@ -121,3 +126,7 @@ export class YveBot { | |||
YveBot.prototype.types = new Types; | |||
YveBot.prototype.actions = new Actions; | |||
YveBot.prototype.validators = new Validators; | |||
|
|||
|
|||
YveBot.Exceptions = Exceptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use exceptions
to keep the pattern
YveBot.exceptions.RuleNotFound
src/core/bot.ts
Outdated
|
||
|
||
YveBot.Exceptions = Exceptions; | ||
YveBot.WaitForUserInputExecutor = WaitForUserInput; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YveBot.executors = new Executors
to be accessed by YveBot.executors.WaitForUserInput
src/core/types.ts
Outdated
import * as utils from './utils'; | ||
|
||
const types = { | ||
|
||
export const WaitForUserInput: RuleTypeExecutor = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it to ./executors
src/core/bot.ts
Outdated
@@ -23,6 +25,9 @@ function sanitizeRule(rule: Rule): Rule { | |||
} | |||
|
|||
export class YveBot { | |||
static Exceptions: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptions instead of any
src/core/bot.ts
Outdated
@@ -23,6 +25,9 @@ function sanitizeRule(rule: Rule): Rule { | |||
} | |||
|
|||
export class YveBot { | |||
static Exceptions: any; | |||
static WaitForUserInputExecutor: typeof WaitForUserInput; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try without typeof
src/core/controller.ts
Outdated
this.bot.store.unset(`executors.${rule.name}.currentIdx`); | ||
} | ||
|
||
async executeRuleTypeExecutors(rule: Rule, lastAnswer: Answer | Answer[]): Promise<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Promise<Answer | Answer[]>
breaks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no guarantee that return will be answer... the return will be whatever transform + validators returns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
This changes makes "how to pause executors" as explicit as possible.