Comments (8)
Log the entire $message payload and start from there.
If getSender()
returns 0, then getUser()
will fail.
from botman.
Here is the $message
content when it happens:
[2023-09-03 15:27:08] production.INFO: BotMan\BotMan\Messages\Incoming\IncomingMessage::__set_state(array(
'message' => NULL,
'sender' => 0,
'recipient' => NULL,
'bot_id' => '',
'images' =>
array (
),
'videos' =>
array (
),
'payload' =>
Illuminate\Support\Collection::__set_state(array(
'items' =>
array (
'from' =>
array (
'id' => 0,
),
),
'escapeWhenCastingToString' => false,
)),
'extras' =>
array (
),
'audio' =>
array (
),
'files' =>
array (
),
'location' => NULL,
'contact' => NULL,
'isFromBot' => false,
))
from botman.
There's nothing there. Someone or something (ie. a crawler) is calling the endpoint without passing any data.
from botman.
This happens when a bot is added or removed from a group. Looks like Received middleware captures such service messages:
{
"update_id": 22069942,
"my_chat_member": {
"chat": {
"id": -222222222,
"title": "Test",
"type": "group",
"all_members_are_administrators": true
},
"from": {
"id": 111111111,
"is_bot": false,
"first_name": "Example",
"username": "Example",
"language_code": "fr"
},
"date": 1693746567,
"old_chat_member": {
"user": {
"id": 3333333333,
"is_bot": true,
"first_name": "Botname",
"username": "botnamebot"
},
"status": "left"
},
"new_chat_member": {
"user": {
"id": 3333333333,
"is_bot": true,
"first_name": "Botname",
"username": "botnamebot"
},
"status": "member"
}
}
}
Is there a way to skip such messages?
from botman.
Just write some code in your Middleware to exclude the processing of this kind of messages.
from botman.
Yes, I did it this way:
public function received(IncomingMessage $message, $next, BotMan $bot)
{
// Ignore service messages
if (! $message->getSender()) {
return $next($message);
}
For those who are looking how to capture service messages here are the list of supported Telegram events. Usage is described here.
from botman.
Another way to ignore service messages is not to use the Received middleware but instead use Heard and Captured.
from botman.
I realized that one of the reasons for this error is when users add a bot into a channel. Messages from channel admins are anonymous so getUser()
method fails. I had to ignore channels in the middleware.
from botman.
Related Issues (20)
- Slow bot reply with telegram-driver HOT 6
- send button/icon HOT 1
- Telegram doesn't show emoji
- Invalid URL to access Slack channel HOT 2
- cURL error 60: SSL: no alternative certificate subject name matches target host name 'graph.facebook.co' HOT 7
- Issue using botman commands with wit ai commands (intents)
- CallBackData button inline - Driver Telegram botman
- FacebookDriven verification error HOT 1
- Conversation lost when reload page HOT 5
- What are the limitations on Botman's regex capabilities? HOT 1
- Fatal error: Uncaught Error: Class "DriverManager" not found
- Is this package suite still maintained? HOT 1
- Need Laravel 11 Support HOT 1
- Telegram Bot Driver Issue HOT 3
- Write message in a chatbox user session HOT 11
- Sending message using a Facebook driver instance
- Ubuntu Apache2 returns 408 HOT 6
- How many times BuildPayload method should be called? HOT 1
- Bot Commands Not Executing on First Attempt HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from botman.