@@ -89,18 +89,47 @@ def call(self, method, params=None, files=None, expect=None):
8989 # Special handling for unavailable chats
9090 if method in SEND_TO_CHAT_METHODS :
9191 reason = None
92+
93+ # This happens when the bot tries to send messages to an user
94+ # who blocked the bot
9295 if status == 403 and "blocked" in message :
96+ # Error code # 403
97+ # Bot was blocked by the user
9398 reason = "blocked"
99+
100+ # This happens when the user deleted its account
94101 elif status == 403 and "deleted" in message :
102+ # Error code # 403
103+ # Forbidden: user is deleted
95104 reason = "account_deleted"
105+
106+ # This happens, as @BotSupport says, when the Telegram API
107+ # isn't able to determine why your bot can't contact an user
96108 elif status == 400 and "PEER_ID_INVALID" in message :
97- # What, this error is an identifier and not a sentence :/
109+ # Error code # 400
110+ # PEER_ID_INVALID
98111 reason = "not_contacted"
112+
113+ # This happens when the bot can't contact the user or the user
114+ # doesn't exist
99115 elif status == 400 and "not found" in message :
116+ # Error code # 400
117+ # Bad Request: chat not found
100118 reason = "not_found"
119+
120+ # This happens when the bot is kicked from the group chat it's
121+ # trying to send messages to
101122 elif status == 403 and "kicked" in message :
123+ # Error code # 403
124+ # Forbidden: bot was kicked from the group chat
125+ # Forbidden: bot was kicked from the supergroup chat
102126 reason = "kicked"
127+
128+ # This happens when the ID points to a group chat, which was
129+ # migrated to a supergroup chat, thus changing its ID
103130 elif status == 400 and "migrated" in message :
131+ # Error code # 400
132+ # Bad Request: group chat is migrated to a supergroup chat
104133 reason = "chat_moved"
105134
106135 if reason is not None :
0 commit comments