Spaces:
Paused
Paused
Update ccc.py
Browse files
ccc.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
-
import
|
| 2 |
import discord
|
| 3 |
from discord.ext import commands
|
| 4 |
import asyncio
|
| 5 |
import json
|
| 6 |
import re
|
| 7 |
-
from collections import defaultdict
|
| 8 |
-
from collections import deque
|
| 9 |
from datetime import datetime, timedelta
|
| 10 |
import pytz
|
| 11 |
import os
|
|
@@ -46,14 +45,15 @@ bot = commands.Bot(command_prefix='!', intents=intents)
|
|
| 46 |
pet_images = {}
|
| 47 |
pet_difficulties = {}
|
| 48 |
pet_raps = {}
|
| 49 |
-
pet_changes =
|
| 50 |
-
recent_notifications = defaultdict(
|
| 51 |
|
| 52 |
-
async def fetch_exists_data():
|
| 53 |
try:
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
| 57 |
except Exception as e:
|
| 58 |
print(f"Error fetching exists data: {e}")
|
| 59 |
return []
|
|
@@ -74,323 +74,327 @@ def format_number(number):
|
|
| 74 |
else:
|
| 75 |
return f"{number/1000000000000:.1f}t"
|
| 76 |
|
| 77 |
-
async def fetch_pet_collection_data(pet_name):
|
| 78 |
try:
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
except Exception as e:
|
| 86 |
print(f"Error fetching pet collection data: {e}")
|
| 87 |
return None
|
| 88 |
|
| 89 |
-
async def fetch_pet_exists_data(pet_name):
|
| 90 |
try:
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
for pet_data in data:
|
| 104 |
-
config_data = pet_data.get('configData', {})
|
| 105 |
-
value = pet_data.get('value', 0)
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
-
|
| 112 |
-
if is_shiny and pt_value == 1:
|
| 113 |
-
variants['Shiny Golden'] = max(variants['Shiny Golden'], value)
|
| 114 |
-
elif is_shiny and pt_value == 2:
|
| 115 |
-
variants['Shiny Rainbow'] = max(variants['Shiny Rainbow'], value)
|
| 116 |
-
elif is_shiny:
|
| 117 |
-
variants['Shiny'] = max(variants['Shiny'], value)
|
| 118 |
-
elif pt_value == 1:
|
| 119 |
-
variants['Golden'] = max(variants['Golden'], value)
|
| 120 |
-
elif pt_value == 2:
|
| 121 |
-
variants['Rainbow'] = max(variants['Rainbow'], value)
|
| 122 |
-
else:
|
| 123 |
-
variants['Normal'] = max(variants['Normal'], value)
|
| 124 |
-
|
| 125 |
-
return variants
|
| 126 |
except Exception as e:
|
| 127 |
print(f"Error fetching exists data: {e}")
|
| 128 |
return None
|
| 129 |
|
| 130 |
@bot.command(name='petdata')
|
| 131 |
async def pet_data(ctx, *, pet_name):
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
if not collection_data or not exists_data:
|
| 137 |
-
await ctx.send("Pet does not exist!")
|
| 138 |
-
return
|
| 139 |
-
|
| 140 |
-
embed = discord.Embed(
|
| 141 |
-
title=collection_data.get('configName', 'Unknown Pet'),
|
| 142 |
-
color=int('11ff00', 16)
|
| 143 |
-
)
|
| 144 |
-
|
| 145 |
-
config_data = collection_data.get('configData', {})
|
| 146 |
-
|
| 147 |
-
description = f"**Index Description:** {config_data.get('indexDesc', 'N/A')}\n"
|
| 148 |
-
description += f"**Obtainable in Index:** {config_data.get('indexObtainable', 'N/A')}"
|
| 149 |
-
embed.description = description
|
| 150 |
-
|
| 151 |
-
total_exists = sum(exists_data.values())
|
| 152 |
-
|
| 153 |
-
exists_text = "\n".join([
|
| 154 |
-
f"{variant}: **{count:,}**"
|
| 155 |
-
for variant, count in exists_data.items() if count > 0
|
| 156 |
-
])
|
| 157 |
-
exists_text += f"\n\n**Total Exist: {total_exists:,}**"
|
| 158 |
-
|
| 159 |
-
embed.add_field(name="**Pet Exists:**", value=exists_text, inline=False)
|
| 160 |
-
|
| 161 |
-
thumbnail_url = config_data.get('thumbnail')
|
| 162 |
-
if thumbnail_url:
|
| 163 |
-
if thumbnail_url.startswith('rbxassetid://'):
|
| 164 |
-
asset_id = re.search(r'\d+', thumbnail_url.replace('rbxassetid://', '')).group(0)
|
| 165 |
-
thumbnail_url = f"https://rbxgleaks.pythonanywhere.com/asset/{asset_id}"
|
| 166 |
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
@bot.command(name='commonhuges')
|
| 172 |
async def common_huge_pets(ctx, count: int = 10):
|
| 173 |
if ctx.author.id != AUTHORIZED_USER_ID:
|
| 174 |
await ctx.send("You are not authorized to use this command.")
|
| 175 |
return
|
| 176 |
-
|
| 177 |
count = max(1, min(count, 25))
|
| 178 |
-
|
| 179 |
-
exists_data = await fetch_exists_data()
|
| 180 |
-
if not exists_data:
|
| 181 |
-
await ctx.send("Could not retrieve pet data. Please try again later.")
|
| 182 |
-
return
|
| 183 |
-
|
| 184 |
-
huge_pet_counts = defaultdict(int)
|
| 185 |
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
| 189 |
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
if is_shiny and pt_value == 1:
|
| 197 |
-
variant_key = f"Shiny Golden {pet_name}"
|
| 198 |
-
elif is_shiny and pt_value == 2:
|
| 199 |
-
variant_key = f"Shiny Rainbow {pet_name}"
|
| 200 |
-
elif is_shiny:
|
| 201 |
-
variant_key = f"Shiny {pet_name}"
|
| 202 |
-
elif pt_value == 1:
|
| 203 |
-
variant_key = f"Golden {pet_name}"
|
| 204 |
-
elif pt_value == 2:
|
| 205 |
-
variant_key = f"Rainbow {pet_name}"
|
| 206 |
-
else:
|
| 207 |
-
variant_key = f"Normal {pet_name}"
|
| 208 |
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
@bot.command(name='commontitanics')
|
| 228 |
async def common_titanic_pets(ctx, count: int = 10):
|
| 229 |
if ctx.author.id != AUTHORIZED_USER_ID:
|
| 230 |
await ctx.send("You are not authorized to use this command.")
|
| 231 |
return
|
| 232 |
-
|
| 233 |
count = max(1, min(count, 25))
|
| 234 |
-
|
| 235 |
-
exists_data = await fetch_exists_data()
|
| 236 |
-
if not exists_data:
|
| 237 |
-
await ctx.send("Could not retrieve pet data. Please try again later.")
|
| 238 |
-
return
|
| 239 |
-
|
| 240 |
-
huge_pet_counts = defaultdict(int)
|
| 241 |
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
|
|
|
|
|
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
if is_shiny and pt_value == 1:
|
| 253 |
-
variant_key = f"Shiny Golden {pet_name}"
|
| 254 |
-
elif is_shiny and pt_value == 2:
|
| 255 |
-
variant_key = f"Shiny Rainbow {pet_name}"
|
| 256 |
-
elif is_shiny:
|
| 257 |
-
variant_key = f"Shiny {pet_name}"
|
| 258 |
-
elif pt_value == 1:
|
| 259 |
-
variant_key = f"Golden {pet_name}"
|
| 260 |
-
elif pt_value == 2:
|
| 261 |
-
variant_key = f"Rainbow {pet_name}"
|
| 262 |
-
else:
|
| 263 |
-
variant_key = f"Normal {pet_name}"
|
| 264 |
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
|
| 283 |
@bot.command(name='leastcommonhuges')
|
| 284 |
async def least_common_huge_pets(ctx, count: int = 10):
|
| 285 |
if ctx.author.id != AUTHORIZED_USER_ID:
|
| 286 |
await ctx.send("You are not authorized to use this command.")
|
| 287 |
return
|
| 288 |
-
|
| 289 |
count = max(1, min(count, 25))
|
| 290 |
-
|
| 291 |
-
exists_data = await fetch_exists_data()
|
| 292 |
-
if not exists_data:
|
| 293 |
-
await ctx.send("Could not retrieve pet data. Please try again later.")
|
| 294 |
-
return
|
| 295 |
-
|
| 296 |
-
huge_pet_counts = defaultdict(int)
|
| 297 |
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
|
|
|
|
|
|
| 301 |
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
if is_shiny and pt_value == 1:
|
| 309 |
-
variant_key = f"Shiny Golden {pet_name}"
|
| 310 |
-
elif is_shiny and pt_value == 2:
|
| 311 |
-
variant_key = f"Shiny Rainbow {pet_name}"
|
| 312 |
-
elif is_shiny:
|
| 313 |
-
variant_key = f"Shiny {pet_name}"
|
| 314 |
-
elif pt_value == 1:
|
| 315 |
-
variant_key = f"Golden {pet_name}"
|
| 316 |
-
elif pt_value == 2:
|
| 317 |
-
variant_key = f"Rainbow {pet_name}"
|
| 318 |
-
else:
|
| 319 |
-
variant_key = f"Normal {pet_name}"
|
| 320 |
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
|
| 339 |
@bot.command(name='leastcommontitanics')
|
| 340 |
async def least_common_titanic_pets(ctx, count: int = 10):
|
| 341 |
if ctx.author.id != AUTHORIZED_USER_ID:
|
| 342 |
await ctx.send("You are not authorized to use this command.")
|
| 343 |
return
|
| 344 |
-
|
| 345 |
count = max(1, min(count, 25))
|
| 346 |
-
|
| 347 |
-
exists_data = await fetch_exists_data()
|
| 348 |
-
if not exists_data:
|
| 349 |
-
await ctx.send("Could not retrieve pet data. Please try again later.")
|
| 350 |
-
return
|
| 351 |
-
|
| 352 |
-
titanic_pet_counts = defaultdict(int)
|
| 353 |
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
|
|
|
|
|
|
| 357 |
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
if is_shiny and pt_value == 1:
|
| 365 |
-
variant_key = f"Shiny Golden {pet_name}"
|
| 366 |
-
elif is_shiny and pt_value == 2:
|
| 367 |
-
variant_key = f"Shiny Rainbow {pet_name}"
|
| 368 |
-
elif is_shiny:
|
| 369 |
-
variant_key = f"Shiny {pet_name}"
|
| 370 |
-
elif pt_value == 1:
|
| 371 |
-
variant_key = f"Golden {pet_name}"
|
| 372 |
-
elif pt_value == 2:
|
| 373 |
-
variant_key = f"Rainbow {pet_name}"
|
| 374 |
-
else:
|
| 375 |
-
variant_key = f"Normal {pet_name}"
|
| 376 |
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 394 |
|
| 395 |
def calculate_jelly_prediction(pet_name, current_value, hourly_rate):
|
| 396 |
if pet_name not in JELLY_LEAVE_TIMES:
|
|
@@ -448,39 +452,39 @@ async def send_rap_change_notification(channel, item_name, previous_rap, current
|
|
| 448 |
f"Current RAP: {current_rap:,}"
|
| 449 |
await channel.send(message)
|
| 450 |
|
| 451 |
-
async def update_rap_values():
|
| 452 |
try:
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
monitored_key = f"Shiny {pet_id}" if is_shiny else pet_id
|
| 468 |
-
|
| 469 |
-
if monitored_key in last_rap_values:
|
| 470 |
-
current_rap = value
|
| 471 |
-
previous_rap = last_rap_values[monitored_key]
|
| 472 |
|
| 473 |
-
|
| 474 |
-
await send_rap_change_notification(monitored_channel, monitored_key, previous_rap, current_rap)
|
| 475 |
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
except Exception as e:
|
| 485 |
print(f"Error fetching RAP values: {e}")
|
| 486 |
|
|
@@ -507,36 +511,36 @@ def calculate_hourly_rate(pet_name):
|
|
| 507 |
|
| 508 |
return 1
|
| 509 |
|
| 510 |
-
async def get_huge_secret_pets():
|
| 511 |
try:
|
| 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 |
except Exception as e:
|
| 541 |
print(f"Error fetching pets list: {e}")
|
| 542 |
return []
|
|
@@ -549,7 +553,7 @@ async def send_embed_message(channel, pet_name, previous_value, current_value, i
|
|
| 549 |
return
|
| 550 |
|
| 551 |
if pet_name not in recent_notifications:
|
| 552 |
-
recent_notifications[pet_name] =
|
| 553 |
recent_notifications[pet_name].append(notification_key)
|
| 554 |
|
| 555 |
pet_image_url = pet_images.get(pet_name, None)
|
|
@@ -622,28 +626,27 @@ async def send_embed_message(channel, pet_name, previous_value, current_value, i
|
|
| 622 |
print(f"Failed to send embed for {pet_name}: {e}")
|
| 623 |
await channel.send(f"🎲 {'A' if value_change == 1 else value_change} {pet_name} was rolled! Exists: {current_display} (Previous: {previous_display})")
|
| 624 |
|
| 625 |
-
async def petdata(tracked_pets):
|
| 626 |
try:
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
print(f"Error code: {response.status_code}")
|
| 645 |
except Exception as e:
|
| 646 |
-
print(f"Error: {e}")
|
| 647 |
return None
|
| 648 |
|
| 649 |
async def main_loop():
|
|
@@ -652,54 +655,51 @@ async def main_loop():
|
|
| 652 |
print("Invalid channel ID. Please check your channel ID.")
|
| 653 |
return
|
| 654 |
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
tracked_pets = await get_huge_secret_pets() or []
|
| 669 |
-
lastknown.update({pet: None for pet in tracked_pets if pet not in lastknown})
|
| 670 |
-
|
| 671 |
-
await update_rap_values()
|
| 672 |
-
|
| 673 |
-
vvalues = await petdata(tracked_pets)
|
| 674 |
-
if vvalues is not None:
|
| 675 |
-
for pet, value in vvalues.items():
|
| 676 |
-
if lastknown[pet] is None:
|
| 677 |
-
print(f"Initial value for {pet}: {value}")
|
| 678 |
-
elif value != lastknown[pet]:
|
| 679 |
-
pet_changes[pet].append({
|
| 680 |
-
'timestamp': datetime.now(),
|
| 681 |
-
'value': value,
|
| 682 |
-
'previous': lastknown[pet]
|
| 683 |
-
})
|
| 684 |
-
await send_embed_message(channel, pet, lastknown[pet], value, is_change=True)
|
| 685 |
-
lastknown[pet] = value
|
| 686 |
-
else:
|
| 687 |
-
print("Broken check")
|
| 688 |
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 694 |
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
print(f"Error in main loop: {e}")
|
| 699 |
-
await asyncio.sleep(60)
|
| 700 |
|
| 701 |
@bot.event
|
| 702 |
async def on_ready():
|
| 703 |
print(f'Logged in as {bot.user.name}')
|
| 704 |
bot.loop.create_task(main_loop())
|
| 705 |
-
|
|
|
|
|
|
| 1 |
+
import aiohttp
|
| 2 |
import discord
|
| 3 |
from discord.ext import commands
|
| 4 |
import asyncio
|
| 5 |
import json
|
| 6 |
import re
|
| 7 |
+
from collections import defaultdict, deque
|
|
|
|
| 8 |
from datetime import datetime, timedelta
|
| 9 |
import pytz
|
| 10 |
import os
|
|
|
|
| 45 |
pet_images = {}
|
| 46 |
pet_difficulties = {}
|
| 47 |
pet_raps = {}
|
| 48 |
+
pet_changes = defaultdict(deque)
|
| 49 |
+
recent_notifications = defaultdict(deque)
|
| 50 |
|
| 51 |
+
async def fetch_exists_data(session):
|
| 52 |
try:
|
| 53 |
+
async with session.get(EXISTS_API) as response:
|
| 54 |
+
if response.status == 200:
|
| 55 |
+
data = await response.json()
|
| 56 |
+
return data.get('data', [])
|
| 57 |
except Exception as e:
|
| 58 |
print(f"Error fetching exists data: {e}")
|
| 59 |
return []
|
|
|
|
| 74 |
else:
|
| 75 |
return f"{number/1000000000000:.1f}t"
|
| 76 |
|
| 77 |
+
async def fetch_pet_collection_data(session, pet_name):
|
| 78 |
try:
|
| 79 |
+
async with session.get('https://collectionpet.deno.dev') as response:
|
| 80 |
+
if response.status == 200:
|
| 81 |
+
data = await response.json()
|
| 82 |
+
for pet in data.get('data', []):
|
| 83 |
+
if pet.get('configName', '').lower() == pet_name.lower():
|
| 84 |
+
return pet
|
| 85 |
except Exception as e:
|
| 86 |
print(f"Error fetching pet collection data: {e}")
|
| 87 |
return None
|
| 88 |
|
| 89 |
+
async def fetch_pet_exists_data(session, pet_name):
|
| 90 |
try:
|
| 91 |
+
async with session.get('https://biggamesexists.deno.dev') as response:
|
| 92 |
+
if response.status == 200:
|
| 93 |
+
data = await response.json()
|
| 94 |
+
variants = {
|
| 95 |
+
'Normal': 0,
|
| 96 |
+
'Golden': 0,
|
| 97 |
+
'Rainbow': 0,
|
| 98 |
+
'Shiny': 0,
|
| 99 |
+
'Shiny Golden': 0,
|
| 100 |
+
'Shiny Rainbow': 0
|
| 101 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
+
for pet_data in data.get('data', []):
|
| 104 |
+
config_data = pet_data.get('configData', {})
|
| 105 |
+
value = pet_data.get('value', 0)
|
| 106 |
+
|
| 107 |
+
pet_id = config_data.get('id', '')
|
| 108 |
+
is_shiny = config_data.get('sh', False)
|
| 109 |
+
pt_value = config_data.get('pt', 0)
|
| 110 |
+
|
| 111 |
+
if pet_id.lower() == pet_name.lower():
|
| 112 |
+
if is_shiny and pt_value == 1:
|
| 113 |
+
variants['Shiny Golden'] = max(variants['Shiny Golden'], value)
|
| 114 |
+
elif is_shiny and pt_value == 2:
|
| 115 |
+
variants['Shiny Rainbow'] = max(variants['Shiny Rainbow'], value)
|
| 116 |
+
elif is_shiny:
|
| 117 |
+
variants['Shiny'] = max(variants['Shiny'], value)
|
| 118 |
+
elif pt_value == 1:
|
| 119 |
+
variants['Golden'] = max(variants['Golden'], value)
|
| 120 |
+
elif pt_value == 2:
|
| 121 |
+
variants['Rainbow'] = max(variants['Rainbow'], value)
|
| 122 |
+
else:
|
| 123 |
+
variants['Normal'] = max(variants['Normal'], value)
|
| 124 |
|
| 125 |
+
return variants
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
except Exception as e:
|
| 127 |
print(f"Error fetching exists data: {e}")
|
| 128 |
return None
|
| 129 |
|
| 130 |
@bot.command(name='petdata')
|
| 131 |
async def pet_data(ctx, *, pet_name):
|
| 132 |
+
async with aiohttp.ClientSession() as session:
|
| 133 |
+
collection_data = await fetch_pet_collection_data(session, pet_name)
|
| 134 |
+
exists_data = await fetch_pet_exists_data(session, pet_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
+
if not collection_data or not exists_data:
|
| 137 |
+
await ctx.send("Pet does not exist!")
|
| 138 |
+
return
|
| 139 |
+
|
| 140 |
+
embed = discord.Embed(
|
| 141 |
+
title=collection_data.get('configName', 'Unknown Pet'),
|
| 142 |
+
color=int('11ff00', 16)
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
config_data = collection_data.get('configData', {})
|
| 146 |
+
|
| 147 |
+
description = f"**Index Description:** {config_data.get('indexDesc', 'N/A')}\n"
|
| 148 |
+
description += f"**Obtainable in Index:** {config_data.get('indexObtainable', 'N/A')}"
|
| 149 |
+
embed.description = description
|
| 150 |
+
|
| 151 |
+
total_exists = sum(exists_data.values())
|
| 152 |
+
|
| 153 |
+
exists_text = "\n".join([
|
| 154 |
+
f"{variant}: **{count:,}**"
|
| 155 |
+
for variant, count in exists_data.items() if count > 0
|
| 156 |
+
])
|
| 157 |
+
exists_text += f"\n\n**Total Exist: {total_exists:,}**"
|
| 158 |
+
|
| 159 |
+
embed.add_field(name="**Pet Exists:**", value=exists_text, inline=False)
|
| 160 |
+
|
| 161 |
+
thumbnail_url = config_data.get('thumbnail')
|
| 162 |
+
if thumbnail_url:
|
| 163 |
+
if thumbnail_url.startswith('rbxassetid://'):
|
| 164 |
+
asset_id = re.search(r'\d+', thumbnail_url.replace('rbxassetid://', '')).group(0)
|
| 165 |
+
thumbnail_url = f"https://rbxgleaks.pythonanywhere.com/asset/{asset_id}"
|
| 166 |
+
|
| 167 |
+
embed.set_image(url=thumbnail_url)
|
| 168 |
+
|
| 169 |
+
await ctx.send(embed=embed)
|
| 170 |
|
| 171 |
@bot.command(name='commonhuges')
|
| 172 |
async def common_huge_pets(ctx, count: int = 10):
|
| 173 |
if ctx.author.id != AUTHORIZED_USER_ID:
|
| 174 |
await ctx.send("You are not authorized to use this command.")
|
| 175 |
return
|
| 176 |
+
|
| 177 |
count = max(1, min(count, 25))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
+
async with aiohttp.ClientSession() as session:
|
| 180 |
+
exists_data = await fetch_exists_data(session)
|
| 181 |
+
if not exists_data:
|
| 182 |
+
await ctx.send("Could not retrieve pet data. Please try again later.")
|
| 183 |
+
return
|
| 184 |
|
| 185 |
+
huge_pet_counts = defaultdict(int)
|
| 186 |
+
|
| 187 |
+
for pet in exists_data:
|
| 188 |
+
config_data = pet.get('configData', {})
|
| 189 |
+
value = pet.get('value', 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
+
if config_data.get('id', '').startswith('Huge'):
|
| 192 |
+
pet_name = config_data.get('id', 'Unknown')
|
| 193 |
+
|
| 194 |
+
is_shiny = config_data.get('sh', False)
|
| 195 |
+
pt_value = config_data.get('pt', 0)
|
| 196 |
+
|
| 197 |
+
if is_shiny and pt_value == 1:
|
| 198 |
+
variant_key = f"Shiny Golden {pet_name}"
|
| 199 |
+
elif is_shiny and pt_value == 2:
|
| 200 |
+
variant_key = f"Shiny Rainbow {pet_name}"
|
| 201 |
+
elif is_shiny:
|
| 202 |
+
variant_key = f"Shiny {pet_name}"
|
| 203 |
+
elif pt_value == 1:
|
| 204 |
+
variant_key = f"Golden {pet_name}"
|
| 205 |
+
elif pt_value == 2:
|
| 206 |
+
variant_key = f"Rainbow {pet_name}"
|
| 207 |
+
else:
|
| 208 |
+
variant_key = f"Normal {pet_name}"
|
| 209 |
+
|
| 210 |
+
huge_pet_counts[variant_key] = max(huge_pet_counts[variant_key], value)
|
| 211 |
+
|
| 212 |
+
sorted_huge_pets = sorted(huge_pet_counts.items(), key=lambda x: x[1], reverse=True)
|
| 213 |
+
|
| 214 |
+
embed = discord.Embed(title=f"Top {count} Most Common Huge Pets", color=discord.Color.blue())
|
| 215 |
+
|
| 216 |
+
if sorted_huge_pets:
|
| 217 |
+
for i, (pet_name, count_value) in enumerate(sorted_huge_pets[:count], 1):
|
| 218 |
+
embed.add_field(
|
| 219 |
+
name=f"{i}. {pet_name}",
|
| 220 |
+
value=f"Exists: **{format_number(count_value)}**",
|
| 221 |
+
inline=False
|
| 222 |
+
)
|
| 223 |
+
else:
|
| 224 |
+
embed.description = "No huge pets found in the data."
|
| 225 |
+
|
| 226 |
+
await ctx.send(embed=embed)
|
| 227 |
|
| 228 |
@bot.command(name='commontitanics')
|
| 229 |
async def common_titanic_pets(ctx, count: int = 10):
|
| 230 |
if ctx.author.id != AUTHORIZED_USER_ID:
|
| 231 |
await ctx.send("You are not authorized to use this command.")
|
| 232 |
return
|
| 233 |
+
|
| 234 |
count = max(1, min(count, 25))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
+
async with aiohttp.ClientSession() as session:
|
| 237 |
+
exists_data = await fetch_exists_data(session)
|
| 238 |
+
if not exists_data:
|
| 239 |
+
await ctx.send("Could not retrieve pet data. Please try again later.")
|
| 240 |
+
return
|
| 241 |
|
| 242 |
+
titanic_pet_counts = defaultdict(int)
|
| 243 |
+
|
| 244 |
+
for pet in exists_data:
|
| 245 |
+
config_data = pet.get('configData', {})
|
| 246 |
+
value = pet.get('value', 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
+
if config_data.get('id', '').startswith('Titanic'):
|
| 249 |
+
pet_name = config_data.get('id', 'Unknown')
|
| 250 |
+
|
| 251 |
+
is_shiny = config_data.get('sh', False)
|
| 252 |
+
pt_value = config_data.get('pt', 0)
|
| 253 |
+
|
| 254 |
+
if is_shiny and pt_value == 1:
|
| 255 |
+
variant_key = f"Shiny Golden {pet_name}"
|
| 256 |
+
elif is_shiny and pt_value == 2:
|
| 257 |
+
variant_key = f"Shiny Rainbow {pet_name}"
|
| 258 |
+
elif is_shiny:
|
| 259 |
+
variant_key = f"Shiny {pet_name}"
|
| 260 |
+
elif pt_value == 1:
|
| 261 |
+
variant_key = f"Golden {pet_name}"
|
| 262 |
+
elif pt_value == 2:
|
| 263 |
+
variant_key = f"Rainbow {pet_name}"
|
| 264 |
+
else:
|
| 265 |
+
variant_key = f"Normal {pet_name}"
|
| 266 |
+
|
| 267 |
+
titanic_pet_counts[variant_key] = max(titanic_pet_counts[variant_key], value)
|
| 268 |
+
|
| 269 |
+
sorted_titanic_pets = sorted(titanic_pet_counts.items(), key=lambda x: x[1], reverse=True)
|
| 270 |
+
|
| 271 |
+
embed = discord.Embed(title=f"Top {count} Most Common Titanic Pets", color=discord.Color.blue())
|
| 272 |
+
|
| 273 |
+
if sorted_titanic_pets:
|
| 274 |
+
for i, (pet_name, count_value) in enumerate(sorted_titanic_pets[:count], 1):
|
| 275 |
+
embed.add_field(
|
| 276 |
+
name=f"{i}. {pet_name}",
|
| 277 |
+
value=f"Exists: **{format_number(count_value)}**",
|
| 278 |
+
inline=False
|
| 279 |
+
)
|
| 280 |
+
else:
|
| 281 |
+
embed.description = "No titanic pets found in the data."
|
| 282 |
+
|
| 283 |
+
await ctx.send(embed=embed)
|
| 284 |
|
| 285 |
@bot.command(name='leastcommonhuges')
|
| 286 |
async def least_common_huge_pets(ctx, count: int = 10):
|
| 287 |
if ctx.author.id != AUTHORIZED_USER_ID:
|
| 288 |
await ctx.send("You are not authorized to use this command.")
|
| 289 |
return
|
| 290 |
+
|
| 291 |
count = max(1, min(count, 25))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
|
| 293 |
+
async with aiohttp.ClientSession() as session:
|
| 294 |
+
exists_data = await fetch_exists_data(session)
|
| 295 |
+
if not exists_data:
|
| 296 |
+
await ctx.send("Could not retrieve pet data. Please try again later.")
|
| 297 |
+
return
|
| 298 |
|
| 299 |
+
huge_pet_counts = defaultdict(int)
|
| 300 |
+
|
| 301 |
+
for pet in exists_data:
|
| 302 |
+
config_data = pet.get('configData', {})
|
| 303 |
+
value = pet.get('value', 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
+
if config_data.get('id', '').startswith('Huge'):
|
| 306 |
+
pet_name = config_data.get('id', 'Unknown')
|
| 307 |
+
|
| 308 |
+
is_shiny = config_data.get('sh', False)
|
| 309 |
+
pt_value = config_data.get('pt', 0)
|
| 310 |
+
|
| 311 |
+
if is_shiny and pt_value == 1:
|
| 312 |
+
variant_key = f"Shiny Golden {pet_name}"
|
| 313 |
+
elif is_shiny and pt_value == 2:
|
| 314 |
+
variant_key = f"Shiny Rainbow {pet_name}"
|
| 315 |
+
elif is_shiny:
|
| 316 |
+
variant_key = f"Shiny {pet_name}"
|
| 317 |
+
elif pt_value == 1:
|
| 318 |
+
variant_key = f"Golden {pet_name}"
|
| 319 |
+
elif pt_value == 2:
|
| 320 |
+
variant_key = f"Rainbow {pet_name}"
|
| 321 |
+
else:
|
| 322 |
+
variant_key = f"Normal {pet_name}"
|
| 323 |
+
|
| 324 |
+
huge_pet_counts[variant_key] = max(huge_pet_counts[variant_key], value)
|
| 325 |
+
|
| 326 |
+
sorted_huge_pets = sorted(huge_pet_counts.items(), key=lambda x: x[1])
|
| 327 |
+
|
| 328 |
+
embed = discord.Embed(title=f"Top {count} Least Common Huge Pets", color=discord.Color.dark_red())
|
| 329 |
+
|
| 330 |
+
if sorted_huge_pets:
|
| 331 |
+
for i, (pet_name, count_value) in enumerate(sorted_huge_pets[:count], 1):
|
| 332 |
+
embed.add_field(
|
| 333 |
+
name=f"{i}. {pet_name}",
|
| 334 |
+
value=f"Exists: **{format_number(count_value)}**",
|
| 335 |
+
inline=False
|
| 336 |
+
)
|
| 337 |
+
else:
|
| 338 |
+
embed.description = "No huge pets found in the data."
|
| 339 |
+
|
| 340 |
+
await ctx.send(embed=embed)
|
| 341 |
|
| 342 |
@bot.command(name='leastcommontitanics')
|
| 343 |
async def least_common_titanic_pets(ctx, count: int = 10):
|
| 344 |
if ctx.author.id != AUTHORIZED_USER_ID:
|
| 345 |
await ctx.send("You are not authorized to use this command.")
|
| 346 |
return
|
| 347 |
+
|
| 348 |
count = max(1, min(count, 25))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
|
| 350 |
+
async with aiohttp.ClientSession() as session:
|
| 351 |
+
exists_data = await fetch_exists_data(session)
|
| 352 |
+
if not exists_data:
|
| 353 |
+
await ctx.send("Could not retrieve pet data. Please try again later.")
|
| 354 |
+
return
|
| 355 |
|
| 356 |
+
titanic_pet_counts = defaultdict(int)
|
| 357 |
+
|
| 358 |
+
for pet in exists_data:
|
| 359 |
+
config_data = pet.get('configData', {})
|
| 360 |
+
value = pet.get('value', 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
|
| 362 |
+
if config_data.get('id', '').startswith('Titanic'):
|
| 363 |
+
pet_name = config_data.get('id', 'Unknown')
|
| 364 |
+
|
| 365 |
+
is_shiny = config_data.get('sh', False)
|
| 366 |
+
pt_value = config_data.get('pt', 0)
|
| 367 |
+
|
| 368 |
+
if is_shiny and pt_value == 1:
|
| 369 |
+
variant_key = f"Shiny Golden {pet_name}"
|
| 370 |
+
elif is_shiny and pt_value == 2:
|
| 371 |
+
variant_key = f"Shiny Rainbow {pet_name}"
|
| 372 |
+
elif is_shiny:
|
| 373 |
+
variant_key = f"Shiny {pet_name}"
|
| 374 |
+
elif pt_value == 1:
|
| 375 |
+
variant_key = f"Golden {pet_name}"
|
| 376 |
+
elif pt_value == 2:
|
| 377 |
+
variant_key = f"Rainbow {pet_name}"
|
| 378 |
+
else:
|
| 379 |
+
variant_key = f"Normal {pet_name}"
|
| 380 |
+
|
| 381 |
+
titanic_pet_counts[variant_key] = max(titanic_pet_counts[variant_key], value)
|
| 382 |
+
|
| 383 |
+
sorted_titanic_pets = sorted(titanic_pet_counts.items(), key=lambda x: x[1])
|
| 384 |
+
|
| 385 |
+
embed = discord.Embed(title=f"Top {count} Least Common Titanic Pets", color=discord.Color.dark_red())
|
| 386 |
+
|
| 387 |
+
if sorted_titanic_pets:
|
| 388 |
+
for i, (pet_name, count_value) in enumerate(sorted_titanic_pets[:count], 1):
|
| 389 |
+
embed.add_field(
|
| 390 |
+
name=f"{i}. {pet_name}",
|
| 391 |
+
value=f"Exists: **{format_number(count_value)}**",
|
| 392 |
+
inline=False
|
| 393 |
+
)
|
| 394 |
+
else:
|
| 395 |
+
embed.description = "No titanic pets found in the data."
|
| 396 |
+
|
| 397 |
+
await ctx.send(embed=embed)
|
| 398 |
|
| 399 |
def calculate_jelly_prediction(pet_name, current_value, hourly_rate):
|
| 400 |
if pet_name not in JELLY_LEAVE_TIMES:
|
|
|
|
| 452 |
f"Current RAP: {current_rap:,}"
|
| 453 |
await channel.send(message)
|
| 454 |
|
| 455 |
+
async def update_rap_values(session):
|
| 456 |
try:
|
| 457 |
+
async with session.get(RAP_API) as response:
|
| 458 |
+
if response.status == 200:
|
| 459 |
+
data = await response.json()
|
| 460 |
+
if data['status'] == 'ok':
|
| 461 |
+
pet_raps.clear()
|
| 462 |
+
|
| 463 |
+
monitored_channel = bot.get_channel(MONITORED_ITEMS_CHANNEL_ID)
|
| 464 |
+
if monitored_channel:
|
| 465 |
+
for pet_data in data['data']:
|
| 466 |
+
config_data = pet_data['configData']
|
| 467 |
+
pet_id = config_data['id']
|
| 468 |
+
value = pet_data['value']
|
| 469 |
+
is_shiny = config_data.get('sh', False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
|
| 471 |
+
monitored_key = f"Shiny {pet_id}" if is_shiny else pet_id
|
|
|
|
| 472 |
|
| 473 |
+
if monitored_key in last_rap_values:
|
| 474 |
+
current_rap = value
|
| 475 |
+
previous_rap = last_rap_values[monitored_key]
|
| 476 |
+
|
| 477 |
+
if previous_rap is not None and current_rap != previous_rap:
|
| 478 |
+
await send_rap_change_notification(monitored_channel, monitored_key, previous_rap, current_rap)
|
| 479 |
+
|
| 480 |
+
last_rap_values[monitored_key] = current_rap
|
| 481 |
+
|
| 482 |
+
if is_shiny:
|
| 483 |
+
pet_raps[f"Shiny {pet_id}"] = value
|
| 484 |
+
else:
|
| 485 |
+
pet_raps[pet_id] = value
|
| 486 |
+
|
| 487 |
+
print(f"Updated RAP values for {len(data['data'])} pets and items")
|
| 488 |
except Exception as e:
|
| 489 |
print(f"Error fetching RAP values: {e}")
|
| 490 |
|
|
|
|
| 511 |
|
| 512 |
return 1
|
| 513 |
|
| 514 |
+
async def get_huge_secret_pets(session):
|
| 515 |
try:
|
| 516 |
+
async with session.get(PETS_API) as response:
|
| 517 |
+
if response.status == 200:
|
| 518 |
+
data = await response.json()
|
| 519 |
+
if data['status'] == 'ok':
|
| 520 |
+
huge_secret_pets = []
|
| 521 |
+
|
| 522 |
+
for pet in data['data']:
|
| 523 |
+
config_data = pet['configData']
|
| 524 |
+
if config_data.get('huge') or config_data.get('secret'):
|
| 525 |
+
pet_name = config_data['name']
|
| 526 |
+
huge_secret_pets.append(pet_name)
|
| 527 |
+
huge_secret_pets.append(f"Shiny {pet_name}")
|
| 528 |
+
|
| 529 |
+
difficulty = config_data.get('difficulty', 'Unknown')
|
| 530 |
+
pet_difficulties[pet_name] = difficulty
|
| 531 |
+
pet_difficulties[f"Shiny {pet_name}"] = difficulty * 100
|
| 532 |
+
|
| 533 |
+
if 'thumbnail' in config_data:
|
| 534 |
+
pet_images[pet_name] = config_data['thumbnail']
|
| 535 |
+
pet_images[f"Shiny {pet_name}"] = config_data['thumbnail']
|
| 536 |
+
print(f"Stored image URL for {pet_name}: {config_data['thumbnail']}")
|
| 537 |
+
|
| 538 |
+
for pet_name in huge_secret_pets:
|
| 539 |
+
if pet_name not in pet_changes:
|
| 540 |
+
pet_changes[pet_name] = deque(maxlen=100)
|
| 541 |
+
|
| 542 |
+
print(f"Found {len(huge_secret_pets)} pets to track (including shiny versions)")
|
| 543 |
+
return huge_secret_pets
|
| 544 |
except Exception as e:
|
| 545 |
print(f"Error fetching pets list: {e}")
|
| 546 |
return []
|
|
|
|
| 553 |
return
|
| 554 |
|
| 555 |
if pet_name not in recent_notifications:
|
| 556 |
+
recent_notifications[pet_name] = deque(maxlen=5)
|
| 557 |
recent_notifications[pet_name].append(notification_key)
|
| 558 |
|
| 559 |
pet_image_url = pet_images.get(pet_name, None)
|
|
|
|
| 626 |
print(f"Failed to send embed for {pet_name}: {e}")
|
| 627 |
await channel.send(f"🎲 {'A' if value_change == 1 else value_change} {pet_name} was rolled! Exists: {current_display} (Previous: {previous_display})")
|
| 628 |
|
| 629 |
+
async def petdata(session, tracked_pets):
|
| 630 |
try:
|
| 631 |
+
async with session.get(EXISTS_API) as response:
|
| 632 |
+
if response.status == 200:
|
| 633 |
+
data = await response.json()
|
| 634 |
+
if data['status'] == 'ok':
|
| 635 |
+
pet_values = {pet: 0 for pet in tracked_pets}
|
| 636 |
+
|
| 637 |
+
for pet in data['data']:
|
| 638 |
+
pet_id = pet['configData']['id']
|
| 639 |
+
is_shiny = pet['configData'].get('sh', False)
|
| 640 |
+
value = pet['value']
|
| 641 |
+
|
| 642 |
+
pet_name = f"Shiny {pet_id}" if is_shiny else pet_id
|
| 643 |
+
if pet_name in pet_values:
|
| 644 |
+
print(f"Found pet: {pet_name} with exist count {value}")
|
| 645 |
+
pet_values[pet_name] = value
|
| 646 |
+
|
| 647 |
+
return pet_values
|
|
|
|
| 648 |
except Exception as e:
|
| 649 |
+
print(f"Error fetching pet data: {e}")
|
| 650 |
return None
|
| 651 |
|
| 652 |
async def main_loop():
|
|
|
|
| 655 |
print("Invalid channel ID. Please check your channel ID.")
|
| 656 |
return
|
| 657 |
|
| 658 |
+
async with aiohttp.ClientSession() as session:
|
| 659 |
+
tracked_pets = await get_huge_secret_pets(session)
|
| 660 |
+
if not tracked_pets:
|
| 661 |
+
print("No pets fetched, retrying in 60 seconds...")
|
| 662 |
+
await asyncio.sleep(60)
|
| 663 |
+
return
|
| 664 |
+
|
| 665 |
+
lastknown = {pet: None for pet in tracked_pets}
|
| 666 |
+
print(f"Initially tracking {len(tracked_pets)} pets")
|
| 667 |
+
|
| 668 |
+
while True:
|
| 669 |
+
try:
|
| 670 |
+
await update_rap_values(session)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 671 |
|
| 672 |
+
vvalues = await petdata(session, tracked_pets)
|
| 673 |
+
if vvalues is not None:
|
| 674 |
+
for pet, value in vvalues.items():
|
| 675 |
+
if lastknown[pet] is None:
|
| 676 |
+
print(f"Initial value for {pet}: {value}")
|
| 677 |
+
elif value != lastknown[pet]:
|
| 678 |
+
pet_changes[pet].append({
|
| 679 |
+
'timestamp': datetime.now(),
|
| 680 |
+
'value': value,
|
| 681 |
+
'previous': lastknown[pet]
|
| 682 |
+
})
|
| 683 |
+
await send_embed_message(channel, pet, lastknown[pet], value, is_change=True)
|
| 684 |
+
lastknown[pet] = value
|
| 685 |
+
else:
|
| 686 |
+
print("Broken check")
|
| 687 |
+
|
| 688 |
+
new_pets = await get_huge_secret_pets(session)
|
| 689 |
+
if new_pets and set(new_pets) != set(tracked_pets):
|
| 690 |
+
print("Pet list updated!")
|
| 691 |
+
tracked_pets = new_pets
|
| 692 |
+
lastknown.update({pet: None for pet in tracked_pets if pet not in lastknown})
|
| 693 |
+
|
| 694 |
+
await asyncio.sleep(60)
|
| 695 |
|
| 696 |
+
except Exception as e:
|
| 697 |
+
print(f"Error in main loop: {e}")
|
| 698 |
+
await asyncio.sleep(60)
|
|
|
|
|
|
|
| 699 |
|
| 700 |
@bot.event
|
| 701 |
async def on_ready():
|
| 702 |
print(f'Logged in as {bot.user.name}')
|
| 703 |
bot.loop.create_task(main_loop())
|
| 704 |
+
|
| 705 |
+
bot.run(TOKEN)
|