eses 1.0.2__py3-none-any.whl → 1.0.4__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.
eses/__init__.py CHANGED
@@ -1,204 +1,106 @@
1
1
  import requests
2
2
  import time
3
- from itertools import cycle
4
3
  import threading
4
+ from typing import List
5
5
 
6
- class ESES:
7
- def __init__(self):
8
- # Default configuration
9
- self.api_url = "http://52.24.104.170:8086/RestSimulator"
10
- self.default_params = {
11
- "Operation": "postDonation",
12
- "available_patriotism": "0",
13
- "company_id": "4456964",
14
- "donation_sum": "100000000000",
15
- "donation_type": "0",
16
- "sender_company_id": "4456964",
17
- "user_id": "3CE57CF11AFA43A1ABB7DB10431C2234",
18
- "version_code": "22"
19
- }
6
+ api_url = "http://52.24.104.170:8086/RestSimulator"
7
+ proxies = []
8
+ proxy_lock = threading.Lock()
9
+ active_threads = []
20
10
 
21
- self.default_headers = {
22
- "Host": "52.24.104.170:8086",
23
- "Connection": "Keep-Alive",
24
- "User-Agent": "android-async-http",
25
- "Accept-Encoding": "gzip",
26
- "Content-Length": "0"
27
- }
11
+ def addproxy(proxy: str):
12
+ """Add a proxy (format: 'ip:port' or 'http://ip:port')"""
13
+ if not proxy.startswith(('http://', 'https://')):
14
+ proxy = f"http://{proxy}"
15
+ with proxy_lock:
16
+ if proxy not in proxies:
17
+ proxies.append(proxy)
18
+ print(f"Proxy added: {proxy}")
28
19
 
29
- # Proxy management
30
- self.proxies = []
31
- self.proxy_cycle = None
32
- self.running = False
33
- self.rotation_thread = None
34
- self.current_donation_params = {}
20
+ def donate(company_name: str, country: str, war_id: str,
21
+ donation_sum: str = "100000000000", proxy: str = None):
22
+ """Send a single donation (with optional proxy)"""
23
+ params = {
24
+ "Operation": "postDonation",
25
+ "available_patriotism": "0",
26
+ "company_id": "4456964",
27
+ "company_name": company_name,
28
+ "country": country,
29
+ "donation_sum": donation_sum,
30
+ "donation_type": "0",
31
+ "sender_company_id": "4456964",
32
+ "user_id": "3CE57CF11AFA43A1ABB7DB10431C2234",
33
+ "version_code": "22",
34
+ "war_id": war_id
35
+ }
36
+ headers = {
37
+ "Host": "52.24.104.170:8086",
38
+ "Connection": "Keep-Alive",
39
+ "User-Agent": "android-async-http",
40
+ "Accept-Encoding": "gzip",
41
+ "Content-Length": "0"
42
+ }
43
+ try:
44
+ response = requests.post(
45
+ api_url,
46
+ params=params,
47
+ headers=headers,
48
+ proxies={"http": proxy, "https": proxy} if proxy else None,
49
+ timeout=10
50
+ )
51
+ print(f"Success via {proxy or 'DIRECT'}: {response.status_code}")
52
+ return response.json()
53
+ except Exception as e:
54
+ print(f"Failed via {proxy or 'DIRECT'}: {str(e)}")
55
+ return None
35
56
 
36
- def donate(self, company_name, country, war_id):
37
- """
38
- Send a donation request with required parameters
39
-
40
- Args:
41
- company_name (str): Name of the company (required)
42
- country (str): Country name (required)
43
- war_id (str): War ID (required)
44
-
45
- Returns:
46
- dict: Dictionary containing status, status_code, and response/error
47
- """
48
- if not all([company_name, country, war_id]):
49
- raise ValueError("company_name, country, and war_id are all required parameters")
57
+ def _donate_cycle(company_name: str, country: str, war_id: str, times: int, delay: int):
58
+ """Internal function for proxy cycling"""
59
+ while True:
60
+ with proxy_lock:
61
+ if not proxies:
62
+ # No proxies - just send 'times' requests directly
63
+ for _ in range(times):
64
+ donate(company_name, country, war_id)
65
+ time.sleep(delay)
66
+ continue
50
67
 
