codex-tgmember 1.0.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 K.NIRMAL
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: codex-tgmember
3
+ Version: 1.0.0
4
+ Summary: A CLI tool to scrape and add members in Telegram groups using the Telethon library.
5
+ Author: K.NIRMAL
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/kAWDHITHA-NIRMAL/codex-tgmember
8
+ Project-URL: Bug Tracker, https://github.com/kAWDHITHA-NIRMAL/codex-tgmember/issues
9
+ Keywords: telegram,scraper,members,telethon,group
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Topic :: Communications :: Chat
14
+ Classifier: Topic :: Utilities
15
+ Requires-Python: >=3.7
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: telethon>=1.34.0
19
+ Dynamic: license-file
20
+
21
+ # codex-tgmember šŸ”­
22
+
23
+ > **āš ļø For educational purposes only. Use responsibly and in compliance with [Telegram's Terms of Service](https://telegram.org/tos).**
24
+
25
+ A Python package to **scrape members** from Telegram groups and **add them** to your own group — powered by [Telethon](https://docs.telethon.dev/).
26
+
27
+ ---
28
+
29
+ ## ✨ Features
30
+
31
+ | Feature | Description |
32
+ |---|---|
33
+ | šŸ“‹ **Scrape Members** | Export all visible group members to a CSV file |
34
+ | āž• **Add Members** | Bulk-add users from CSV by username or Telegram ID |
35
+ | šŸ“‚ **CSV Viewer** | Display any member CSV file in the terminal |
36
+ | šŸ” **2FA Support** | Handles two-step verification automatically |
37
+ | šŸ›”ļø **Safe Fallback** | Falls back gracefully when admin rights are missing |
38
+
39
+ ---
40
+
41
+ ## šŸ“¦ Installation
42
+
43
+ ### From PyPI *(after publishing)*
44
+ ```bash
45
+ pip install codex-tgmember
46
+ ```
47
+
48
+ ### From source (local)
49
+ ```bash
50
+ cd pack/
51
+ pip install .
52
+ ```
53
+
54
+ ---
55
+
56
+ ## šŸ”‘ Prerequisites
57
+
58
+ 1. **Python 3.7+**
59
+ 2. A **Telegram account** with a phone number
60
+ 3. **API credentials** from [my.telegram.org](https://my.telegram.org):
61
+ - Go to **API development tools**
62
+ - Create an app → copy `api_id` and `api_hash`
63
+
64
+ ---
65
+
66
+ ## āš™ļø Configuration
67
+
68
+ ### Option A — Use as a Python library
69
+
70
+ ```python
71
+ from tg_member_tool import TelegramMemberTool
72
+
73
+ tool = TelegramMemberTool(
74
+ api_id=12345678, # your API ID
75
+ api_hash='your_api_hash', # your API Hash
76
+ phone='+94707728716' # your phone with country code
77
+ )
78
+
79
+ # Start interactive menu
80
+ tool.run()
81
+ ```
82
+
83
+ ### Option B — Edit `cli.py` and use the command line
84
+
85
+ Open `pack/tg_member_tool/cli.py` and fill in your credentials:
86
+
87
+ ```python
88
+ API_ID = 12345678
89
+ API_HASH = 'your_api_hash_here'
90
+ PHONE = '+94707728716'
91
+ ```
92
+
93
+ Then run:
94
+
95
+ ```bash
96
+ tg-member-tool
97
+ ```
98
+
99
+ ---
100
+
101
+ ## šŸš€ Usage
102
+
103
+ ### Interactive Menu
104
+
105
+ ```
106
+ ╔══════════════════════════════╗
107
+ ā•‘ Telegram Member Tool ā•‘
108
+ ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
109
+
110
+ 1. Scrape group members → CSV
111
+ 2. Add members from CSV
112
+ 3. Display CSV file
113
+
114
+ Select option:
115
+ ```
116
+
117
+ ---
118
+
119
+ ### 1ļøāƒ£ Scrape Members → CSV
120
+
121
+ ```python
122
+ tool.scrape_members()
123
+ # or pass index directly (no prompt):
124
+ tool.scrape_members(group_index=5)
125
+ ```
126
+
127
+ Output file: `members-groupname.csv`
128
+
129
+ ```
130
+ username,user_id,access_hash,name,group,group_id
131
+ john_doe,123456789,9876543210987654321,John Doe,My Group,1001234567
132
+ ```
133
+
134
+ ---
135
+
136
+ ### 2ļøāƒ£ Add Members from CSV
137
+
138
+ ```python
139
+ tool.add_members('members-my-group.csv')
140
+ # or specify group and method directly:
141
+ tool.add_members('members.csv', group_index=2, method=1)
142
+ ```
143
+
144
+ **CSV format required:**
145
+ ```csv
146
+ username,user_id,access_hash
147
+ john_doe,123456789,9876543210987654321
148
+ jane_doe,987654321,1234567890123456789
149
+ ```
150
+
151
+ **Add methods:**
152
+ - `1` — by **username** (more reliable, requires user to have a username)
153
+ - `2` — by **Telegram ID** (works even without a username)
154
+
155
+ ---
156
+
157
+ ### 3ļøāƒ£ Display CSV File
158
+
159
+ ```python
160
+ tool.display_csv('members-my-group.csv')
161
+ ```
162
+
163
+ ---
164
+
165
+ ## šŸ“ Package Structure
166
+
167
+ ```
168
+ pack/
169
+ ā”œā”€ā”€ pyproject.toml ← Package config & metadata
170
+ ā”œā”€ā”€ LICENSE
171
+ ā”œā”€ā”€ README.md
172
+ └── tg_member_tool/
173
+ ā”œā”€ā”€ __init__.py ← Package entry, exports TelegramMemberTool
174
+ ā”œā”€ā”€ core.py ← Main TelegramMemberTool class
175
+ └── cli.py ← `tg-member-tool` command entry point
176
+ ```
177
+
178
+ ---
179
+
180
+ ## āš ļø Common Errors & Fixes
181
+
182
+ | Error | Cause | Fix |
183
+ |---|---|---|
184
+ | `SessionPasswordNeededError` | 2FA is enabled | Enter your 2FA password when prompted |
185
+ | `ChatAdminRequiredError` | Not admin of the group | Choose a group where you are admin |
186
+ | `PeerFloodError` | Too many requests | Wait several hours before trying again |
187
+ | `UserPrivacyRestrictedError` | User has privacy on | User is skipped automatically |
188
+ | `AuthRestartError` | Telegram internal issue | Re-run the script |
189
+
190
+ ---
191
+
192
+ ## šŸ” Security Notes
193
+
194
+ - šŸ”‘ **Never share** your `api_id`, `api_hash`, or `.session` file
195
+ - āŒ **Never commit** credentials to GitHub — add them to `.gitignore`
196
+ - ā³ Respect Telegram's rate limits: [limits.tginfo.me](https://limits.tginfo.me/en)
197
+ - šŸ‘„ Only add users who have **consented** to join groups
198
+
199
+ ---
200
+
201
+ ## šŸ“œ Disclaimer
202
+
203
+ This tool is provided **for educational purposes only**. The author is not responsible for:
204
+ - Account bans due to aggressive API use
205
+ - Privacy violations or spam complaints
206
+ - Any misuse of this software
207
+
208
+ Always comply with [Telegram's Terms of Service](https://telegram.org/tos).
209
+
210
+ ---
211
+
212
+ ## šŸ“„ License
213
+
214
+ MIT Ā© K.NIRMAL
@@ -0,0 +1,194 @@
1
+ # codex-tgmember šŸ”­
2
+
3
+ > **āš ļø For educational purposes only. Use responsibly and in compliance with [Telegram's Terms of Service](https://telegram.org/tos).**
4
+
5
+ A Python package to **scrape members** from Telegram groups and **add them** to your own group — powered by [Telethon](https://docs.telethon.dev/).
6
+
7
+ ---
8
+
9
+ ## ✨ Features
10
+
11
+ | Feature | Description |
12
+ |---|---|
13
+ | šŸ“‹ **Scrape Members** | Export all visible group members to a CSV file |
14
+ | āž• **Add Members** | Bulk-add users from CSV by username or Telegram ID |
15
+ | šŸ“‚ **CSV Viewer** | Display any member CSV file in the terminal |
16
+ | šŸ” **2FA Support** | Handles two-step verification automatically |
17
+ | šŸ›”ļø **Safe Fallback** | Falls back gracefully when admin rights are missing |
18
+
19
+ ---
20
+
21
+ ## šŸ“¦ Installation
22
+
23
+ ### From PyPI *(after publishing)*
24
+ ```bash
25
+ pip install codex-tgmember
26
+ ```
27
+
28
+ ### From source (local)
29
+ ```bash
30
+ cd pack/
31
+ pip install .
32
+ ```
33
+
34
+ ---
35
+
36
+ ## šŸ”‘ Prerequisites
37
+
38
+ 1. **Python 3.7+**
39
+ 2. A **Telegram account** with a phone number
40
+ 3. **API credentials** from [my.telegram.org](https://my.telegram.org):
41
+ - Go to **API development tools**
42
+ - Create an app → copy `api_id` and `api_hash`
43
+
44
+ ---
45
+
46
+ ## āš™ļø Configuration
47
+
48
+ ### Option A — Use as a Python library
49
+
50
+ ```python
51
+ from tg_member_tool import TelegramMemberTool
52
+
53
+ tool = TelegramMemberTool(
54
+ api_id=12345678, # your API ID
55
+ api_hash='your_api_hash', # your API Hash
56
+ phone='+94707728716' # your phone with country code
57
+ )
58
+
59
+ # Start interactive menu
60
+ tool.run()
61
+ ```
62
+
63
+ ### Option B — Edit `cli.py` and use the command line
64
+
65
+ Open `pack/tg_member_tool/cli.py` and fill in your credentials:
66
+
67
+ ```python
68
+ API_ID = 12345678
69
+ API_HASH = 'your_api_hash_here'
70
+ PHONE = '+94707728716'
71
+ ```
72
+
73
+ Then run:
74
+
75
+ ```bash
76
+ tg-member-tool
77
+ ```
78
+
79
+ ---
80
+
81
+ ## šŸš€ Usage
82
+
83
+ ### Interactive Menu
84
+
85
+ ```
86
+ ╔══════════════════════════════╗
87
+ ā•‘ Telegram Member Tool ā•‘
88
+ ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
89
+
90
+ 1. Scrape group members → CSV
91
+ 2. Add members from CSV
92
+ 3. Display CSV file
93
+
94
+ Select option:
95
+ ```
96
+
97
+ ---
98
+
99
+ ### 1ļøāƒ£ Scrape Members → CSV
100
+
101
+ ```python
102
+ tool.scrape_members()
103
+ # or pass index directly (no prompt):
104
+ tool.scrape_members(group_index=5)
105
+ ```
106
+
107
+ Output file: `members-groupname.csv`
108
+
109
+ ```
110
+ username,user_id,access_hash,name,group,group_id
111
+ john_doe,123456789,9876543210987654321,John Doe,My Group,1001234567
112
+ ```
113
+
114
+ ---
115
+
116
+ ### 2ļøāƒ£ Add Members from CSV
117
+
118
+ ```python
119
+ tool.add_members('members-my-group.csv')
120
+ # or specify group and method directly:
121
+ tool.add_members('members.csv', group_index=2, method=1)
122
+ ```
123
+
124
+ **CSV format required:**
125
+ ```csv
126
+ username,user_id,access_hash
127
+ john_doe,123456789,9876543210987654321
128
+ jane_doe,987654321,1234567890123456789
129
+ ```
130
+
131
+ **Add methods:**
132
+ - `1` — by **username** (more reliable, requires user to have a username)
133
+ - `2` — by **Telegram ID** (works even without a username)
134
+
135
+ ---
136
+
137
+ ### 3ļøāƒ£ Display CSV File
138
+
139
+ ```python
140
+ tool.display_csv('members-my-group.csv')
141
+ ```
142
+
143
+ ---
144
+
145
+ ## šŸ“ Package Structure
146
+
147
+ ```
148
+ pack/
149
+ ā”œā”€ā”€ pyproject.toml ← Package config & metadata
150
+ ā”œā”€ā”€ LICENSE
151
+ ā”œā”€ā”€ README.md
152
+ └── tg_member_tool/
153
+ ā”œā”€ā”€ __init__.py ← Package entry, exports TelegramMemberTool
154
+ ā”œā”€ā”€ core.py ← Main TelegramMemberTool class
155
+ └── cli.py ← `tg-member-tool` command entry point
156
+ ```
157
+
158
+ ---
159
+
160
+ ## āš ļø Common Errors & Fixes
161
+
162
+ | Error | Cause | Fix |
163
+ |---|---|---|
164
+ | `SessionPasswordNeededError` | 2FA is enabled | Enter your 2FA password when prompted |
165
+ | `ChatAdminRequiredError` | Not admin of the group | Choose a group where you are admin |
166
+ | `PeerFloodError` | Too many requests | Wait several hours before trying again |
167
+ | `UserPrivacyRestrictedError` | User has privacy on | User is skipped automatically |
168
+ | `AuthRestartError` | Telegram internal issue | Re-run the script |
169
+
170
+ ---
171
+
172
+ ## šŸ” Security Notes
173
+
174
+ - šŸ”‘ **Never share** your `api_id`, `api_hash`, or `.session` file
175
+ - āŒ **Never commit** credentials to GitHub — add them to `.gitignore`
176
+ - ā³ Respect Telegram's rate limits: [limits.tginfo.me](https://limits.tginfo.me/en)
177
+ - šŸ‘„ Only add users who have **consented** to join groups
178
+
179
+ ---
180
+
181
+ ## šŸ“œ Disclaimer
182
+
183
+ This tool is provided **for educational purposes only**. The author is not responsible for:
184
+ - Account bans due to aggressive API use
185
+ - Privacy violations or spam complaints
186
+ - Any misuse of this software
187
+
188
+ Always comply with [Telegram's Terms of Service](https://telegram.org/tos).
189
+
190
+ ---
191
+
192
+ ## šŸ“„ License
193
+
194
+ MIT Ā© K.NIRMAL
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: codex-tgmember
3
+ Version: 1.0.0
4
+ Summary: A CLI tool to scrape and add members in Telegram groups using the Telethon library.
5
+ Author: K.NIRMAL
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/kAWDHITHA-NIRMAL/codex-tgmember
8
+ Project-URL: Bug Tracker, https://github.com/kAWDHITHA-NIRMAL/codex-tgmember/issues
9
+ Keywords: telegram,scraper,members,telethon,group
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Topic :: Communications :: Chat
14
+ Classifier: Topic :: Utilities
15
+ Requires-Python: >=3.7
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: telethon>=1.34.0
19
+ Dynamic: license-file
20
+
21
+ # codex-tgmember šŸ”­
22
+
23
+ > **āš ļø For educational purposes only. Use responsibly and in compliance with [Telegram's Terms of Service](https://telegram.org/tos).**
24
+
25
+ A Python package to **scrape members** from Telegram groups and **add them** to your own group — powered by [Telethon](https://docs.telethon.dev/).
26
+
27
+ ---
28
+
29
+ ## ✨ Features
30
+
31
+ | Feature | Description |
32
+ |---|---|
33
+ | šŸ“‹ **Scrape Members** | Export all visible group members to a CSV file |
34
+ | āž• **Add Members** | Bulk-add users from CSV by username or Telegram ID |
35
+ | šŸ“‚ **CSV Viewer** | Display any member CSV file in the terminal |
36
+ | šŸ” **2FA Support** | Handles two-step verification automatically |
37
+ | šŸ›”ļø **Safe Fallback** | Falls back gracefully when admin rights are missing |
38
+
39
+ ---
40
+
41
+ ## šŸ“¦ Installation
42
+
43
+ ### From PyPI *(after publishing)*
44
+ ```bash
45
+ pip install codex-tgmember
46
+ ```
47
+
48
+ ### From source (local)
49
+ ```bash
50
+ cd pack/
51
+ pip install .
52
+ ```
53
+
54
+ ---
55
+
56
+ ## šŸ”‘ Prerequisites
57
+
58
+ 1. **Python 3.7+**
59
+ 2. A **Telegram account** with a phone number
60
+ 3. **API credentials** from [my.telegram.org](https://my.telegram.org):
61
+ - Go to **API development tools**
62
+ - Create an app → copy `api_id` and `api_hash`
63
+
64
+ ---
65
+
66
+ ## āš™ļø Configuration
67
+
68
+ ### Option A — Use as a Python library
69
+
70
+ ```python
71
+ from tg_member_tool import TelegramMemberTool
72
+
73
+ tool = TelegramMemberTool(
74
+ api_id=12345678, # your API ID
75
+ api_hash='your_api_hash', # your API Hash
76
+ phone='+94707728716' # your phone with country code
77
+ )
78
+
79
+ # Start interactive menu
80
+ tool.run()
81
+ ```
82
+
83
+ ### Option B — Edit `cli.py` and use the command line
84
+
85
+ Open `pack/tg_member_tool/cli.py` and fill in your credentials:
86
+
87
+ ```python
88
+ API_ID = 12345678
89
+ API_HASH = 'your_api_hash_here'
90
+ PHONE = '+94707728716'
91
+ ```
92
+
93
+ Then run:
94
+
95
+ ```bash
96
+ tg-member-tool
97
+ ```
98
+
99
+ ---
100
+
101
+ ## šŸš€ Usage
102
+
103
+ ### Interactive Menu
104
+
105
+ ```
106
+ ╔══════════════════════════════╗
107
+ ā•‘ Telegram Member Tool ā•‘
108
+ ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
109
+
110
+ 1. Scrape group members → CSV
111
+ 2. Add members from CSV
112
+ 3. Display CSV file
113
+
114
+ Select option:
115
+ ```
116
+
117
+ ---
118
+
119
+ ### 1ļøāƒ£ Scrape Members → CSV
120
+
121
+ ```python
122
+ tool.scrape_members()
123
+ # or pass index directly (no prompt):
124
+ tool.scrape_members(group_index=5)
125
+ ```
126
+
127
+ Output file: `members-groupname.csv`
128
+
129
+ ```
130
+ username,user_id,access_hash,name,group,group_id
131
+ john_doe,123456789,9876543210987654321,John Doe,My Group,1001234567
132
+ ```
133
+
134
+ ---
135
+
136
+ ### 2ļøāƒ£ Add Members from CSV
137
+
138
+ ```python
139
+ tool.add_members('members-my-group.csv')
140
+ # or specify group and method directly:
141
+ tool.add_members('members.csv', group_index=2, method=1)
142
+ ```
143
+
144
+ **CSV format required:**
145
+ ```csv
146
+ username,user_id,access_hash
147
+ john_doe,123456789,9876543210987654321
148
+ jane_doe,987654321,1234567890123456789
149
+ ```
150
+
151
+ **Add methods:**
152
+ - `1` — by **username** (more reliable, requires user to have a username)
153
+ - `2` — by **Telegram ID** (works even without a username)
154
+
155
+ ---
156
+
157
+ ### 3ļøāƒ£ Display CSV File
158
+
159
+ ```python
160
+ tool.display_csv('members-my-group.csv')
161
+ ```
162
+
163
+ ---
164
+
165
+ ## šŸ“ Package Structure
166
+
167
+ ```
168
+ pack/
169
+ ā”œā”€ā”€ pyproject.toml ← Package config & metadata
170
+ ā”œā”€ā”€ LICENSE
171
+ ā”œā”€ā”€ README.md
172
+ └── tg_member_tool/
173
+ ā”œā”€ā”€ __init__.py ← Package entry, exports TelegramMemberTool
174
+ ā”œā”€ā”€ core.py ← Main TelegramMemberTool class
175
+ └── cli.py ← `tg-member-tool` command entry point
176
+ ```
177
+
178
+ ---
179
+
180
+ ## āš ļø Common Errors & Fixes
181
+
182
+ | Error | Cause | Fix |
183
+ |---|---|---|
184
+ | `SessionPasswordNeededError` | 2FA is enabled | Enter your 2FA password when prompted |
185
+ | `ChatAdminRequiredError` | Not admin of the group | Choose a group where you are admin |
186
+ | `PeerFloodError` | Too many requests | Wait several hours before trying again |
187
+ | `UserPrivacyRestrictedError` | User has privacy on | User is skipped automatically |
188
+ | `AuthRestartError` | Telegram internal issue | Re-run the script |
189
+
190
+ ---
191
+
192
+ ## šŸ” Security Notes
193
+
194
+ - šŸ”‘ **Never share** your `api_id`, `api_hash`, or `.session` file
195
+ - āŒ **Never commit** credentials to GitHub — add them to `.gitignore`
196
+ - ā³ Respect Telegram's rate limits: [limits.tginfo.me](https://limits.tginfo.me/en)
197
+ - šŸ‘„ Only add users who have **consented** to join groups
198
+
199
+ ---
200
+
201
+ ## šŸ“œ Disclaimer
202
+
203
+ This tool is provided **for educational purposes only**. The author is not responsible for:
204
+ - Account bans due to aggressive API use
205
+ - Privacy violations or spam complaints
206
+ - Any misuse of this software
207
+
208
+ Always comply with [Telegram's Terms of Service](https://telegram.org/tos).
209
+
210
+ ---
211
+
212
+ ## šŸ“„ License
213
+
214
+ MIT Ā© K.NIRMAL
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ codex_tgmember.egg-info/PKG-INFO
5
+ codex_tgmember.egg-info/SOURCES.txt
6
+ codex_tgmember.egg-info/dependency_links.txt
7
+ codex_tgmember.egg-info/entry_points.txt
8
+ codex_tgmember.egg-info/requires.txt
9
+ codex_tgmember.egg-info/top_level.txt
10
+ tg_member_tool/__init__.py
11
+ tg_member_tool/cli.py
12
+ tg_member_tool/core.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ codex-tgmember = tg_member_tool.cli:main
@@ -0,0 +1 @@
1
+ telethon>=1.34.0
@@ -0,0 +1 @@
1
+ tg_member_tool
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "codex-tgmember"
7
+ version = "1.0.0"
8
+ description = "A CLI tool to scrape and add members in Telegram groups using the Telethon library."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [
12
+ { name = "K.NIRMAL" }
13
+ ]
14
+ keywords = ["telegram", "scraper", "members", "telethon", "group"]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Topic :: Communications :: Chat",
20
+ "Topic :: Utilities",
21
+ ]
22
+ requires-python = ">=3.7"
23
+ dependencies = [
24
+ "telethon>=1.34.0",
25
+ ]
26
+
27
+ [project.urls]
28
+ "Homepage" = "https://github.com/kAWDHITHA-NIRMAL/codex-tgmember"
29
+ "Bug Tracker" = "https://github.com/kAWDHITHA-NIRMAL/codex-tgmember/issues"
30
+
31
+ [project.scripts]
32
+ codex-tgmember = "tg_member_tool.cli:main"
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["."]
36
+ include = ["tg_member_tool*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+ """
2
+ tg_member_tool - Telegram Group Member Scraper & Adder
3
+ """
4
+
5
+ __version__ = "1.0.0"
6
+ __author__ = "K.NIRMAL"
7
+ __license__ = "MIT"
8
+
9
+ from .core import TelegramMemberTool
10
+
11
+ __all__ = ["TelegramMemberTool"]
@@ -0,0 +1,26 @@
1
+ """
2
+ cli.py - Command-line entry point for tg-member-tool
3
+ """
4
+
5
+ import sys
6
+ from tg_member_tool import TelegramMemberTool
7
+
8
+
9
+ def main():
10
+ """Entry point invoked by `tg-member-tool` command after pip install."""
11
+
12
+ # These must be set by the user before using the package
13
+ API_ID = 0 # ← Replace with your API ID
14
+ API_HASH = 'your_api_hash' # ← Replace with your API Hash
15
+ PHONE = '+your_phone' # ← Replace with your phone number
16
+
17
+ if API_ID == 0 or API_HASH == 'your_api_hash':
18
+ print('āŒ Please set your API_ID, API_HASH, and PHONE in cli.py before running.')
19
+ sys.exit(1)
20
+
21
+ tool = TelegramMemberTool(api_id=API_ID, api_hash=API_HASH, phone=PHONE)
22
+ tool.run()
23
+
24
+
25
+ if __name__ == '__main__':
26
+ main()
@@ -0,0 +1,265 @@
1
+ """
2
+ core.py - Main logic for TelegramMemberTool
3
+ """
4
+
5
+ import csv
6
+ import re
7
+ import sys
8
+ import time
9
+ import traceback
10
+
11
+ from telethon.sync import TelegramClient
12
+ from telethon.tl.functions.channels import InviteToChannelRequest
13
+ from telethon.tl.functions.messages import GetDialogsRequest
14
+ from telethon.tl.types import InputPeerChannel, InputPeerEmpty, InputPeerUser
15
+ from telethon.errors.rpcerrorlist import PeerFloodError, UserPrivacyRestrictedError
16
+
17
+
18
+ class TelegramMemberTool:
19
+ """
20
+ A tool to scrape and add members in Telegram groups.
21
+
22
+ Args:
23
+ api_id (int): Your Telegram API ID from https://my.telegram.org
24
+ api_hash (str): Your Telegram API Hash from https://my.telegram.org
25
+ phone (str): Your phone number with country code (e.g. '+94707728716')
26
+
27
+ Example::
28
+
29
+ from tg_member_tool import TelegramMemberTool
30
+
31
+ tool = TelegramMemberTool(
32
+ api_id=12345678,
33
+ api_hash='your_api_hash_here',
34
+ phone='+94707728716'
35
+ )
36
+ tool.run()
37
+ """
38
+
39
+ def __init__(self, api_id: int, api_hash: str, phone: str):
40
+ self.phone = phone
41
+ self.client = TelegramClient(phone, api_id, api_hash)
42
+
43
+ # ------------------------------------------------------------------
44
+ # Authentication
45
+ # ------------------------------------------------------------------
46
+
47
+ def connect(self):
48
+ """Connect and authenticate. Handles SMS code and 2FA password."""
49
+ self.client.connect()
50
+ if not self.client.is_user_authorized():
51
+ self.client.send_code_request(self.phone)
52
+ try:
53
+ self.client.sign_in(self.phone, input('Enter verification code: '))
54
+ except Exception as e:
55
+ if 'SessionPasswordNeededError' in type(e).__name__:
56
+ self.client.sign_in(
57
+ password=input('2FA password required. Enter password: ')
58
+ )
59
+ else:
60
+ raise
61
+
62
+ # ------------------------------------------------------------------
63
+ # Core features
64
+ # ------------------------------------------------------------------
65
+
66
+ def list_chats(self):
67
+ """Return a list of all chats/groups the account is part of."""
68
+ result = self.client(GetDialogsRequest(
69
+ offset_date=None,
70
+ offset_id=0,
71
+ offset_peer=InputPeerEmpty(),
72
+ limit=200,
73
+ hash=0
74
+ ))
75
+ return result.chats
76
+
77
+ def scrape_members(self, group_index: int = None) -> str:
78
+ """
79
+ Scrape members from a group and save to CSV.
80
+
81
+ Args:
82
+ group_index (int, optional): Index of the group from the chats list.
83
+ If None, the user will be prompted.
84
+
85
+ Returns:
86
+ str: Path to the saved CSV file, or empty string on failure.
87
+ """
88
+ chats = self.list_chats()
89
+
90
+ if group_index is None:
91
+ print('\nAvailable chats:')
92
+ for idx, chat in enumerate(chats):
93
+ print(f' {idx}: {chat.title}')
94
+ group_index = int(input('\nEnter group number: '))
95
+
96
+ target_group = chats[group_index]
97
+ print(f'\nFetching members from: {target_group.title}')
98
+
99
+ participants = self._fetch_participants(target_group)
100
+ if participants is None:
101
+ return ''
102
+
103
+ filename = self._save_to_csv(participants, target_group)
104
+ print(f'āœ… Saved {len(participants)} members to {filename}')
105
+ return filename
106
+
107
+ def add_members(self, csv_file: str, group_index: int = None, method: int = None):
108
+ """
109
+ Add members from a CSV file to a group.
110
+
111
+ Args:
112
+ csv_file (str): Path to the CSV file (must have username, user_id, access_hash columns).
113
+ group_index (int, optional): Index of the target group. Prompts if None.
114
+ method (int, optional): 1 = by username, 2 = by ID. Prompts if None.
115
+ """
116
+ users = self._load_csv(csv_file)
117
+ if not users:
118
+ print('āŒ No valid users found in CSV.')
119
+ return
120
+
121
+ result = self.client(GetDialogsRequest(
122
+ offset_date=None,
123
+ offset_id=0,
124
+ offset_peer=InputPeerEmpty(),
125
+ limit=200,
126
+ hash=0
127
+ ))
128
+ groups = [c for c in result.chats if getattr(c, 'megagroup', False)]
129
+
130
+ if group_index is None:
131
+ print('\nAvailable groups (supergroups only):')
132
+ for idx, g in enumerate(groups):
133
+ print(f' {idx}: {g.title}')
134
+ group_index = int(input('\nEnter group number: '))
135
+
136
+ target_group = groups[group_index]
137
+ target_entity = InputPeerChannel(target_group.id, target_group.access_hash)
138
+
139
+ if method is None:
140
+ method = int(input('\nAdd method (1-by username, 2-by ID): '))
141
+
142
+ for user in users:
143
+ try:
144
+ print(f'Adding {user["username"] or user["id"]}...')
145
+ if method == 1:
146
+ user_entity = self.client.get_input_entity(user['username'])
147
+ elif method == 2:
148
+ user_entity = InputPeerUser(user['id'], user['access_hash'])
149
+ else:
150
+ print('Invalid method. Use 1 or 2.')
151
+ break
152
+
153
+ self.client(InviteToChannelRequest(target_entity, [user_entity]))
154
+ print(' āœ… Added. Waiting 60 seconds...')
155
+ time.sleep(60)
156
+
157
+ except PeerFloodError:
158
+ print('āš ļø Flood error — stopping to protect account. Try again later.')
159
+ break
160
+ except UserPrivacyRestrictedError:
161
+ print(f' āš ļø Privacy restricted. Skipping {user["username"]}.')
162
+ except Exception as e:
163
+ print(f' āŒ Error: {e}')
164
+ traceback.print_exc()
165
+
166
+ def display_csv(self, csv_file: str):
167
+ """Print contents of a CSV file to terminal."""
168
+ with open(csv_file, encoding='UTF-8') as f:
169
+ reader = csv.reader(f, delimiter=',', lineterminator='\n')
170
+ for row in reader:
171
+ print(row)
172
+
173
+ # ------------------------------------------------------------------
174
+ # Interactive menu
175
+ # ------------------------------------------------------------------
176
+
177
+ def run(self):
178
+ """Start the interactive CLI menu."""
179
+ self.connect()
180
+
181
+ print('\n╔══════════════════════════════╗')
182
+ print('ā•‘ Telegram Member Tool ā•‘')
183
+ print('ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•')
184
+
185
+ choice = int(input(
186
+ '\n 1. Scrape group members → CSV\n'
187
+ ' 2. Add members from CSV\n'
188
+ ' 3. Display CSV file\n'
189
+ '\n Select option: '
190
+ ))
191
+
192
+ if choice == 1:
193
+ self.scrape_members()
194
+ elif choice == 2:
195
+ if len(sys.argv) < 2:
196
+ csv_file = input('Enter path to CSV file: ')
197
+ else:
198
+ csv_file = sys.argv[1]
199
+ self.add_members(csv_file)
200
+ elif choice == 3:
201
+ if len(sys.argv) < 2:
202
+ csv_file = input('Enter path to CSV file: ')
203
+ else:
204
+ csv_file = sys.argv[1]
205
+ self.display_csv(csv_file)
206
+ else:
207
+ print('Invalid selection.')
208
+
209
+ # ------------------------------------------------------------------
210
+ # Private helpers
211
+ # ------------------------------------------------------------------
212
+
213
+ def _fetch_participants(self, target_group):
214
+ """Try aggressive fetch, fall back to standard. Returns None if both fail."""
215
+ try:
216
+ return self.client.get_participants(target_group, aggressive=True)
217
+ except Exception as e:
218
+ if 'ChatAdminRequiredError' not in type(e).__name__:
219
+ raise
220
+ print(' Aggressive fetch failed — trying standard fetch...')
221
+ try:
222
+ return self.client.get_participants(target_group)
223
+ except Exception as e2:
224
+ if 'ChatAdminRequiredError' in type(e2).__name__:
225
+ print(f'\nāŒ Cannot fetch members from "{target_group.title}".')
226
+ print(' This group hides its member list from non-admins.')
227
+ return None
228
+ raise
229
+
230
+ def _save_to_csv(self, participants, target_group) -> str:
231
+ """Save participants list to a CSV file and return the filename."""
232
+ sanitized = re.sub('[^a-z0-9]+', '-', target_group.title.lower()).strip('-')
233
+ filename = f'members-{sanitized}.csv'
234
+ with open(filename, 'w', encoding='UTF-8') as f:
235
+ writer = csv.writer(f, delimiter=',', lineterminator='\n')
236
+ writer.writerow(['username', 'user_id', 'access_hash', 'name', 'group', 'group_id'])
237
+ for user in participants:
238
+ name = ' '.join(filter(None, [user.first_name, user.last_name]))
239
+ writer.writerow([
240
+ user.username or '',
241
+ user.id,
242
+ user.access_hash,
243
+ name,
244
+ target_group.title,
245
+ target_group.id
246
+ ])
247
+ return filename
248
+
249
+ @staticmethod
250
+ def _load_csv(filepath: str) -> list:
251
+ """Load users from a CSV file. Returns list of dicts."""
252
+ users = []
253
+ with open(filepath, encoding='UTF-8') as f:
254
+ reader = csv.reader(f, delimiter=',', lineterminator='\n')
255
+ next(reader) # skip header
256
+ for row in reader:
257
+ if len(row) < 3:
258
+ print(' Skipping incomplete record.')
259
+ continue
260
+ users.append({
261
+ 'username': row[0],
262
+ 'id': int(row[1]) if row[1] else 0,
263
+ 'access_hash': int(row[2]) if row[2] else 0,
264
+ })
265
+ return users