forked from DrakeHooks/CasinoClaim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdingdingdingAPI.py
More file actions
156 lines (124 loc) · 6 KB
/
Copy pathdingdingdingAPI.py
File metadata and controls
156 lines (124 loc) · 6 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
# Drake Hooks
# Casino Claim
# DingDingDing API
import os
import asyncio
from dotenv import load_dotenv
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
# Load environment variables from the .env file
load_dotenv()
# Function to authenticate into DingDingDing
async def authenticate_dingdingding(driver, bot, ctx, channel):
try:
channel = bot.get_channel(int(os.getenv("DISCORD_CHANNEL")))
web = "https://www.dingdingding.com/login"
driver.get(web)
await asyncio.sleep(10)
# Wait for email and password fields, enter credentials from environment variables
email_field = WebDriverWait(driver, 30).until(
EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div/div[1]/div[1]/div/div/div[2]/form/input[1]"))
)
creds = os.getenv("DINGDINGDING")
if not creds:
await channel.send("DINGDINGDING credentials not found in environment variables.")
return False
email_field.send_keys(creds.split(":")[0])
password_field = WebDriverWait(driver, 30).until(
EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div/div[1]/div[1]/div/div/div[2]/form/input[2]"))
)
password_field.send_keys(creds.split(":")[1])
await asyncio.sleep(3)
try:
WebDriverWait(driver, 300).until_not(
EC.presence_of_element_located((By.CSS_SELECTOR, "iframe[title*='recaptcha']"))
)
print("CAPTCHA resolved, proceeding to click the login button.")
except TimeoutException:
return False
try:
# Click login button
login_btn = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.XPATH, "/html/body/div[1]/div/div/div[1]/div[1]/div/div/div[2]/form/button[2]"))
)
login_btn.click()
except:
await channel.send("Unable to solve captcha!")
return False
await asyncio.sleep(5)
# Check if login was successful
if driver.current_url == "https://dingdingding.com/lobby/":
await channel.send("Authenticated into DingDingDing successfully!")
return True
else:
await channel.send("Authentication failed. Did not reach the lobby.")
return False
except TimeoutException:
await channel.send("Authentication timeout. Please check your credentials or XPaths.")
return False
# Function to claim DingDingDing daily bonus
async def claim_dingdingding_bonus(driver, bot, ctx, channel):
try:
channel = bot.get_channel(int(os.getenv("DISCORD_CHANNEL")))
driver.get("https://dingdingding.com/lobby/")
await asyncio.sleep(10)
# Click the bonus button in the lobby
bonus_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "#__nuxt > div > div:nth-child(1) > aside.sidenav > div.sidenav__cont > div > div.sidenav__actions > button.btn.btn--nav.btn--rewards > span.btn__label"))
)
bonus_button.click()
print("DingDingDing Daily Bonus Button Found!")
# Click the collect button
collect_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "/html/body/div[1]/div/div[1]/div[6]/div/div[2]/div/div/button[2]"))
)
collect_button.click()
await channel.send("DingDingDing Daily Bonus Claimed!")
except TimeoutException:
print("COLLECT button not found! Check XPATH of claim button!")
return False
return True
# Function to check the countdown for the next bonus
async def check_dingdingding_countdown(driver, bot, ctx, channel):
try:
channel = bot.get_channel(int(os.getenv("DISCORD_CHANNEL")))
driver.get("https://dingdingding.com/lobby/")
await asyncio.sleep(10)
bonus_button = WebDriverWait(driver, 30).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "#__nuxt > div > div:nth-child(1) > aside.sidenav > div.sidenav__cont > div > div.sidenav__actions > button.btn.btn--nav.btn--rewards > span.btn__label"))
)
bonus_button.click()
# Retrieve countdown elements
hours_element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div[1]/div[6]/div/div[2]/div/div/div/span/div[1]/span"))
)
minutes_element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div[1]/div[6]/div/div[2]/div/div/div/span/div[2]"))
)
seconds_element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div[1]/div[6]/div/div[2]/div/div/div/span/div[3]"))
)
# Format countdown time
countdown_message = f"Next DingDingDing Bonus Available in: {hours_element.text.zfill(2)}:{minutes_element.text.zfill(2)}:{seconds_element.text.zfill(2)}"
await channel.send(countdown_message)
except TimeoutException:
await channel.send("Failed to retrieve DingDingDing countdown timer.")
return False
return True
# Main function to handle DingDingDing
async def dingdingding_casino(driver, bot, ctx, channel):
channel = bot.get_channel(int(os.getenv("DISCORD_CHANNEL")))
# Authenticate first
await channel.send("Authenticating into DingDingDing...")
authenticated = await authenticate_dingdingding(driver, bot, ctx, channel)
if authenticated:
try:
await claim_dingdingding_bonus(driver, bot, ctx, channel)
await asyncio.sleep(5)
except:
print("Failed to claim DingDingDing bonus.")
await check_dingdingding_countdown(driver, bot, ctx, channel)
else:
await channel.send("Failed to authenticate into DingDingDing.")