51
- # Store the current donation parameters
52
- self.current_donation_params = {
53
- "company_name": company_name,
54
- "country": country,
55
- "war_id": war_id
56
- }
68
+ # Use all proxies in sequence
69
+ for proxy in proxies:
70
+ for _ in range(times):
71
+ donate(company_name, country, war_id, proxy=proxy)
57
72
 
58
- params = self.default_params.copy()
59
- params.update(self.current_donation_params)
60
-
61
- try:
62
- response = requests.get(
63
- self.api_url,
64
- params=params,
65
- headers=self.default_headers,
66
- timeout=10
67
- )
68
- return {
69
- "status": "success",
70
- "status_code": response.status_code,
71
- "response": response.text
72
- }
73
- except Exception as e:
74
- return {
75
- "status": "error",
76
- "error": str(e)
77
- }
73
+ # Delay after full cycle
74
+ time.sleep(delay)
78
75
 
79
- def add_proxy(self, proxy):
80
- """
81
- Add a proxy to the proxy list (format: ip:port)
82
-
83
- Args:
84
- proxy (str): Proxy address in format 'ip:port'
85
- """
86
- # Validate proxy format
87
- if ":" not in proxy:
88
- raise ValueError("Proxy must be in format ip:port")
89
-
90
- # Convert to http://ip:port format
91
- formatted_proxy = f"http://{proxy}"
92
-
93
- if formatted_proxy not in self.proxies:
94
- self.proxies.append(formatted_proxy)
95
- self.proxy_cycle = cycle(self.proxies)
96
- return f"Proxy added: {proxy}"
97
- return f"Proxy already exists: {proxy}"
76
+ def donatewithproxy(company_name: str, country: str, war_id: str, times: int = 1, delay: int = 0):
77
+ """
78
+ Send donations using all proxies in cycles:
79
+ 1. Each proxy sends 'times' requests
80
+ 2. Waits 'delay' seconds after full cycle
81
+ 3. Repeats indefinitely
82
+
83
+ Example:
84
+ donatewithproxy("Blackrock", "India", "2382", times=3, delay=20)
85
+ """
86
+ thread = threading.Thread(
87
+ target=_donate_cycle,
88
+ args=(company_name, country, war_id, times, delay),
89
+ daemon=True
90
+ )
91
+ thread.start()
92
+ active_threads.append(thread)
93
+ print(f"Started donation cycle (proxies={len(proxies)}, times={times}, delay={delay}s)")
98
94
 
99
- def clear_proxies(self):
100
- """Clear all proxies from the proxy list"""
101
- self.proxies = []
102
- self.proxy_cycle = None
103
- return "All proxies cleared"
95
+ def clear_proxies():
96
+ """Clear all proxies"""
97
+ with proxy_lock:
98
+ proxies.clear()
99
+ print("Proxies cleared")
104
100
 
