-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
625 lines (513 loc) · 21.9 KB
/
main.py
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
# Drake Hooks
# Casino Claim
# Never Miss a Casino Bonus Again! A discord app for claiming social casino bonuses.
import os
from datetime import datetime, timedelta
import time
import re
import sqlite3
import discord
import asyncio
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
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.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.common.exceptions import NoSuchElementException, TimeoutException
import datetime
from dotenv import load_dotenv
import undetected_chromedriver as uc
from discord import Intents, Client, Message
from discord.ext import commands, tasks
import asyncio
from seleniumbase import Driver
from selenium.webdriver.common.action_chains import ActionChains
#import custom API functions
try:
# from fortunecoinsAPI import *
from stakeAPI import *
from modoAPI import *
from googleauthAPI import *
from chancedAPI import *
from rollingrichesAPI import *
from globalpokerAPI import *
from dingdingdingAPI import *
from chumbaAPI import *
from crowncoinsAPI import *
from zulaAPI import *
from luckybirdAPI import *
from sportzinoAPI import *
except Exception as e:
print(f"Error importing API libraries: {str(e)}")
load_dotenv()
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
DISCORD_CHANNEL = int(os.getenv("DISCORD_CHANNEL"))
intents = Intents.default()
intents.message_content = True
caps = DesiredCapabilities.CHROME
caps["goog:loggingPrefs"] = {"performance": "ALL"}
# Setup Chrome options
options = Options()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_argument("disable-infobars")
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_argument('--no-sandbox')
user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
options.add_argument(f"--user-agent={user_agent}")
user_data_dir = "/temp/google-chrome/" # Change path for Linux environment
options.add_argument(f"--user-data-dir={user_data_dir}")
options.add_extension('/temp/CAPTCHA-Solver-auto-hCAPTCHA-reCAPTCHA-freely-Chrome-Web-Store.crx')
options.set_capability("goog:loggingPrefs", caps["goog:loggingPrefs"])
# extension = "/root/.config/google-chrome/Default/Extensions"
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
bot = commands.Bot(command_prefix='!', intents=intents, case_insensitive=True)
bot.remove_command("help")
bot.luckybird_2fa_code = None
bot.chumba_2fa_code = None
# Dictionary to manage authentication status for different casinos
auth_status = {
"dingdingding": False,
"modo": False,
"stake": False,
"luckybird": False,
}
# Tasks
chanced_casino_task = None
luckybird_task = None
globalpoker_task = None
CrownCoinsCasino_task = None
chumba_task = None
dingdingding_task = None
stake_task = None
zula_task = None
rollingriches_task = None
sportzino_task = None
# Flags to check if corresponding background tasks are running
chanced_casino_running = False
luckybird_running = False
globalpoker_running = False
CrownCoinsCasino_running = False
chumba_running = False
dingdingding_running = False
stake_running = False
zula_running = False
rollingriches_running = False
funrize_running = False
sportzino_running = False
@bot.event
async def on_ready():
print(f"Bot has connected as {bot.user}")
channel = bot.get_channel(DISCORD_CHANNEL)
if channel:
await channel.send("Discord bot has started...")
else:
print("Invalid DISCORD_CHANNEL")
await asyncio.sleep(60)
if not chanced_casino_loop.is_running():
chanced_casino_loop.start()
if not new_chanced_session.is_running():
new_chanced_session.start()
if not casino_loop.is_running():
casino_loop.start()
await asyncio.sleep(260)
if not dingdingding_auth_task.is_running():
dingdingding_auth_task.start()
@bot.command(name="ping")
async def ping(ctx):
print("ponged")
await ctx.send("Pong")
@bot.command(name="help")
async def help(ctx):
await ctx.send("""Commands are not recommended. Available commands:
!chanced - Check Chanced.com for bonus
!luckybird - Check LuckyBird.io for bonus
!globalpoker - Check GlobalPoker for bonus
!crowncoins - Check CrownCoinsCasino for bonus
!chumba - Check Chumba for bonus
!dingdingding - Check DingDingDing for bonus
!modo - Check Modo for bonus
!sweepslots - Check SweepSlots for bonus
!zula - Check Zula for bonus
!rollingriches - Check RollingRiches for bonus
!sportzino - Check Sportzino for bonus
!fortunecoins - Check Fortunecoins for bonus
!ping - Check if the bot is online
!restart - Restart the bot
!help - Display the available commands
!stop - Stop the bot
---------------------------------------
Auth Commands:
!googleauth - Authenticate Google Account
!auth <site> - Authenticate into a specific site
(e.g. Modo, DingDingDing, Stake, LuckyBird)
!auth <site> <method> - Authenticate using a specific method
(e.g. !auth crowncoins google, !auth crowncoins env)
""")
async def action_notification(ctx, message):
# Send a notification message to the Discord channel
await ctx.send(f"Notification: {message}")
# Invalid command error handling
@bot.event
async def on_command_error(ctx, error):
print(f"Command Error: {error}")
await ctx.send(f"Command Error: {error}")
# Print help command
print("Type '!help' for a list of commands")
await ctx.send("Type '!help' for a list of commands")
# Restart command
@bot.command(name="restart")
async def restart(ctx):
print("Restarting...")
await ctx.send("Restarting...")
await bot.close()
os._exit(0) # Special exit code to restart docker container
@bot.command(name="googleauth")
async def googleauth(ctx):
await ctx.send("Authenticating Google Account...")
# Load credentials from environment variables
google_credentials = os.getenv("GOOGLE_LOGIN")
if google_credentials:
google_username, google_password = google_credentials.split(':')
credentials = (google_username, google_password)
else:
await ctx.send("Google credentials not found in .env file.")
credentials = (None, None)
channel = bot.get_channel(DISCORD_CHANNEL)
await google_auth(ctx, driver, channel, credentials)
@bot.event
async def on_message(message):
"""Capture 2FA codes for LuckyBird and Chumba."""
if message.channel.id == DISCORD_CHANNEL:
content = message.content.strip()
if len(content) == 6 and content.isdigit():
if "luckybird" in message.content.lower(): # Check if it's for LuckyBird
bot.luckybird_2fa_code = content
print(f"LuckyBird 2FA code {bot.luckybird_2fa_code} received.")
elif "chumba" in message.content.lower(): # Check if it's for Chumba
bot.chumba_2fa_code = content
print(f"Chumba 2FA code {bot.chumba_2fa_code} received.")
await bot.process_commands(message)
@bot.command(name="chumba")
async def chumba(ctx):
"""Starts the Chumba automation process."""
await ctx.send("Checking Chumba for Bonus...")
# Step 1: Go to the Chumba lobby
driver.get("https://lobby.chumbacasino.com/")
await asyncio.sleep(5)
# Step 2: If we are on the login page, authenticate
if driver.current_url.startswith("https://login.chumbacasino.com/"):
# Reset 2FA code before authentication
bot.chumba_2fa_code = None
# Call authentication process and pass the bot object to share the two_fa_code
authenticated = await authenticate_chumba(driver, bot, ctx)
if not authenticated:
await ctx.send("Chumba authentication failed.")
return
# Step 3: Proceed with claiming the bonus if authenticated
if driver.current_url.startswith("https://lobby.chumbacasino.com/"):
await claim_chumba_bonus(driver, ctx)
await check_chumba_countdown(driver, ctx)
else:
await ctx.send("Failed to reach the Chumba lobby.")
@bot.command(name="RollingRiches")
async def rollingriches(ctx):
global rollingriches_task
if not rollingriches_task or rollingriches_task.done():
await ctx.send("Checking Rolling Riches for Bonus...")
channel = bot.get_channel(DISCORD_CHANNEL)
await rolling_riches_casino(ctx, driver, channel)
else:
await ctx.send("RollingRiches automation is already running.")
@bot.command(name="Stake")
async def stake(ctx):
global stake_task
if not stake_task or stake_task.done():
await ctx.send("Checking Stake for Bonus...")
channel = bot.get_channel(DISCORD_CHANNEL)
await stake_claim(driver, bot, ctx, channel)
else:
await ctx.send("Stake automation is already running.")
@bot.command(name="chanced")
async def chanced(ctx):
await ctx.send("Checking Chanced.com for Bonus...")
# Load credentials from environment variables
chanced_credentials = os.getenv("CHANCED")
if chanced_credentials:
# Split the credentials into username and password using the ':' delimiter
chanced_username, chanced_password = chanced_credentials.split(':')
credentials = (chanced_username, chanced_password)
else:
credentials = (None, None) # No credentials, will proceed with user data dir
channel = bot.get_channel(DISCORD_CHANNEL)
await chanced_casino(ctx, driver, channel, credentials)
@bot.command(name="luckybird")
async def luckybird(ctx):
await ctx.send("Checking Luckybird for bonus...")
channel = bot.get_channel(int(os.getenv("DISCORD_CHANNEL")))
bonus_claimed = await luckyBird_claim(driver, bot, ctx, channel)
# If claiming the bonus failed, always check the countdown
if not bonus_claimed:
print("Failed to claim LuckyBird bonus. Checking countdown timer...")
await extract_countdown_info(driver, bot, ctx, channel)
# Command to run the Global Poker bonus checker
@bot.command(name="globalpoker")
async def global_poker_command(ctx):
global globalpoker_running
if not globalpoker_running:
await ctx.send("Checking GlobalPoker for Bonus...")
globalpoker_running = True
# Get the channel and driver from the context
channel = bot.get_channel(DISCORD_CHANNEL)
# driver = ctx.driver # Assuming driver is passed in the context
# Call the main GlobalPoker function
await global_poker(ctx, driver, channel)
globalpoker_running = False
else:
await ctx.send("GlobalPoker automation is already running.")
@bot.command(name="CrownCoins")
async def crowncoinscasino(ctx):
global CrownCoinsCasino_task
if not CrownCoinsCasino_task or CrownCoinsCasino_task.done():
await ctx.send("Checking Crown Coins Casino for Bonus...")
channel = bot.get_channel(int(os.getenv("DISCORD_CHANNEL")))
CrownCoinsCasino_task = asyncio.create_task(crowncoins_casino(driver, bot, ctx, channel))
else:
await ctx.send("CrownCoinsCasino automation is already running.")
@bot.command(name="dingdingding")
async def DingDingDing(ctx):
await ctx.send("Checking DingDingDing for bonus...")
channel = bot.get_channel(int(os.getenv("DISCORD_CHANNEL")))
bonus_claimed = await claim_dingdingding_bonus(driver, bot, ctx, channel)
# If claiming the bonus failed, always check the countdown
if not bonus_claimed:
print("Failed to claim DingDingDing bonus. Checking countdown timer...")
await check_dingdingding_countdown(driver, bot, ctx, channel)
@bot.command(name="modo")
async def modo(ctx):
await ctx.send("Checking Modo for bonus...")
channel = bot.get_channel(int(os.getenv("DISCORD_CHANNEL")))
# Attempt to claim the bonus
bonus_claimed = await claim_modo_bonus(driver, bot, ctx, channel)
# Check countdown if claiming fails
if not bonus_claimed:
print("Failed to claim Modo bonus. Checking countdown timer...")
await check_modo_countdown(driver, bot, ctx, channel)
@bot.command(name="auth")
async def authenticate_command(ctx, site: str, method: str = None):
channel = bot.get_channel(DISCORD_CHANNEL)
# CrownCoins Authentication
if site.lower() == "crowncoins":
if method is None:
await ctx.send("Please specify the authentication method: `google` or `env`.")
return
if method.lower() == "google":
await ctx.send("Authenticating CrownCoins using Google...")
auth_status["crowncoins_google"] = await auth_crown_google(driver, bot, ctx, channel)
if auth_status["crowncoins_google"]:
print("CrownCoins authentication via Google succeeded.")
else:
screenshot_path = "crowncoins_google_auth_failed.png"
driver.save_screenshot(screenshot_path)
await ctx.send("",
file=discord.File(screenshot_path))
os.remove(screenshot_path)
elif method.lower() == "env":
await ctx.send("Authenticating CrownCoins using .env credentials...")
auth_status["crowncoins_env"] = await auth_crown_env(driver, bot, ctx, channel)
if auth_status["crowncoins_env"]:
print("CrownCoins authentication via .env credentials succeeded.")
else:
screenshot_path = "crowncoins_env_auth_failed.png"
driver.save_screenshot(screenshot_path)
await ctx.send("",
file=discord.File(screenshot_path))
os.remove(screenshot_path)
else:
await ctx.send("Invalid authentication method. Use `google` or `env`.")
# Other Sites
elif site.lower() == "dingdingding":
await ctx.send("Authenticating DingDingDing...")
auth_status["dingdingding"] = await authenticate_dingdingding(driver, bot, ctx, channel)
if auth_status["dingdingding"]:
print("DingDingDing authentication succeeded.")
else:
screenshot_path = "dingdingding_auth_failed.png"
driver.save_screenshot(screenshot_path)
await ctx.send("Authentication failed. Unable to proceed.",
file=discord.File(screenshot_path))
os.remove(screenshot_path)
elif site.lower() == "modo":
await ctx.send("Authenticating Modo...")
auth_status["modo"] = await authenticate_modo(driver, bot, ctx, channel)
if auth_status["modo"]:
print("Modo authentication succeeded.")
else:
screenshot_path = "modo_auth_failed.png"
driver.save_screenshot(screenshot_path)
await ctx.send("Modo authentication failed. Unable to proceed.",
file=discord.File(screenshot_path))
os.remove(screenshot_path)
elif site.lower() == "stake":
await ctx.send("Authenticating Stake...")
auth_status["stake"] = await stake_auth(driver, bot, ctx, channel)
if auth_status["stake"]:
print("Stake authentication succeeded.")
else:
screenshot_path = "stake_auth_failed.png"
driver.save_screenshot(screenshot_path)
await ctx.send("Stake authentication failed. Unable to proceed.",
file=discord.File(screenshot_path))
os.remove(screenshot_path)
elif site.lower() == "luckybird":
await ctx.send("Authenticating LuckyBird...")
auth_status["luckybird"] = await authenticate_luckybird(driver, bot, ctx, channel)
if auth_status["luckybird"]:
print("LuckyBird authentication succeeded.")
else:
screenshot_path = "luckybird_auth_failed.png"
driver.save_screenshot(screenshot_path)
await ctx.send("LuckyBird authentication failed. Unable to proceed.",
file=discord.File(screenshot_path))
os.remove(screenshot_path)
else:
await ctx.send(f"Authentication for '{site}' is not implemented.")
@bot.command(name="Zula")
async def zula(ctx):
global zula_task
if not zula_task or zula_task.done():
await ctx.send("Checking Zula Casino for Bonus...")
zula_task = asyncio.create_task(zula_casino(driver, bot, ctx))
else:
await ctx.send("ZulaCasino automation is already running.")
@bot.command(name="Sportzino")
async def sportzino(ctx):
global sportzino_task
if not sportzino_task or sportzino_task.done():
channel = bot.get_channel(DISCORD_CHANNEL)
await ctx.send("Checking Sportzino for Bonus...")
sportzino_task = asyncio.create_task(Sportzino(ctx, driver, channel))
else:
await ctx.send("Sportzino automation is already running.")
@tasks.loop(hours=12)
async def new_chanced_session():
print("Starting new_chanced_session...")
channel = bot.get_channel(DISCORD_CHANNEL)
# Load credentials from environment variables
chanced_credentials = os.getenv("CHANCED")
if chanced_credentials:
chanced_username, chanced_password = chanced_credentials.split(':')
credentials = (chanced_username, chanced_password)
else:
credentials = (None, None)
if credentials[0] and credentials[1]:
await channel.send(f"Creating a new Chanced session with credentials.")
else:
await channel.send(f"Unable to create new chanced.com session. Are the credentials set?")
try:
await logout_and_login(None, driver, channel, credentials)
except Exception as e:
await channel.send(f"Error during session refresh: {str(e)}")
@tasks.loop(minutes=62)
async def chanced_casino_loop():
print("Starting chanced_casino_loop...")
# Get the channel object
channel = bot.get_channel(DISCORD_CHANNEL)
# Check if the channel is valid
if channel is None:
print(f"Error: Invalid channel ID '{DISCORD_CHANNEL}' or bot is not connected.")
return # Exit the task loop early if the channel is invalid
try:
# Run the chanced casino task
await chanced_casino(None, driver, channel, None)
except Exception as e:
print(f"Error in loop: {str(e)}")
await channel.send(f"Error in Chanced Casino loop: {str(e)}")
@tasks.loop(hours=24)
async def dingdingding_auth_task():
channel = bot.get_channel(DISCORD_CHANNEL)
await channel.send("Running scheduled DingDingDing authentication...")
auth_status["dingdingding"] = await authenticate_dingdingding(driver, bot, None, channel)
if auth_status["dingdingding"]:
await channel.send("DingDingDing authentication succeeded during the scheduled task.")
else:
await channel.send("DingDingDing authentication failed during the scheduled task.")
@tasks.loop(hours=2, )
async def casino_loop():
print("Starting casino_loop...")
channel = bot.get_channel(DISCORD_CHANNEL)
if channel is None:
print(f"Error: Invalid channel ID '{DISCORD_CHANNEL}' or bot is not connected.")
return # Exit the task loop early if the channel is invalid
try:
# Run the casino tasks sequentially with 2-hour gaps
try:
await asyncio.sleep(40)
await zula_casino(None, driver, channel)
except:
print("Error in Zula")
await asyncio.sleep(50)
await asyncio.sleep(80)
try:
await Sportzino(None, driver, channel)
await asyncio.sleep(50)
except:
print("Error in Sportzino")
await asyncio.sleep(50)
await asyncio.sleep(80)
try:
await crowncoins_casino(driver, bot, None, channel)
except:
print("Error in CrownCoinsCasino")
await asyncio.sleep(30)
try:
bonus_claimed = await claim_modo_bonus(driver, bot, None, channel)
if not bonus_claimed:
print("Failed to claim Modo bonus. Checking countdown timer...")
await check_modo_countdown(driver, bot, None, channel)
except:
print("Error in DingDingDing")
await asyncio.sleep(100)
try:
bonus_claimed = await claim_dingdingding_bonus(driver, bot, None, channel)
if not bonus_claimed:
print("Failed to claim DingDingDing bonus. Checking countdown timer...")
await check_dingdingding_countdown(driver, bot, None, channel)
except:
print("Error in DingDingDing")
await asyncio.sleep(100)
await asyncio.sleep(10)
try:
await global_poker(None, driver, channel)
await asyncio.sleep(10)
except:
print("Error in GlobalPoker")
await asyncio.sleep(10)
try:
bonus_claimed = await luckyBird_claim(driver, bot, None, channel)
if not bonus_claimed:
print("Failed to claim LuckyBird bonus. Checking countdown timer...")
await extract_countdown_info(driver, bot, None, channel)
except:
print("Error in LuckyBird")
await asyncio.sleep(10)
try:
await chumba_casino(None, driver, bot)
except:
print("Error in Chumba")
await asyncio.sleep(10)
try:
await rolling_riches_casino(None, driver, channel)
except:
print("Error in RollingRiches")
try:
await stake_claim(driver, bot, None, channel)
except:
print("Error in Stake")
except Exception as e:
print(f"Error in loop: {str(e)}")
bot.run(DISCORD_TOKEN)