@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 +4 -3
- package/dist/telegram_bot.js +12 -5
- package/package.json +1 -1
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
|
-
|
|
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
|
|
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)
|
|
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).
|
package/dist/telegram_bot.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
}
|