tgdata 0.0.3__tar.gz → 0.0.4__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.3 → tgdata-0.0.4}/PKG-INFO +13 -2
  2. {tgdata-0.0.3 → tgdata-0.0.4}/README.md +12 -1
  3. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/__init__.py +1 -1
  4. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/connection_engine.py +32 -10
  5. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata.egg-info/PKG-INFO +13 -2
  6. {tgdata-0.0.3 → tgdata-0.0.4}/setup.cfg +0 -0
  7. {tgdata-0.0.3 → tgdata-0.0.4}/setup.py +0 -0
  8. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/message_engine.py +0 -0
  9. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/models.py +0 -0
  10. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/progress.py +0 -0
  11. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/__init__.py +0 -0
  12. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/my_test.py +0 -0
  13. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_00_connection.py +0 -0
  14. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_01_list_group_chats.py +0 -0
  15. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_02_get_message_count.py +0 -0
  16. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_03_get_all_messages.py +0 -0
  17. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_04_get_all_messages_in_batches.py +0 -0
  18. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_05_with_progress_feature.py +0 -0
  19. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_06_polling_simple.py +0 -0
  20. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_07_on_new_message_simple.py +0 -0
  21. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_07_real_time_event_handler.py +0 -0
  22. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_08_batch_callback.py +0 -0
  23. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_08_polling.py +0 -0
  24. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_10_advanced_features.py +0 -0
  25. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_debug_min_id.py +0 -0
  26. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_polling_debug.py +0 -0
  27. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/smoke_tests/test_username_support.py +0 -0
  28. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/tgdata.py +0 -0
  29. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata/utils.py +0 -0
  30. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata.egg-info/SOURCES.txt +0 -0
  31. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata.egg-info/dependency_links.txt +0 -0
  32. {tgdata-0.0.3 → tgdata-0.0.4}/tgdata.egg-info/requires.txt +0 -0
  33. {tgdata-0.0.3 → tgdata-0.0.4}/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.3
3
+ Version: 0.0.4
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
@@ -67,10 +67,21 @@ tgdata supports 1 authentication at the moment.
67
67
  api_id = 1234566
68
68
  api_hash = a24adjfakjdfakjshdflkajsbdflk
69
69
  phone = +905064004949 # use full phone number including + and country code
70
- username = 'powerpuffdude'
71
70
 
71
+ # Where the Telethon session lives (".session" is appended automatically).
72
+ # Use an ABSOLUTE path — a bare name creates the file in whatever directory
73
+ # the process happens to run from. Do not quote values: INI values are raw
74
+ # text, so quotes become part of the value (tgdata strips them defensively
75
+ # since 0.0.4, but don't rely on it).
76
+ session_file = /absolute/path/to/my_session
72
77
  ```
73
78
 
79
+ **Session naming precedence** (since 0.0.4): an explicit `session_file`
80
+ always wins. A legacy `username` key is used as the session name only when
81
+ no `session_file` is set — configs that relied on username-named sessions
82
+ keep working, but new configs should set `session_file` and omit `username`
83
+ (it plays no part in authentication).
84
+
74
85
 
75
86
  ## Quick Start
76
87
 
@@ -41,10 +41,21 @@ tgdata supports 1 authentication at the moment.
41
41
  api_id = 1234566
42
42
  api_hash = a24adjfakjdfakjshdflkajsbdflk
43
43
  phone = +905064004949 # use full phone number including + and country code
44
- username = 'powerpuffdude'
45
44
 
45
+ # Where the Telethon session lives (".session" is appended automatically).
46
+ # Use an ABSOLUTE path — a bare name creates the file in whatever directory
47
+ # the process happens to run from. Do not quote values: INI values are raw
48
+ # text, so quotes become part of the value (tgdata strips them defensively
49
+ # since 0.0.4, but don't rely on it).
50
+ session_file = /absolute/path/to/my_session
46
51
  ```
47
52
 
53
+ **Session naming precedence** (since 0.0.4): an explicit `session_file`
54
+ always wins. A legacy `username` key is used as the session name only when
55
+ no `session_file` is set — configs that relied on username-named sessions
56
+ keep working, but new configs should set `session_file` and omit `username`
57
+ (it plays no part in authentication).
58
+
48
59
 
49
60
  ## Quick Start
50
61
 
