@microsoft/teamsfx 0.7.1-beta.15e156d38.0 → 0.7.1-beta.65870165d.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1972,35 +1972,33 @@ class CommandResponseMiddleware {
1972
1972
  }
1973
1973
  }
1974
1974
  async onTurn(context, next) {
1975
- const type = this.classifyActivity(context.activity);
1976
- switch (type) {
1977
- case ActivityType.CurrentBotMessaged:
1978
- // Invoke corresponding command handler for the command response
1979
- const commandText = this.getActivityText(context.activity);
1980
- const message = {
1981
- text: commandText,
1982
- };
1983
- for (const handler of this.commandHandlers) {
1984
- const matchResult = this.shouldTrigger(handler.triggerPatterns, commandText);
1985
- // It is important to note that the command bot will stop processing handlers
1986
- // when the first command handler is matched.
1987
- if (!!matchResult) {
1988
- message.matches = Array.isArray(matchResult) ? matchResult : void 0;
1989
- const response = await handler.handleCommandReceived(context, message);
1975
+ if (context.activity.type === ActivityTypes.Message) {
1976
+ // Invoke corresponding command handler for the command response
1977
+ const commandText = this.getActivityText(context.activity);
1978
+ const message = {
1979
+ text: commandText,
1980
+ };
1981
+ for (const handler of this.commandHandlers) {
1982
+ const matchResult = this.shouldTrigger(handler.triggerPatterns, commandText);
1983
+ // It is important to note that the command bot will stop processing handlers
1984
+ // when the first command handler is matched.
1985
+ if (!!matchResult) {
1986
+ message.matches = Array.isArray(matchResult) ? matchResult : void 0;
1987
+ const response = await handler.handleCommandReceived(context, message);
1988
+ if (typeof response === "string") {
1990
1989
  await context.sendActivity(response);
1991
- break;
1990
+ }
1991
+ else {
1992
+ const replyActivity = response;
1993
+ if (replyActivity) {
1994
+ await context.sendActivity(replyActivity);
1995
+ }
1992
1996
  }
1993
1997
  }
1994
- break;
1998
+ }
1995
1999
  }
1996
2000
  await next();
1997
2001
  }
1998
- classifyActivity(activity) {
1999
- if (activity.type === ActivityTypes.Message) {
2000
- return ActivityType.CurrentBotMessaged;
2001
- }
2002
- return ActivityType.Unknown;
2003
- }
2004
2002
  matchPattern(pattern, text) {
2005
2003
  if (text) {
2006
2004
  if (typeof pattern === "string") {