@codebam/cf-workers-telegram-bot 11.5.3 → 11.6.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.
@@ -114,16 +114,23 @@ export default class TelegramBot {
114
114
  case 'inline':
115
115
  return ':inline' in this.commands ? ':inline' : this.defaultCommand;
116
116
  case 'guest_message':
117
- return ':guest_message' in this.commands ? ':guest_message' : this.defaultCommand;
117
+ // For guest messages, we fall through to command detection if it's not a special type
118
+ break;
118
119
  case 'pre_checkout_query':
119
120
  return ':pre_checkout_query' in this.commands ? ':pre_checkout_query' : this.defaultCommand;
120
121
  case 'successful_payment':
121
122
  return ':successful_payment' in this.commands ? ':successful_payment' : this.defaultCommand;
122
123
  }
123
- // Then check if it's a command starting with /
124
- if (args[0]?.startsWith('/')) {
125
- const command = args[0].substring(1, args[0].lastIndexOf('@') > -1 ? args[0].lastIndexOf('@') : args[0].length);
126
- return command in this.commands ? command : this.defaultCommand;
124
+ // Then check if there's a command starting with / anywhere in the message
125
+ const commandIndex = args.findIndex((arg) => arg.startsWith('/'));
126
+ if (commandIndex !== -1) {
127
+ const fullCommand = args[commandIndex];
128
+ const command = fullCommand.substring(1, fullCommand.lastIndexOf('@') > -1 ? fullCommand.lastIndexOf('@') : fullCommand.length);
129
+ if (command in this.commands) {
130
+ // Shift args so the command handler sees the command at index 0
131
+ ctx.args = args.slice(commandIndex);
132
+ return command;
133
+ }
127
134
  }
128
135
  return this.defaultCommand;
129
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebam/cf-workers-telegram-bot",
3
- "version": "11.5.3",
3
+ "version": "11.6.0",
4
4
  "description": "serverless telegram bot on cf workers",
5
5
  "main": "./dist/main.js",
6
6
  "module": "./dist/main.js",