@@ -30,7 +30,7 @@ from .utils import (
30
30
  # Progress tracking
31
31
  from .progress import ProgressTracker
32
32
 
33
- __version__ = "0.0.3"
33
+ __version__ = "0.0.4"
34
34
 
35
35
  __all__ = [
36
36
  # Main class
@@ -117,18 +117,38 @@ class ConnectionEngine:
117
117
 
118
118
  if telegram_section is None:
119
119
  raise ValueError("No [telegram] or [Telegram] section found in config file")
120
-
120
+
121
+ def _unquote(value):
122
+ # INI values are raw text: `username = 'name'` yields the QUOTES as
123
+ # part of the value, and a quoted session name becomes a file
124
+ # literally called 'name'.session on disk. Strip surrounding
125
+ # quotes from every string we read.
126
+ return value.strip().strip("'\"") if isinstance(value, str) else value
127
+
128
+ section = config[telegram_section]
129
+ raw_session = _unquote(section.get('session_file'))
130
+ raw_username = _unquote(section.get('username'))
131
+
132
+ # Session naming precedence: an EXPLICIT session_file always wins — it
133
+ # is the documented home of the credential, and honoring it keeps the
134
+ # session's location independent of the process's working directory.
135
+ # The legacy behavior (username as the session name) applies only when
136
+ # no session_file is configured, so old username-only configs keep
137
+ # finding their existing sessions. 'telegram_session' is the final
138
+ # fallback when neither is set.
139
+ session_name = raw_session or raw_username or 'telegram_session'
140
+
121
141
  self._config = ConnectionConfig(
122
- api_id=config[telegram_section]['api_id'],
123
- api_hash=config[telegram_section]['api_hash'],
124
- session_file=config[telegram_section].get('session_file', 'telegram_session'),
125
- phone=config[telegram_section].get('phone'),
126
- username=config[telegram_section].get('username'),
142
+ api_id=_unquote(section['api_id']),
143
+ api_hash=_unquote(section['api_hash']),
144
+ session_file=session_name,
145
+ phone=_unquote(section.get('phone')),
146
+ username=raw_username,
127
147
  max_retries=self.max_retries,
128
148
  retry_delay=self.retry_delay,
129
149
  exponential_backoff=self.exponential_backoff
130
150
  )
131
-
151
+
132
152
  return self._config
133
153
 
134
154
  async def get_client(self) -> TelegramClient:
@@ -173,10 +193,12 @@ class ConnectionEngine:
173
193
  """Create and authenticate the primary client once (may be interactive)."""
174
194
  config = self._load_config()
175
195
 
176
- # Use username as session name for compatibility with original code
177
- session_name = config.username if config.username else config.session_file
196
+ # Session naming is resolved ONCE in _load_config (explicit
197
+ # session_file > username > default) — config.session_file IS the
198
+ # resolved name, so the primary client and the pool clients below
199
+ # can never disagree about where the session lives.
178
200
  self._primary_client = TelegramClient(
179
- session_name,
201
+ config.session_file,
180
202
  config.api_id,
181
203
  config.api_hash
182
204
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tgdata
3
- Version: 0.0.3
3
+ Version: 0.0.4
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
@@ -67,10 +67,21 @@ tgdata supports 1 authentication at the moment.
67
67
  api_id = 1234566
68
68
  api_hash = a24adjfakjdfakjshdflkajsbdflk
69
69
  phone = +905064004949 # use full phone number including + and country code
70
- username = 'powerpuffdude'
71
70
 
71
+ # Where the Telethon session lives (".session" is appended automatically).
72
+ # Use an ABSOLUTE path — a bare name creates the file in whatever directory
73
+ # the process happens to run from. Do not quote values: INI values are raw
74
+ # text, so quotes become part of the value (tgdata strips them defensively
75
+ # since 0.0.4, but don't rely on it).
76
+ session_file = /absolute/path/to/my_session
72
77
  ```
73
78
 
79
+ **Session naming precedence** (since 0.0.4): an explicit `session_file`
80
+ always wins. A legacy `username` key is used as the session name only when
81
+ no `session_file` is set — configs that relied on username-named sessions
82
+ keep working, but new configs should set `session_file` and omit `username`
83
+ (it plays no part in authentication).
84
+
74
85
 
75
86
  ## Quick Start
76
87
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes