tgdata 0.0.4__tar.gz → 0.0.5__tar.gz

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.
Files changed (33) hide show
  1. {tgdata-0.0.4 → tgdata-0.0.5}/PKG-INFO +8 -1
  2. {tgdata-0.0.4 → tgdata-0.0.5}/README.md +7 -0
  3. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/__init__.py +8 -2
  4. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/message_engine.py +29 -1
  5. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata.egg-info/PKG-INFO +8 -1
  6. {tgdata-0.0.4 → tgdata-0.0.5}/setup.cfg +0 -0
  7. {tgdata-0.0.4 → tgdata-0.0.5}/setup.py +0 -0
  8. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/connection_engine.py +0 -0
  9. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/models.py +0 -0
  10. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/progress.py +0 -0
  11. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/__init__.py +0 -0
  12. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/my_test.py +0 -0
  13. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_00_connection.py +0 -0
  14. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_01_list_group_chats.py +0 -0
  15. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_02_get_message_count.py +0 -0
  16. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_03_get_all_messages.py +0 -0
  17. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_04_get_all_messages_in_batches.py +0 -0
  18. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_05_with_progress_feature.py +0 -0
  19. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_06_polling_simple.py +0 -0
  20. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_07_on_new_message_simple.py +0 -0
  21. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_07_real_time_event_handler.py +0 -0
  22. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_08_batch_callback.py +0 -0
  23. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_08_polling.py +0 -0
  24. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_10_advanced_features.py +0 -0
  25. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_debug_min_id.py +0 -0
  26. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_polling_debug.py +0 -0
  27. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/smoke_tests/test_username_support.py +0 -0
  28. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/tgdata.py +0 -0
  29. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata/utils.py +0 -0
  30. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata.egg-info/SOURCES.txt +0 -0
  31. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata.egg-info/dependency_links.txt +0 -0
  32. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata.egg-info/requires.txt +0 -0
  33. {tgdata-0.0.4 → tgdata-0.0.5}/tgdata.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tgdata
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: A production-grade Python library for extracting and processing Telegram group and channel messages
5
5
  Author: enes kuzucu
6
6
  Classifier: Development Status :: 3 - Alpha
@@ -192,6 +192,13 @@ messages = await tg.get_messages(
192
192
  )
193
193
  ```
194
194
 
195
+ A numeric id resolves only if the session can actually see the group. On a
196
+ cache miss tgdata syncs the account's chat list once and retries — so fresh
197
+ sessions work for groups the account belongs to. If the group still can't be
198
+ found it raises `tgdata.GroupAccessError` (the account is not a member, or
199
+ the id is wrong) instead of Telethon's generic "Could not find the input
200
+ entity" ValueError.
201
+
195
202
  ### get_messages with start_date parameter
196
203
 
197
204
  ```python
@@ -166,6 +166,13 @@ messages = await tg.get_messages(
166
166
  )
167
167
  ```
168
168
 
169
+ A numeric id resolves only if the session can actually see the group. On a
170
+ cache miss tgdata syncs the account's chat list once and retries — so fresh
171
+ sessions work for groups the account belongs to. If the group still can't be
172
+ found it raises `tgdata.GroupAccessError` (the account is not a member, or
173
+ the id is wrong) instead of Telethon's generic "Could not find the input
174
+ entity" ValueError.
175
+
169
176
  ### get_messages with start_date parameter
170
177
 
171
178
  ```python
@@ -7,6 +7,9 @@ A production-grade Python library for extracting and processing Telegram group a
7
7
  # Main class
8
8
  from .tgdata import TgData
9
9
 
10
+ # Errors
11
+ from .message_engine import GroupAccessError
12
+
10
13
  # Models
11
14
  from .models import (
12
15
  MessageData,
@@ -30,12 +33,15 @@ from .utils import (
30
33
  # Progress tracking
31
34
  from .progress import ProgressTracker
32
35
 
33
- __version__ = "0.0.4"
36
+ __version__ = "0.0.5"
34
37
 
35
38
  __all__ = [
36
39
  # Main class
37
40
  "TgData",
38
-
41
+
42
+ # Errors
43
+ "GroupAccessError",
44
+
39
45
  # Models
40
46
  "MessageData",
41
47
  "GroupInfo",
@@ -29,6 +29,12 @@ DEFAULT_FETCH_LIMIT = 750
29
29
  MAX_FLOOD_RETRIES = 3
30
30
 
31
31
 
32
+ class GroupAccessError(Exception):
33
+ """The account cannot see this group: it is not a member (or the id is
34
+ wrong). Raised only after a dialog sync ruled out the benign cause —
35
+ a fresh session whose entity cache simply hasn't met the id yet."""
36
+
37
+
32
38
  class MessageEngine:
33
39
  """
34
40
  Handles all message-related operations.
@@ -134,7 +140,10 @@ class MessageEngine:
134
140
  try:
135
141
  async with self.connection_engine.session() as client:
136
142
  # Get the entity
137
- channel = await client.get_entity(group_id)
143
+ try:
144
+ channel = await client.get_entity(group_id)
145
+ except ValueError:
146
+ channel = await self._entity_after_dialog_sync(client, group_id)
138
147
  logger.info(f"Fetching messages from: {channel.title}")
139
148
 
140
149
  # Per-chat context stamped onto every row (provenance / deep links)
@@ -364,6 +373,25 @@ class MessageEngine:
364
373
  df['GroupedId'] = df['GroupedId'].astype('Int64')
365
374
  return df
366
375
 
376
+ @staticmethod
377
+ async def _entity_after_dialog_sync(client, group_id):
378
+ """get_entity said "never seen this id" — an ambiguous error hiding two
379
+ different situations. Telegram sessions can only resolve ids they have
380
+ encountered, so a FRESH session fails even for groups the account IS a
381
+ member of. Sync the chat list (fills the entity cache) and retry once:
382
+ a member resolves and the fetch proceeds as if nothing happened; a
383
+ non-member fails again, and only then is it a real access problem —
384
+ reported as one, instead of Telethon's cache riddle."""
385
+ logger.info(f"Entity {group_id} unknown to this session — syncing dialogs to check membership")
386
+ await client.get_dialogs()
387
+ try:
388
+ return await client.get_entity(group_id)
389
+ except ValueError:
390
+ raise GroupAccessError(
391
+ f"account has no access to group {group_id} — the account is not "
392
+ f"a member (join the group with this account), or the id is wrong"
393
+ ) from None
394
+
367
395
  @staticmethod
368
396
  def _link_base(chat) -> Optional[str]:
369
397
  """Base t.me URL for deep links to this chat's messages (None if not linkable)."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tgdata
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: A production-grade Python library for extracting and processing Telegram group and channel messages
5
5
  Author: enes kuzucu
6
6
  Classifier: Development Status :: 3 - Alpha
@@ -192,6 +192,13 @@ messages = await tg.get_messages(
192
192
  )
193
193
  ```
194
194
 
195
+ A numeric id resolves only if the session can actually see the group. On a
196
+ cache miss tgdata syncs the account's chat list once and retries — so fresh
197
+ sessions work for groups the account belongs to. If the group still can't be
198
+ found it raises `tgdata.GroupAccessError` (the account is not a member, or
199
+ the id is wrong) instead of Telethon's generic "Could not find the input
200
+ entity" ValueError.
201
+
195
202
  ### get_messages with start_date parameter
196
203
 
197
204
  ```python
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes