Repository navigation
Expand file tree
/
Copy pathcomment.py
More file actions
338 lines (295 loc) · 11.9 KB
/
Copy pathcomment.py
File metadata and controls
338 lines (295 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
import requests
import logging
from time import sleep
import random
from threading import Thread
import subprocess
from termcolor import colored
import os
import zipfile
import platform
import stat
from bs4 import BeautifulSoup
import urllib3
import json
# Disable SSL verification warnings
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
logging.warning(colored("SSL certificate verification is disabled. This makes the connection less secure.", "yellow"))
""" VARS """
MINTS = [
'HQjeQwC8syhw31pipi8Ad4fKDfRKfhHN4YGHDpWGpump'
]
PRINT_ERROR = True
COMMENT_PER_TOKEN = 1
DISABLE_PROXIES = False
""" LOGGING """
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - [%(levelname)s] %(message)s',
datefmt='%H:%M:%S'
)
""" SRC """
def post_comment(tokens, proxies, comment, mint):
global DISABLE_PROXIES
if DISABLE_PROXIES == False:
current_proxy = random.choice(proxies)
proxies = {
'http': f'http://{current_proxy}',
'https': f'http://{current_proxy}',
}
url = "https://client-proxy-server.pump.fun/comment"
headers = {
"accept": "*/*",
"accept-language": "en-US,en;q=0.8",
"content-type": "application/json",
"origin": "https://pump.fun",
"priority": "u=1, i",
"referer": "https://pump.fun/",
"sec-ch-ua": '"Brave";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"sec-gpc": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)",
"x-aws-proxy-token": random.choice(tokens)
}
data = {
"text": comment,
"mint": mint
}
x = 0
while x <= 5:
x+=1
try:
if DISABLE_PROXIES == False:
response = requests.post(url, json=data, headers=headers, proxies=proxies)
else:
response = requests.post(url, json=data, headers=headers)
response_status_code = response.status_code
if response_status_code == 200:
logging.info(colored("Successfully commented on mint " + mint, "green"))
break
else:
return
except Exception as e:
if PRINT_ERROR == True:
logging.error(colored(f"Error commenting on mint {mint} - Unknown error: {e}", "red"))
def find_new_mint(proxies):
global DISABLE_PROXIES
mint = ""
if DISABLE_PROXIES == False:
current_proxy = random.choice(proxies)
proxies = {
'http': f'http://{current_proxy}',
'https': f'http://{current_proxy}',
}
try:
if DISABLE_PROXIES == False:
resp = requests.get("https://frontend-api.pump.fun/coins/latest", proxies=proxies, verify=False)
else:
resp = requests.get("https://frontend-api.pump.fun/coins/latest", verify=False)
if resp.status_code == 200:
try:
data = resp.json()
mint = data["mint"]
except json.JSONDecodeError as je:
raise je
logging.error(colored(f"JSON decode error in find_new_mint: {str(je)}\nResponse text: {resp.text[:200]}", "red"))
except KeyError as ke:
raise ke
logging.error(colored(f"Key 'mint' not found in response: {str(ke)}", "red"))
except Exception as ex:
raise ex
if PRINT_ERROR:
logging.error(colored(f"Error in find_new_mint: {str(ex)}", "red"))
return mint
def download_chromedriver():
# Get the latest version for mac
version_url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE"
latest_version = requests.get(version_url).text.strip()
# Determine download URL based on system
if platform.system().lower() == "darwin": # macOS
if "arm" in platform.machine().lower() or "aarch64" in platform.machine().lower():
platform_name = "mac_arm64"
else:
platform_name = "mac64"
elif platform.system().lower() == "windows":
platform_name = "win32"
else: # Linux
platform_name = "linux64"
download_url = f"https://chromedriver.storage.googleapis.com/{latest_version}/chromedriver_{platform_name}.zip"
# Download the file
logging.info(colored("Downloading ChromeDriver...", "yellow"))
response = requests.get(download_url)
# Save the zip file
script_dir = os.path.dirname(os.path.abspath(__file__))
zip_path = os.path.join(script_dir, "chromedriver.zip")
with open(zip_path, "wb") as f:
f.write(response.content)
# Extract the zip file
with zipfile.ZipFile(zip_path, "r") as zip_ref:
zip_ref.extractall(script_dir)
# Remove the zip file
os.remove(zip_path)
# Make the chromedriver executable on Unix systems
if platform.system().lower() != "windows":
chromedriver_path = os.path.join(script_dir, "chromedriver")
st = os.stat(chromedriver_path)
os.chmod(chromedriver_path, st.st_mode | stat.S_IEXEC)
logging.info(colored("ChromeDriver downloaded and installed successfully!", "green"))
def start_chromedriver():
script_dir = os.path.dirname(os.path.abspath(__file__))
if os.name == 'nt': # Windows
chromedriver_path = os.path.join(script_dir, "chromedriver.exe")
else: # Unix-like systems (Linux, macOS)
chromedriver_path = os.path.join(script_dir, "chromedriver")
# If chromedriver doesn't exist in the script directory, download it
if not os.path.exists(chromedriver_path):
try:
# First try to find system installation
system_driver = subprocess.check_output(['which', 'chromedriver']).decode().strip()
chromedriver_path = system_driver
except subprocess.CalledProcessError:
# If not found, download it
logging.info(colored("ChromeDriver not found. Downloading...", "yellow"))
download_chromedriver()
try:
if os.name == 'nt': # Windows
process = subprocess.Popen(
[chromedriver_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
creationflags=subprocess.CREATE_NO_WINDOW,
start_new_session=True
)
else: # Unix-like systems
process = subprocess.Popen(
[chromedriver_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
start_new_session=True
)
return process
except Exception as e:
logging.error(colored(f"Error starting ChromeDriver: {str(e)}", "red"))
raise
def load_sessions():
tokens = []
with open("tokens.txt", "r") as f:
lines = f.read().split("\n")
for line in lines:
if line not in tokens and len(line) > 2:
tokens.append(line.replace(" ", "").replace("\n", "").replace("\r", "").strip())
return tokens
def get_free_proxies():
# First try to load existing proxies from file
try:
with open("proxies.txt", "r") as f:
existing_proxies = [line.strip() for line in f.readlines() if len(line.strip()) > 2]
if existing_proxies:
logging.info(colored(f"Loaded {len(existing_proxies)} proxies from file", "blue"))
return existing_proxies
except FileNotFoundError:
pass
logging.info(colored("Fetching free proxies...", "yellow"))
proxies = set()
# Source 1: proxyscrape.com
try:
response = requests.get('https://api.proxyscrape.com/v2/?request=getproxies&protocol=http&timeout=10000&country=all&ssl=all&anonymity=all')
if response.status_code == 200:
proxies.update(response.text.strip().split('\n'))
except:
pass
# Source 2: free-proxy-list.net
try:
response = requests.get('https://free-proxy-list.net/')
if response.status_code == 200:
soup = BeautifulSoup(response.text, 'html.parser')
table = soup.find('table')
for row in table.find_all('tr')[1:]: # Skip header row
cols = row.find_all('td')
if len(cols) >= 2:
ip = cols[0].text.strip()
port = cols[1].text.strip()
proxies.add(f'{ip}:{port}')
except:
pass
# Source 3: geonode.com
try:
response = requests.get('https://proxylist.geonode.com/api/proxy-list?limit=100&page=1&sort_by=lastChecked&sort_type=desc&protocols=http%2Chttps')
if response.status_code == 200:
data = response.json()
for proxy in data.get('data', []):
proxies.add(f"{proxy['ip']}:{proxy['port']}")
except:
pass
# Validate proxies
valid_proxies = []
logging.info(colored(f"Testing {len(proxies)} proxies...", "yellow"))
for proxy in proxies:
try:
proxy_dict = {
'http': f'http://{proxy}',
'https': f'http://{proxy}'
}
response = requests.get('https://frontend-api.pump.fun/coins/latest',
proxies=proxy_dict,
verify=False,
timeout=5)
if response.status_code == 200:
valid_proxies.append(proxy)
logging.info(colored(f"Valid proxy found: {proxy}", "green"))
except:
continue
# Save valid proxies to file
if valid_proxies:
with open("proxies.txt", "w") as f:
f.write('\n'.join(valid_proxies))
logging.info(colored(f"Saved {len(valid_proxies)} proxies to file", "green"))
return valid_proxies
def load_comments():
comments = []
with open("comments.txt", "r") as f:
lines = f.read().split("\n")
for line in lines:
if line not in comments and len(line) > 2:
comments.append(line)
return comments
def refresh_proxies():
global proxies
while True:
sleep(300) # Refresh every 5 minutes
try:
new_proxies = get_free_proxies()
if new_proxies:
proxies = new_proxies
logging.info(colored(f"Refreshed proxies. Now using {len(proxies)} proxies", "blue"))
except Exception as e:
logging.error(colored(f"Error refreshing proxies: {str(e)}", "red"))
def main():
global DISABLE_PROXIES
Thread(target=(start_chromedriver)).start()
tokens = load_sessions()
proxies = get_free_proxies()
comments = load_comments()
if len(proxies) == 0:
DISABLE_PROXIES = True
logging.info(colored("Loaded: " + str(len(tokens)) + " tokens - " + str(len(proxies)) + " proxies - " + str(len(comments)) + " comments", "blue"))
# Start proxy refresh thread
Thread(target=refresh_proxies, daemon=True).start()
while True:
mint = find_new_mint(proxies)
print(mint)
if mint != "":
if not mint in MINTS:
MINTS.append(mint)
for comment in comments:
x = 0
while x < COMMENT_PER_TOKEN:
Thread(target=(post_comment), args=(tokens, proxies, comment, mint)).start()
x+=1
sleep(0.2)
if __name__ == "__main__":
main()