Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected async onRecognize(context: TurnContext, state: any, options: PromptOptions): Promise> {
const result: PromptRecognizerResult = { succeeded: false };
let results: any;
const activity: Activity = context.activity;
const utterance: string = activity.text;
const locale: string = activity.locale || this.defaultLocale || 'en-us';
switch(this.promptType)
{
case InternetProtocolPromptType.IPAddress:
results = recognizers.recognizeIpAddress(utterance, locale);
break;
case InternetProtocolPromptType.URL:
results = recognizers.recognizeURL(utterance, locale);
break;
}
if (results.length > 0 && results[0].resolution != null) {
try {
result.succeeded = true;
result.value = results[0].resolution.value;
}
catch(e) {
console.log(e);
}
}
return result;
}
}
public async onTurn(context: TurnContext, next: () => Promise): Promise {
if (context.activity.type === ActivityTypes.Message) {
const urls: ModelResult[] = recognizeURL(context.activity.text, this.defaultLocale);
const urlEntities: string[] = [];
if (urls.length > 0) {
for (const i of urls) {
urlEntities.push(i.resolution.value);
}
context.turnState.set('urlEntities', urlEntities);
}
}
await next();
}
}