python-vk-bot 0.8.0__py3-none-any.whl → 0.8.1__py3-none-any.whl

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.
python_vk_bot/bot.py CHANGED
@@ -163,10 +163,39 @@ class Bot:
163
163
  return users[0] if users else None
164
164
 
165
165
  async def get_message(self, peer_id: int, conversation_message_id: int) -> Message | None:
166
+ """Fetch one message, returning None only for confirmed absence.
167
+
168
+ Invalid identifiers raise ValueError before the request. Malformed or
169
+ inconsistent responses raise InvalidResponseError; API and transport
170
+ errors propagate unchanged. No retries or fallback requests are made.
171
+ """
172
+ peer_id = _peer_identifier(peer_id)
173
+ conversation_message_id = _message_identifier(None, conversation_message_id)
166
174
  result = await self.request(
167
175
  "messages.getByConversationMessageId",
168
176
  {"peer_id": peer_id, "conversation_message_ids": conversation_message_id},
169
177
  )
178
+ if not isinstance(result, dict):
179
+ raise InvalidResponseError("Invalid message lookup response")
180
+ count = result.get("count")
181
+ items = result.get("items")
182
+ if (
183
+ type(count) is not int
184
+ or count not in (0, 1)
185
+ or not isinstance(items, list)
186
+ or count != len(items)
187
+ ):
188
+ raise InvalidResponseError("Invalid message lookup count or items")
189
+ if count == 1:
190
+ item = items[0]
191
+ if not isinstance(item, dict) or any(
192
+ type(item.get(field)) is not int or item[field] != expected
193
+ for field, expected in (
194
+ ("peer_id", peer_id),
195
+ ("conversation_message_id", conversation_message_id),
196
+ )
197
+ ):
198
+ raise InvalidResponseError("Message lookup result has unexpected identifiers")
170
199
  page = _parse(MessagePage, result)
171
200
  return page.items[0] if page.items else None
172
201
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-vk-bot
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: An asynchronous framework for VK community bots.
5
5
  Project-URL: Homepage, https://github.com/fomenko-ai/python-vk-bot
6
6
  Project-URL: Repository, https://github.com/fomenko-ai/python-vk-bot
@@ -1,7 +1,7 @@
1
1
  python_vk_bot/__init__.py,sha256=f6S37kGsoT0yoVT19IMpkweIMG8CyoeTxUQprFtT-LM,1631
2
2
  python_vk_bot/_config.py,sha256=Rju-sjCKAfk70ajQbpPMzOuefBIjtgF8tKjOuSYo0AE,744
3
3
  python_vk_bot/application.py,sha256=dkHR3F6geN8VhpnnfCb7aSEL1k8GCo-iA9nSZRoZCC4,20361
4
- python_vk_bot/bot.py,sha256=T1ORFc9Bcrj_YAzM288V9QmrwwwSwQ7fqQ_nsIfNBLU,17108
4
+ python_vk_bot/bot.py,sha256=1MuhW3GjKJx0HTA6SaWUioXlS6I9ZxW1-wZoNfwFsKM,18457
5
5
  python_vk_bot/callback.py,sha256=9j11jtl4rpTnfUThvOf2g6kb7wYQXAQerHbuk3IYw3o,4726
6
6
  python_vk_bot/context.py,sha256=yFPT1rXCUXSfbyPCu4y2kmWv2NI_XlZ2zIbzTpeWG90,504
7
7
  python_vk_bot/errors.py,sha256=N0bBnNqc_yHUIGxQ3fTwGLk7V03nn5FLQwcpBSsA7dQ,1544
@@ -24,7 +24,7 @@ python_vk_bot/models/event_answers.py,sha256=BApsLwOySfcr3aLUazQo8rryEsitT3jaEGT
24
24
  python_vk_bot/models/events.py,sha256=7JPZykMTRy8hiMKsX45ZZbwGiK8-sZFtzXZqprYxK18,2826
25
25
  python_vk_bot/models/keyboards.py,sha256=p-Z7EGL5e-rOPoYVEg_uctgwSMmCVk-Z1Pgl1nZ32RY,3062
26
26
  python_vk_bot/models/messages.py,sha256=kuQEc4iLZJvhzpKJAGvRcERJdASWYQpj0OUwNdjnn10,4215
27
- python_vk_bot-0.8.0.dist-info/METADATA,sha256=vN1_zAYcrh5Y-ErIaSrHUwsvvvXRdO74ywO7dVCuuSE,15255
28
- python_vk_bot-0.8.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
29
- python_vk_bot-0.8.0.dist-info/licenses/LICENSE,sha256=F-35ycqPcYW243OjxMHCggr_AHQgZLX2zvtZgobVEvo,1072
30
- python_vk_bot-0.8.0.dist-info/RECORD,,
27
+ python_vk_bot-0.8.1.dist-info/METADATA,sha256=ZdGFmUmK7JxA9L3z_CcEK0rcIxi8K1bJEQe75BAmzbw,15255
28
+ python_vk_bot-0.8.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
29
+ python_vk_bot-0.8.1.dist-info/licenses/LICENSE,sha256=F-35ycqPcYW243OjxMHCggr_AHQgZLX2zvtZgobVEvo,1072
30
+ python_vk_bot-0.8.1.dist-info/RECORD,,