File size: 26,561 Bytes
d35d016 cdfa259 d35d016 cdfa259 7cd896c cdfa259 d35d016 ae2fb85 d35d016 cdfa259 d35d016 cdfa259 d35d016 cdfa259 d35d016 7cd896c cdfa259 fdb616e cdfa259 7cd896c cdfa259 7cd896c cdfa259 7cd896c cdfa259 fdb616e cdfa259 fdb616e cdfa259 7cd896c cdfa259 d35d016 cdfa259 d35d016 7cd896c d35d016 7cd896c d35d016 7cd896c d35d016 cdfa259 d35d016 7cd896c cdfa259 7cd896c cdfa259 7cd896c cdfa259 7cd896c cdfa259 7cd896c cdfa259 d35d016 cdfa259 7cd896c cdfa259 d35d016 7cd896c cdfa259 7cd896c d35d016 cdfa259 d35d016 cdfa259 d35d016 cdfa259 d35d016 cdfa259 d35d016 7cd896c d35d016 cdfa259 d35d016 7cd896c d35d016 7cd896c d35d016 7cd896c d35d016 7cd896c d35d016 |
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 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 |
import requests
import discord
from discord.ext import commands
import asyncio
import json
import re
from collections import defaultdict
from collections import deque
from datetime import datetime, timedelta
import pytz
import os
TOKEN = os.environ['TOKEN']
CHANNEL_ID = 1298830206387228682
MONITORED_ITEMS_CHANNEL_ID = 1307752080139878500
AUTHORIZED_USER_ID = 1219416244806094883
PETS_API = 'https://petsapi.deno.dev/'
EXISTS_API = 'https://existsapi.deno.dev/'
RAP_API = 'https://rapapi.deno.dev/'
last_rap_values = {
"Crystal Key": None,
"Huge Shiba": None,
"Huge Dragon": None,
"Huge Inferno Cat": None,
"Autumn God Potion": None
}
LIMITED_PETS = {
"Huge Shiba": 15000,
"Huge Dragon": 7500,
"Huge Nightmare Corgi": 15000,
"Huge Jelly Axolotl": 5000
}
JELLY_LEAVE_TIMES = {
"Huge Pilgrim Turkey": datetime.strptime('2024-12-06 12:00:00', '%Y-%m-%d %H:%M:%S').replace(tzinfo=pytz.timezone('US/Eastern')),
"Acorn": datetime.strptime('2024-12-06 12:00:00', '%Y-%m-%d %H:%M:%S').replace(tzinfo=pytz.timezone('US/Eastern'))
}
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
pet_images = {}
pet_difficulties = {}
pet_raps = {}
pet_changes = {}
recent_notifications = defaultdict(lambda: deque(maxlen=5))
async def fetch_exists_data():
try:
response = requests.get('https://biggamesexists.deno.dev')
if response.status_code == 200:
return response.json().get('data', [])
except Exception as e:
print(f"Error fetching exists data: {e}")
return []
def format_number(number):
if not isinstance(number, (int, float)):
return str(number)
abs_number = abs(number)
if abs_number < 1000:
return str(number)
elif abs_number < 1000000:
return f"{number/1000:.1f}k"
elif abs_number < 1000000000:
return f"{number/1000000:.1f}m"
elif abs_number < 1000000000000:
return f"{number/1000000000:.1f}b"
else:
return f"{number/1000000000000:.1f}t"
async def fetch_pet_collection_data(pet_name):
try:
response = requests.get('https://collectionpet.deno.dev')
if response.status_code == 200:
data = response.json().get('data', [])
for pet in data:
if pet.get('configName', '').lower() == pet_name.lower():
return pet
except Exception as e:
print(f"Error fetching pet collection data: {e}")
return None
async def fetch_pet_exists_data(pet_name):
try:
response = requests.get('https://biggamesexists.deno.dev')
if response.status_code == 200:
data = response.json().get('data', [])
variants = {
'Normal': 0,
'Golden': 0,
'Rainbow': 0,
'Shiny': 0,
'Shiny Golden': 0,
'Shiny Rainbow': 0
}
for pet_data in data:
config_data = pet_data.get('configData', {})
value = pet_data.get('value', 0)
pet_id = config_data.get('id', '')
is_shiny = config_data.get('sh', False)
pt_value = config_data.get('pt', 0)
if pet_id.lower() == pet_name.lower():
if is_shiny and pt_value == 1:
variants['Shiny Golden'] = max(variants['Shiny Golden'], value)
elif is_shiny and pt_value == 2:
variants['Shiny Rainbow'] = max(variants['Shiny Rainbow'], value)
elif is_shiny:
variants['Shiny'] = max(variants['Shiny'], value)
elif pt_value == 1:
variants['Golden'] = max(variants['Golden'], value)
elif pt_value == 2:
variants['Rainbow'] = max(variants['Rainbow'], value)
else:
variants['Normal'] = max(variants['Normal'], value)
return variants
except Exception as e:
print(f"Error fetching exists data: {e}")
return None
@bot.command(name='petdata')
async def pet_data(ctx, *, pet_name):
collection_data = await fetch_pet_collection_data(pet_name)
exists_data = await fetch_pet_exists_data(pet_name)
if not collection_data or not exists_data:
await ctx.send("Pet does not exist!")
return
embed = discord.Embed(
title=collection_data.get('configName', 'Unknown Pet'),
color=int('11ff00', 16)
)
config_data = collection_data.get('configData', {})
description = f"**Index Description:** {config_data.get('indexDesc', 'N/A')}\n"
description += f"**Obtainable in Index:** {config_data.get('indexObtainable', 'N/A')}"
embed.description = description
total_exists = sum(exists_data.values())
exists_text = "\n".join([
f"{variant}: **{count:,}**"
for variant, count in exists_data.items() if count > 0
])
exists_text += f"\n\n**Total Exist: {total_exists:,}**"
embed.add_field(name="**Pet Exists:**", value=exists_text, inline=False)
thumbnail_url = config_data.get('thumbnail')
if thumbnail_url:
if thumbnail_url.startswith('rbxassetid://'):
asset_id = re.search(r'\d+', thumbnail_url.replace('rbxassetid://', '')).group(0)
thumbnail_url = f"https://rbxgleaks.pythonanywhere.com/asset/{asset_id}"
embed.set_image(url=thumbnail_url)
await ctx.send(embed=embed)
@bot.command(name='commonhuges')
async def common_huge_pets(ctx, count: int = 10):
if ctx.author.id != AUTHORIZED_USER_ID:
await ctx.send("You are not authorized to use this command.")
return
count = max(1, min(count, 25))
exists_data = await fetch_exists_data()
if not exists_data:
await ctx.send("Could not retrieve pet data. Please try again later.")
return
huge_pet_counts = defaultdict(int)
for pet in exists_data:
config_data = pet.get('configData', {})
value = pet.get('value', 0)
if config_data.get('id', '').startswith('Huge'):
pet_name = config_data.get('id', 'Unknown')
is_shiny = config_data.get('sh', False)
pt_value = config_data.get('pt', 0)
if is_shiny and pt_value == 1:
variant_key = f"Shiny Golden {pet_name}"
elif is_shiny and pt_value == 2:
variant_key = f"Shiny Rainbow {pet_name}"
elif is_shiny:
variant_key = f"Shiny {pet_name}"
elif pt_value == 1:
variant_key = f"Golden {pet_name}"
elif pt_value == 2:
variant_key = f"Rainbow {pet_name}"
else:
variant_key = f"Normal {pet_name}"
huge_pet_counts[variant_key] = max(huge_pet_counts[variant_key], value)
sorted_huge_pets = sorted(huge_pet_counts.items(), key=lambda x: x[1], reverse=True)
embed = discord.Embed(title=f"Top {count} Most Common Huge Pets", color=discord.Color.blue())
if sorted_huge_pets:
for i, (pet_name, count_value) in enumerate(sorted_huge_pets[:count], 1):
embed.add_field(
name=f"{i}. {pet_name}",
value=f"Exists: **{format_number(count_value)}**",
inline=False
)
else:
embed.description = "No huge pets found in the data."
await ctx.send(embed=embed)
@bot.command(name='commontitanics')
async def common_titanic_pets(ctx, count: int = 10):
if ctx.author.id != AUTHORIZED_USER_ID:
await ctx.send("You are not authorized to use this command.")
return
count = max(1, min(count, 25))
exists_data = await fetch_exists_data()
if not exists_data:
await ctx.send("Could not retrieve pet data. Please try again later.")
return
huge_pet_counts = defaultdict(int)
for pet in exists_data:
config_data = pet.get('configData', {})
value = pet.get('value', 0)
if config_data.get('id', '').startswith('Titanic'):
pet_name = config_data.get('id', 'Unknown')
is_shiny = config_data.get('sh', False)
pt_value = config_data.get('pt', 0)
if is_shiny and pt_value == 1:
variant_key = f"Shiny Golden {pet_name}"
elif is_shiny and pt_value == 2:
variant_key = f"Shiny Rainbow {pet_name}"
elif is_shiny:
variant_key = f"Shiny {pet_name}"
elif pt_value == 1:
variant_key = f"Golden {pet_name}"
elif pt_value == 2:
variant_key = f"Rainbow {pet_name}"
else:
variant_key = f"Normal {pet_name}"
huge_pet_counts[variant_key] = max(huge_pet_counts[variant_key], value)
sorted_huge_pets = sorted(huge_pet_counts.items(), key=lambda x: x[1], reverse=True)
embed = discord.Embed(title=f"Top {count} Most Common Titanic Pets", color=discord.Color.blue())
if sorted_huge_pets:
for i, (pet_name, count_value) in enumerate(sorted_huge_pets[:count], 1):
embed.add_field(
name=f"{i}. {pet_name}",
value=f"Exists: **{format_number(count_value)}**",
inline=False
)
else:
embed.description = "No titanic pets found in the data."
await ctx.send(embed=embed)
@bot.command(name='leastcommonhuges')
async def least_common_huge_pets(ctx, count: int = 10):
if ctx.author.id != AUTHORIZED_USER_ID:
await ctx.send("You are not authorized to use this command.")
return
count = max(1, min(count, 25))
exists_data = await fetch_exists_data()
if not exists_data:
await ctx.send("Could not retrieve pet data. Please try again later.")
return
huge_pet_counts = defaultdict(int)
for pet in exists_data:
config_data = pet.get('configData', {})
value = pet.get('value', 0)
if config_data.get('id', '').startswith('Huge'):
pet_name = config_data.get('id', 'Unknown')
is_shiny = config_data.get('sh', False)
pt_value = config_data.get('pt', 0)
if is_shiny and pt_value == 1:
variant_key = f"Shiny Golden {pet_name}"
elif is_shiny and pt_value == 2:
variant_key = f"Shiny Rainbow {pet_name}"
elif is_shiny:
variant_key = f"Shiny {pet_name}"
elif pt_value == 1:
variant_key = f"Golden {pet_name}"
elif pt_value == 2:
variant_key = f"Rainbow {pet_name}"
else:
variant_key = f"Normal {pet_name}"
huge_pet_counts[variant_key] = max(huge_pet_counts[variant_key], value)
sorted_huge_pets = sorted(huge_pet_counts.items(), key=lambda x: x[1])
embed = discord.Embed(title=f"Top {count} Least Common Huge Pets", color=discord.Color.dark_red())
if sorted_huge_pets:
for i, (pet_name, count_value) in enumerate(sorted_huge_pets[:count], 1):
embed.add_field(
name=f"{i}. {pet_name}",
value=f"Exists: **{format_number(count_value)}**",
inline=False
)
else:
embed.description = "No huge pets found in the data."
await ctx.send(embed=embed)
@bot.command(name='leastcommontitanics')
async def least_common_titanic_pets(ctx, count: int = 10):
if ctx.author.id != AUTHORIZED_USER_ID:
await ctx.send("You are not authorized to use this command.")
return
count = max(1, min(count, 25))
exists_data = await fetch_exists_data()
if not exists_data:
await ctx.send("Could not retrieve pet data. Please try again later.")
return
titanic_pet_counts = defaultdict(int)
for pet in exists_data:
config_data = pet.get('configData', {})
value = pet.get('value', 0)
if config_data.get('id', '').startswith('Titanic'):
pet_name = config_data.get('id', 'Unknown')
is_shiny = config_data.get('sh', False)
pt_value = config_data.get('pt', 0)
if is_shiny and pt_value == 1:
variant_key = f"Shiny Golden {pet_name}"
elif is_shiny and pt_value == 2:
variant_key = f"Shiny Rainbow {pet_name}"
elif is_shiny:
variant_key = f"Shiny {pet_name}"
elif pt_value == 1:
variant_key = f"Golden {pet_name}"
elif pt_value == 2:
variant_key = f"Rainbow {pet_name}"
else:
variant_key = f"Normal {pet_name}"
titanic_pet_counts[variant_key] = max(titanic_pet_counts[variant_key], value)
sorted_titanic_pets = sorted(titanic_pet_counts.items(), key=lambda x: x[1])
embed = discord.Embed(title=f"Top {count} Least Common Titanic Pets", color=discord.Color.dark_red())
if sorted_titanic_pets:
for i, (pet_name, count_value) in enumerate(sorted_titanic_pets[:count], 1):
embed.add_field(
name=f"{i}. {pet_name}",
value=f"Exists: **{format_number(count_value)}**",
inline=False
)
else:
embed.description = "No titanic pets found in the data."
await ctx.send(embed=embed)
def calculate_jelly_prediction(pet_name, current_value, hourly_rate):
if pet_name not in JELLY_LEAVE_TIMES:
return None
current_time = datetime.now(pytz.timezone('US/Eastern'))
leave_time = JELLY_LEAVE_TIMES[pet_name]
if current_time >= leave_time:
return None
time_diff = leave_time - current_time
hours_remaining = time_diff.total_seconds() / 3600
predicted_increase = hourly_rate * hours_remaining
predicted_final = current_value + predicted_increase
return {
'predicted_value': int(predicted_final),
'hours_remaining': round(hours_remaining, 1)
}
def calculate_time_until_limited(pet_name, current_value, hourly_rate):
if pet_name not in LIMITED_PETS or hourly_rate <= 0:
return None
limit = LIMITED_PETS[pet_name]
remaining = limit - current_value
if remaining <= 0:
return "Already Limited!"
hours = remaining / hourly_rate
if hours < 0:
return "Error calculating time"
days = hours // 24
remaining_hours = hours % 24
if days > 0:
return f"~{int(days)}d {int(remaining_hours)}h"
else:
return f"~{int(remaining_hours)}h"
async def send_rap_change_notification(channel, item_name, previous_rap, current_rap):
percent_change = ((current_rap - previous_rap) / previous_rap) * 100
if current_rap > previous_rap:
message = f"🚀 {item_name} RAP ROSE BY {percent_change:.2f}%!\n" + \
f"Previous RAP: {previous_rap:,}\n" + \
f"Current RAP: {current_rap:,}"
await channel.send(message)
else:
message = f"📉 {item_name} RAP DROPPED BY {abs(percent_change):.2f}%!\n" + \
f"Previous RAP: {previous_rap:,}\n" + \
f"Current RAP: {current_rap:,}"
await channel.send(message)
async def update_rap_values():
try:
response = requests.get(RAP_API)
if response.status_code == 200:
data = response.json()
if data['status'] == 'ok':
pet_raps.clear()
monitored_channel = bot.get_channel(MONITORED_ITEMS_CHANNEL_ID)
if monitored_channel:
for pet_data in data['data']:
config_data = pet_data['configData']
pet_id = config_data['id']
value = pet_data['value']
is_shiny = config_data.get('sh', False)
monitored_key = f"Shiny {pet_id}" if is_shiny else pet_id
if monitored_key in last_rap_values:
current_rap = value
previous_rap = last_rap_values[monitored_key]
if previous_rap is not None and current_rap != previous_rap:
await send_rap_change_notification(monitored_channel, monitored_key, previous_rap, current_rap)
last_rap_values[monitored_key] = current_rap
if is_shiny:
pet_raps[f"Shiny {pet_id}"] = value
else:
pet_raps[pet_id] = value
print(f"Updated RAP values for {len(data['data'])} pets and items")
except Exception as e:
print(f"Error fetching RAP values: {e}")
def calculate_hourly_rate(pet_name):
if pet_name not in pet_changes:
return 0
changes = pet_changes[pet_name]
if not changes:
return 0
current_time = datetime.now()
one_hour_ago = current_time - timedelta(hours=1)
recent_changes = [change for change in changes if change['timestamp'] > one_hour_ago]
if not recent_changes:
return 0
if len(recent_changes) >= 2:
earliest_value = recent_changes[0]['value']
latest_value = recent_changes[-1]['value']
return latest_value - earliest_value
return 1
async def get_huge_secret_pets():
try:
response = requests.get(PETS_API)
if response.status_code == 200:
data = response.json()
if data['status'] == 'ok':
huge_secret_pets = []
for pet in data['data']:
config_data = pet['configData']
if config_data.get('huge') or config_data.get('secret'):
pet_name = config_data['name']
huge_secret_pets.append(pet_name)
huge_secret_pets.append(f"Shiny {pet_name}")
difficulty = config_data.get('difficulty', 'Unknown')
pet_difficulties[pet_name] = difficulty
pet_difficulties[f"Shiny {pet_name}"] = difficulty * 100
if 'thumbnail' in config_data:
pet_images[pet_name] = config_data['thumbnail']
pet_images[f"Shiny {pet_name}"] = config_data['thumbnail']
print(f"Stored image URL for {pet_name}: {config_data['thumbnail']}")
for pet_name in huge_secret_pets:
if pet_name not in pet_changes:
pet_changes[pet_name] = deque(maxlen=100)
print(f"Found {len(huge_secret_pets)} pets to track (including shiny versions)")
return huge_secret_pets
except Exception as e:
print(f"Error fetching pets list: {e}")
return []
async def send_embed_message(channel, pet_name, previous_value, current_value, is_change=False):
notification_key = f"{pet_name}_{previous_value}_{current_value}"
if notification_key in recent_notifications.get(pet_name, []):
print(f"Skipping duplicate notification for {pet_name}")
return
if pet_name not in recent_notifications:
recent_notifications[pet_name] = []
recent_notifications[pet_name].append(notification_key)
pet_image_url = pet_images.get(pet_name, None)
difficulty = pet_difficulties.get(pet_name, "Unknown")
rap_value = pet_raps.get(pet_name, "No RAP")
hourly_rate = calculate_hourly_rate(pet_name)
difficulty_display = format_number(difficulty) if isinstance(difficulty, (int, float)) else difficulty
rap_display = format_number(rap_value) if isinstance(rap_value, (int, float)) else rap_value
current_display = f"{current_value:,}" if isinstance(current_value, (int, float)) else current_value
previous_display = format_number(previous_value) if isinstance(previous_value, (int, float)) else previous_value
hourly_rate_display = format_number(hourly_rate) if isinstance(hourly_rate, (int, float)) else hourly_rate
is_shiny = pet_name.startswith("Shiny ")
base_name = pet_name.replace("Shiny ", "") if is_shiny else pet_name
time_until_limited = None
if base_name in LIMITED_PETS:
time_until_limited = calculate_time_until_limited(base_name, current_value, hourly_rate)
jelly_prediction = None
if base_name in JELLY_LEAVE_TIMES:
jelly_prediction = calculate_jelly_prediction(base_name, current_value, hourly_rate)
value_change = current_value - previous_value if previous_value is not None else current_value
if is_shiny:
title = f"✨ {f'A **SHINY** {base_name} was' if value_change == 1 else f'{value_change} **SHINY** {base_name}s were'} rolled! ✨"
embed_color = discord.Color.from_rgb(255, 255, 255)
else:
title = f"🎲 {f'A {pet_name}' if value_change == 1 else f'{value_change} {pet_name}s'} were rolled! 🎲"
embed_color = discord.Color.blue() if not is_change else discord.Color.orange()
description = f"{pet_name} exists: **{current_display}**\n" \
f"Difficulty: **1 in {difficulty_display}**\n" \
f"RAP Value: **{rap_display}**\n" \
f"Hourly Rate: **{hourly_rate_display}/h**"
if time_until_limited is not None:
description += f"\nTime Remaining Until Limited: **{time_until_limited}**"
if base_name in LIMITED_PETS:
limit = LIMITED_PETS[base_name]
remaining = limit - current_value
if remaining > 0:
description += f"\nQuantity Remaining: **{remaining:,}**"
if jelly_prediction is not None:
description += f"\nEstimated Final Count: **{jelly_prediction['predicted_value']:,}**"
description += f"\nGoing Limited In: **{jelly_prediction['hours_remaining']}h**"
embed = discord.Embed(
title=title,
description=description,
color=embed_color
)
if pet_image_url:
if isinstance(pet_image_url, str):
if pet_image_url.startswith('rbxassetid://'):
asset_id = re.search(r'^\d+', pet_image_url.replace('rbxassetid://', '')).group(0)
pet_image_url = f"https://rbxgleaks.pythonanywhere.com/asset/{asset_id}"
print(f"Using image URL for {pet_name}: {pet_image_url}")
embed.set_thumbnail(url=pet_image_url)
try:
await channel.send(embed=embed)
except discord.HTTPException as e:
print(f"Failed to send embed for {pet_name}: {e}")
await channel.send(f"🎲 {'A' if value_change == 1 else value_change} {pet_name} was rolled! Exists: {current_display} (Previous: {previous_display})")
async def petdata(tracked_pets):
try:
response = requests.get(EXISTS_API)
if response.status_code == 200:
data = response.json()
if data['status'] == 'ok':
pet_values = {pet: 0 for pet in tracked_pets}
for pet in data['data']:
pet_id = pet['configData']['id']
is_shiny = pet['configData'].get('sh', False)
value = pet['value']
pet_name = f"Shiny {pet_id}" if is_shiny else pet_id
if pet_name in pet_values:
print(f"Found pet: {pet_name} with exist count {value}")
pet_values[pet_name] = value
return pet_values
print(f"Error code: {response.status_code}")
except Exception as e:
print(f"Error: {e}")
return None
async def main_loop():
channel = bot.get_channel(CHANNEL_ID)
if channel is None:
print("Invalid channel ID. Please check your channel ID.")
return
tracked_pets = await get_huge_secret_pets()
if not tracked_pets:
print("No pets fetched, retrying in 60 seconds...")
await asyncio.sleep(60)
return
lastknown = {pet: None for pet in tracked_pets}
print(f"Initially tracking {len(tracked_pets)} pets")
while True:
try:
if not tracked_pets:
tracked_pets = await get_huge_secret_pets() or []
lastknown.update({pet: None for pet in tracked_pets if pet not in lastknown})
await update_rap_values()
vvalues = await petdata(tracked_pets)
if vvalues is not None:
for pet, value in vvalues.items():
if lastknown[pet] is None:
print(f"Initial value for {pet}: {value}")
elif value != lastknown[pet]:
pet_changes[pet].append({
'timestamp': datetime.now(),
'value': value,
'previous': lastknown[pet]
})
await send_embed_message(channel, pet, lastknown[pet], value, is_change=True)
lastknown[pet] = value
else:
print("Broken check")
new_pets = await get_huge_secret_pets() or []
if new_pets and set(new_pets) != set(tracked_pets):
print("Pet list updated!")
tracked_pets = new_pets
lastknown.update({pet: None for pet in tracked_pets if pet not in lastknown})
await asyncio.sleep(60)
except Exception as e:
print(f"Error in main loop: {e}")
await asyncio.sleep(60)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
bot.loop.create_task(main_loop())
bot.run(TOKEN) |