@codebam/cf-workers-telegram-bot 11.5.2 → 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.
package/README.md CHANGED
@@ -95,9 +95,9 @@ The `consumer` directory in this repository serves as a template for new project
95
95
  npm run deploy
96
96
  ```
97
97
 
98
- 6. **Set Webhook**:
98
+ 5. **Set Webhook**:
99
99
  Visit the following URL in your browser to register your worker with Telegram:
100
- `https://<your-worker>.<your-subdomain>.workers.dev/<SECRET_TELEGRAM_API_TOKEN>?command=set`
100
+ `https://<your-worker>.<your-subdomain>.workers.dev/<SECRET_TELEGRAM_API_TOKEN>/setWebhook`
101
101
 
102
102
  ## Deployment
103
103
 
@@ -108,7 +108,8 @@ npx wrangler deploy
108
108
  ```
109
109
 
110
110
  ### GitHub Actions
111
- To automate deployments, use the [Wrangler Action](https://github.com/cloudflare/wrangler-action). Add `CLOUDFLARE_API_TOKEN` and `SECRET_TELEGRAM_API_TOKEN` to your repository secrets.
111
+ To automate deployments, use the [Wrangler Action](https://github.com/cloudflare/wrangler-action) or Cloudflare's built-in [GitHub integration](https://developers.cloudflare.com/workers/ci-cd/github-actions/).
112
+
112
113
 
113
114
  ## API Documentation
114
115
  Detailed API documentation is available at [cf-workers-telegram-bot.codebam.ca](https://cf-workers-telegram-bot.codebam.ca).
@@ -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.2",
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",