-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenough.py
More file actions
51 lines (45 loc) · 1.5 KB
/
enough.py
File metadata and controls
51 lines (45 loc) · 1.5 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
from sms import SendSms
import threading
def is_enough(phone, email, count, mode):
sms = SendSms(phone, email)
servisler_sms = []
for attr in dir(SendSms):
if callable(getattr(SendSms, attr)) and not attr.startswith('__'):
servisler_sms.append(attr)
lock = threading.Lock()
sent_count = 0
failed_count = 0
total_attempts = 0
servis_index = 0
def run_service():
nonlocal sent_count, failed_count, total_attempts, servis_index
with lock:
if total_attempts >= count:
return
total_attempts += 1
func = servisler_sms[servis_index]
servis_index = (servis_index + 1) % len(servisler_sms)
try:
getattr(sms, func)()
with lock:
sent_count += 1
except Exception:
with lock:
failed_count += 1
batch_size = min(100, count) # Render için 100’lük batch
if mode == "turbo":
for _ in range(0, count, batch_size):
threads = []
for _ in range(min(batch_size, count - total_attempts)):
t = threading.Thread(target=run_service)
threads.append(t)
t.start()
for t in threads:
t.join()
else:
for _ in range(count):
run_service()
print(f"[+] Başarılı! {sent_count} SMS gönderildi")
for _ in range(failed_count):
print("[-] Başarısız!")
return sent_count, failed_count