105
- def rotateproxy(self, requests_per_proxy=None, delay_after_rotation=None):
106
- """
107
- Rotate through proxies making requests using current donation parameters
108
-
109
- Args:
110
- requests_per_proxy (int): Number of requests to make per proxy (required)
111
- delay_after_rotation (int): Seconds to wait after using all proxies (required)
112
-
113
- Returns:
114
- threading.Thread: The rotation thread object
115
- """
116
- # Validate required parameters
117
- if requests_per_proxy is None:
118
- raise ValueError("requests_per_proxy is required")
119
- if delay_after_rotation is None:
120
- raise ValueError("delay_after_rotation is required")
121
-
122
- if not self.current_donation_params:
123
- raise ValueError("No donation parameters set. Call donate() first")
124
-
125
- if not self.proxies:
126
- raise ValueError("No proxies available. Add proxies using add_proxy()")
127
-
128
- if self.proxy_cycle is None:
129
- self.proxy_cycle = cycle(self.proxies)
130
-
131
- self.running = True
132
-
133
- def rotation_worker():
134
- while self.running:
135
- for proxy in self.proxies:
136
- if not self.running:
137
- break
138
-
139
- for i in range(requests_per_proxy):
140
- if not self.running:
141
- break
142
-
143
- try:
144
- result = self.donate(
145
- self.current_donation_params["company_name"],
146
- self.current_donation_params["country"],
147
- self.current_donation_params["war_id"]
148
- )
149
- print(f"[Proxy: {proxy}] Request {i+1}/{requests_per_proxy}: {result['status']} (Status: {result.get('status_code', 'N/A')})")
150
- except Exception as e:
151
- print(f"[Proxy: {proxy}] Request {i+1}/{requests_per_proxy} failed: {str(e)}")
152
-
153
- time.sleep(1)
154
-
155
- if self.running:
156
- print(f"Rotation complete. Waiting {delay_after_rotation} seconds...")
157
- for _ in range(delay_after_rotation):
158
- if not self.running:
159
- break
160
- time.sleep(1)
161
-
162
- self.rotation_thread = threading.Thread(target=rotation_worker)
163
- self.rotation_thread.daemon = True
164
- self.rotation_thread.start()
165
- return self.rotation_thread
166
-
167
- def stop_rotation(self):
168
- """Stop the proxy rotation"""
169
- self.running = False
170
- if self.rotation_thread and self.rotation_thread.is_alive():
171
- self.rotation_thread.join(timeout=2)
172
- return "Rotation stopped"
173
-
174
- def get_proxy_list(self):
175
- """Get the current list of proxies (in ip:port format)"""
176
- return [p.replace("http://", "") for p in self.proxies]
177
-
178
- def set_default_param(self, key, value):
179
- """
180
- Set a default parameter value
181
-
182
- Args:
183
- key (str): Parameter key
184
- value (str): Parameter value
185
- """
186
- if key in self.default_params:
187
- self.default_params[key] = value
188
- return f"Updated {key}"
189
- else:
190
- raise KeyError(f"Invalid parameter key: {key}")
191
-
192
- def set_default_header(self, key, value):
193
- """
194
- Set a default header value
195
-
196
- Args:
197
- key (str): Header key
198
- value (str): Header value
199
- """
200
- self.default_headers[key] = value
201
- return f"Updated {key}"
202
-
203
- # Create a module-level instance for the simple interface
204
- eses = ESES()
101
+ def stop_all_donations():
102
+ """Stop all active donation threads"""
103
+ for thread in active_threads:
104
+ thread.join(timeout=1)
105
+ active_threads.clear()
106
+ print("All donations stopped")
eses/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.0.2"
1
+ __version__ = "1.0.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eses
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: A library for sending donation requests with proxy rotation
5
5
  Author-email: Your Name <your@email.com>
6
6
  Project-URL: Homepage, https://github.com/yourusername/eses
@@ -0,0 +1,7 @@
1
+ eses/__init__.py,sha256=rZmYeCdHswp8Bv91vIaIAS9SWmkxNPjIGQ0xtdrU6S0,3486
2
+ eses/version.py,sha256=O-a1T6uLdX0DYXelAnzqY4NDGktopbWdpKZloec7oxY,21
3
+ eses-1.0.4.dist-info/licenses/LICENSE,sha256=aG4OK9mj5S-wNkDBtWV4cDftgrzOM901qqYwlGF2Q2U,1085
4
+ eses-1.0.4.dist-info/METADATA,sha256=UFYIqKkt2CweTYfmgI-YaNC-q0N_2gj_lXttJPXrS-8,667
5
+ eses-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ eses-1.0.4.dist-info/top_level.txt,sha256=bhF_PMTvXEr3zbQtvND1twvnv1MQUq2hcn8kREYmePw,5
7
+ eses-1.0.4.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- eses/__init__.py,sha256=QbmbQ1668_tQpdUUZ3vlGeLwaitoN_lD9_LYhNkSE1I,7306
2
- eses/version.py,sha256=JqmBIiZnO_c1ce6zv6JZzf01tRk6jFq-SGGuvkL_r1U,21
3
- eses-1.0.2.dist-info/licenses/LICENSE,sha256=aG4OK9mj5S-wNkDBtWV4cDftgrzOM901qqYwlGF2Q2U,1085
4
- eses-1.0.2.dist-info/METADATA,sha256=WOAvu9PHyfrrc0dYXwlRxyTDIs77MaYxzCWqLY47YOU,667
5
- eses-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- eses-1.0.2.dist-info/top_level.txt,sha256=bhF_PMTvXEr3zbQtvND1twvnv1MQUq2hcn8kREYmePw,5
7
- eses-1.0.2.dist-info/RECORD,,
File without changes