-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSniper.py
More file actions
140 lines (112 loc) · 5.08 KB
/
Copy pathSniper.py
File metadata and controls
140 lines (112 loc) · 5.08 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
import threading
import requests
import discum
import Vars
import time
import re
auth = {'authorization': Vars.token}
channelID = Vars.channelId
emoji = '💕'
bot = discum.Client(token=Vars.token, log=False)
claimed = '❤️'
unclaimed = '💔'
kakera_emoji = '💎'
power_threshold = Vars.power_threshold
def react_to_card(message):
embeds = message.get('embeds', [])
if not embeds:
return
try:
card_name = embeds[0]['author']['name']
description = embeds[0]['description']
card_series = description.replace('\n', '**').split('**')[0].strip()
# Remove trailing Discord emoji mentions like <:male:123456789>
card_series = re.sub(r'<:[^:]+:\d+>$', '', card_series).strip()
try:
card_power = int(description.split('**')[1])
except (IndexError, ValueError):
card_power = 0
# Claimed/unclaimed status
footer = embeds[0].get('footer', {})
status_emoji = claimed if footer.get('icon_url') else unclaimed
# Log
timestamp = time.strftime("%H:%M - %d/%m/%y", time.localtime())
print(f"{timestamp} - {status_emoji} ---- {card_power} - {card_name} - {card_series}")
chosen = None
if Vars.catch_from_characters and card_name in getattr(Vars, "desiredCharacters", []):
chosen = message
elif Vars.catch_from_series and card_series in Vars.desiredSeries:
chosen = message
elif Vars.catch_from_power and card_power >= power_threshold:
chosen = message
if chosen:
RED = "\033[91m"
RESET = "\033[0m"
print(f"{RED}⚠️ {timestamp} - Sniping {card_name} from {card_series} (Power {card_power}) ⚠️{RESET}")
try:
components = message.get("components", [])
if components and components[0].get("components"):
btn = components[0]["components"][0] # first button
btn_label = btn.get("label")
btn_emoji = btn.get("emoji", {}).get("name")
btn_id = btn.get("custom_id")
print(f"{timestamp} - Found button: label='{btn_label}', emoji='{btn_emoji}', id='{btn_id}'")
bot.click(
applicationID=message["author"]["id"], # Mudae bot ID
channelID=message["channel_id"],
guildID=message.get("guild_id"),
messageID=message["id"],
messageFlags=message["flags"],
data={'component_type': 2, 'custom_id': btn_id},
sessionID=bot.gateway.session_id
)
print(f"{timestamp} - Clicked {btn_emoji or btn_label} for {card_name}")
else:
# fallback to reaction
time.sleep(0.1)
requests.put(
f"https://discord.com/api/v8/channels/{channelID}/messages/{message['id']}/reactions/{emoji}/%40me",
headers=auth
)
print(f"{timestamp} - Reacted to {card_name} with {emoji}")
except Exception as e:
print(f"{timestamp} - Failed to snipe {card_name}: {e}")
# Check all buttons (claim + kakera)
components = message.get("components", [])
if components and components[0].get("components"):
inner_components = components[0]["components"]
for comp in inner_components:
try:
btn_emoji = comp.get("emoji", {}).get("name")
btn_label = comp.get("label")
btn_id = comp.get("custom_id")
# Debug log
print(f"{timestamp} - Found button: label='{btn_label}', emoji='{btn_emoji}', id='{btn_id}'")
# If this button matches desired Kakera emojis, click it
if btn_emoji in Vars.desiredKakeras:
print(f"{timestamp} - Found Kakera {btn_emoji} for {card_name}, claiming...")
bot.click(
applicationID=message['author']['id'],
channelID=message['channel_id'],
guildID=Vars.serverId,
messageID=message['id'],
messageFlags=message['flags'],
data={'component_type': 2, 'custom_id': btn_id},
sessionID=bot.gateway.session_id
)
time.sleep(0.5)
except (KeyError, IndexError):
continue
except (KeyError, IndexError):
return
@bot.gateway.command
def on_message(resp):
if resp.event.message:
message = resp.parsed.auto()
if message['channel_id'] == channelID:
react_to_card(message)
def start_gateway():
bot.gateway.run(auto_reconnect=True)
def start_watcher():
print("Starting sniper...")
threading.Thread(target=start_gateway, daemon=True).start()