Update plugins/safari.py
Browse files- plugins/safari.py +215 -302
plugins/safari.py
CHANGED
|
@@ -1,273 +1,168 @@
|
|
| 1 |
from telethon import events
|
| 2 |
from asyncio import sleep as zzz
|
| 3 |
-
from random import randint
|
| 4 |
import time
|
| 5 |
-
from . import
|
| 6 |
|
| 7 |
chat = "@HeXamonbot"
|
| 8 |
infomers = "@teamkanha"
|
| 9 |
informer = "@princeji211"
|
| 10 |
|
| 11 |
hoenn = False
|
| 12 |
-
|
| 13 |
-
hunt_lock = False
|
| 14 |
-
hunt_delay = 3
|
| 15 |
-
hunt_monitor_task = None
|
| 16 |
-
last_hunt_time = 0
|
| 17 |
|
| 18 |
pokemon_list = [
|
| 19 |
-
"Mewtwo", "Ho-oh", "Lugia", "Rayquaza", "Deoxys", "Kyogre", "Jirachi", "Groudon", "Dialga", "Regigigas",
|
| 20 |
-
"
|
| 21 |
-
"
|
| 22 |
-
"
|
| 23 |
-
"
|
| 24 |
-
"
|
| 25 |
-
"
|
| 26 |
-
"
|
| 27 |
-
"
|
| 28 |
-
"
|
| 29 |
-
"
|
| 30 |
-
"Bouffalant", "Durant", "Meowstic", "Hawlucha", "Morpeko", "Sirfetch'd", "Spiritomb"
|
| 31 |
]
|
| 32 |
-
from asyncio import create_task, sleep as zzz
|
| 33 |
-
import time
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
|
|
|
|
|
|
|
|
|
| 38 |
try:
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
await zzz(hunt_delay + 15)
|
| 45 |
-
|
| 46 |
-
if not hoenn:
|
| 47 |
-
print("[Monitor] hoenn is False, stopping monitor loop.")
|
| 48 |
-
break
|
| 49 |
-
|
| 50 |
-
time_diff = round(time.time() - last_hunt_time, 2)
|
| 51 |
-
log_msg = f"🔁 Monitor check... Time since last hunt: `{time_diff}`s"
|
| 52 |
-
print(f"[Monitor] {log_msg}")
|
| 53 |
-
await client.send_message(chat, log_msg)
|
| 54 |
-
|
| 55 |
-
if time_diff <= hunt_delay + 25:
|
| 56 |
-
wait_time = round((hunt_delay + 25) - time_diff, 2)
|
| 57 |
-
msg = f"⏳ Skipping `/hunt` — next run in `{wait_time}` seconds."
|
| 58 |
-
print(f"[Monitor] {msg}")
|
| 59 |
-
await client.send_message(chat, msg)
|
| 60 |
-
continue
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
try:
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
if
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
print("[Monitor] ❌ No buttons found — cannot throw ball. Stopping.")
|
| 79 |
-
hoenn = False
|
| 80 |
-
await client.send_message(chat, "❌ No buttons found — Safari stopped.")
|
| 81 |
-
return
|
| 82 |
-
|
| 83 |
-
found_ball = False
|
| 84 |
-
for row in target.buttons:
|
| 85 |
-
for btn in row:
|
| 86 |
-
btn_text = btn.text.lower()
|
| 87 |
-
print(f"[Monitor] Checking button: {btn_text}")
|
| 88 |
-
if any(x in btn_text for x in [
|
| 89 |
-
"throw ball", "net", "ultra", "great", "quick",
|
| 90 |
-
"poke ball", "level", "fast", "nest"
|
| 91 |
-
]):
|
| 92 |
-
print(f"[Monitor] 🎯 Clicking button: {btn.text}")
|
| 93 |
-
await target.click(text=btn.text)
|
| 94 |
-
await zzz(hunt_delay + 2)
|
| 95 |
-
await safe_hunt(client)
|
| 96 |
-
found_ball = True
|
| 97 |
-
break
|
| 98 |
-
if found_ball:
|
| 99 |
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
if not found_ball:
|
| 102 |
-
print("[Monitor] ❌ No valid Pokéball found. Stopping Safari.")
|
| 103 |
-
hoenn = False
|
| 104 |
-
await client.send_message(chat, "❌ Safari stopped — no valid Pokéball found.")
|
| 105 |
-
return
|
| 106 |
-
|
| 107 |
-
else:
|
| 108 |
-
print("[Monitor] Not in battle. Calling safe_hunt...")
|
| 109 |
-
await safe_hunt(client)
|
| 110 |
-
|
| 111 |
-
except Exception as e:
|
| 112 |
-
hoenn = False
|
| 113 |
-
error_msg = f"❌ Hunt monitor crashed:\n`{str(e)}`"
|
| 114 |
-
print(f"[Monitor Error] {e}")
|
| 115 |
-
await client.send_message(chat, error_msg)
|
| 116 |
-
return
|
| 117 |
-
|
| 118 |
-
finally:
|
| 119 |
-
hunt_monitor_task = None
|
| 120 |
-
print("[Monitor] Task cleaned up and stopped.")
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
# ===== COMMANDS =====
|
| 124 |
-
@kanha_bot.on(events.NewMessage(outgoing=True, pattern=r"\.safari"))
|
| 125 |
-
async def safari_start(event):
|
| 126 |
-
global hoenn, hunt_attempts, hunt_lock, hunt_monitor_task
|
| 127 |
-
hoenn = False
|
| 128 |
-
hunt_attempts = 0
|
| 129 |
-
hunt_lock = False
|
| 130 |
-
|
| 131 |
-
await event.edit("🐾 Starting Safari...")
|
| 132 |
-
success = False
|
| 133 |
-
|
| 134 |
-
for _ in range(3):
|
| 135 |
-
try:
|
| 136 |
-
async with event.client.conversation(chat, timeout=5) as conv:
|
| 137 |
-
await conv.send_message("/enter")
|
| 138 |
-
await conv.get_response()
|
| 139 |
-
success = True
|
| 140 |
-
break
|
| 141 |
-
except:
|
| 142 |
-
await zzz(randint(3, 5))
|
| 143 |
-
|
| 144 |
-
if not success:
|
| 145 |
-
await event.edit("❌ Failed to enter Safari after 3 attempts.")
|
| 146 |
-
return
|
| 147 |
-
|
| 148 |
-
hoenn = True
|
| 149 |
-
await event.edit("✅ Safari entered! Starting hunts...")
|
| 150 |
-
hunt_monitor_task = create_task(hunt_monitor_loop(event.client))
|
| 151 |
-
await zzz(randint(3, 5))
|
| 152 |
-
await safe_hunt(event.client)
|
| 153 |
-
|
| 154 |
-
async def process_fled_or_failed(event, message, text):
|
| 155 |
-
await zzz(hunt_delay + 2)
|
| 156 |
-
if message.buttons:
|
| 157 |
-
await message.click(text="Release")
|
| 158 |
-
await zzz(hunt_delay + 2)
|
| 159 |
-
await safe_hunt(event.client)
|
| 160 |
-
|
| 161 |
-
async def safe_hunt(client):
|
| 162 |
-
global hunt_attempts, hoenn, hunt_lock, hunt_delay, last_hunt_time
|
| 163 |
-
if not hoenn or hunt_lock:
|
| 164 |
-
return
|
| 165 |
-
|
| 166 |
-
success = False
|
| 167 |
-
for _ in range(4):
|
| 168 |
-
try:
|
| 169 |
-
async with client.conversation(chat, timeout=6) as conv:
|
| 170 |
-
start_time = time.time()
|
| 171 |
-
msg = await conv.send_message("/hunt")
|
| 172 |
-
await conv.get_response(msg.id)
|
| 173 |
-
hunt_delay = round(time.time() - start_time, 2)
|
| 174 |
-
last_hunt_time = time.time()
|
| 175 |
-
hunt_attempts = 0
|
| 176 |
-
success = True
|
| 177 |
-
break
|
| 178 |
-
except:
|
| 179 |
-
hunt_attempts += 1
|
| 180 |
-
await zzz(hunt_delay + 2)
|
| 181 |
-
|
| 182 |
-
if not success:
|
| 183 |
-
hoenn = False
|
| 184 |
-
await client.send_message(chat, "❌ Failed to hunt after 4 attempts. Safari stopped.")
|
| 185 |
-
|
| 186 |
-
async def click_with_retry(message, button_text, retries=3):
|
| 187 |
-
client = message.client
|
| 188 |
-
old_text = message.text
|
| 189 |
-
old_id = message.id
|
| 190 |
-
|
| 191 |
-
for _ in range(retries):
|
| 192 |
-
if message.buttons:
|
| 193 |
-
for row in message.buttons:
|
| 194 |
-
for btn in row:
|
| 195 |
-
if button_text.lower() in btn.text.lower():
|
| 196 |
-
await message.click(text=btn.text)
|
| 197 |
-
await zzz(hunt_delay + 2)
|
| 198 |
-
updated_msg = await client.get_messages(message.chat_id, ids=old_id)
|
| 199 |
-
if updated_msg.text != old_text:
|
| 200 |
-
return True
|
| 201 |
-
latest_msg = await client.get_messages(message.chat_id, limit=1)
|
| 202 |
-
if latest_msg and latest_msg[0].id != old_id:
|
| 203 |
-
return True
|
| 204 |
-
else:
|
| 205 |
-
# If no buttons in old message, try latest
|
| 206 |
-
latest_msg = await client.get_messages(message.chat_id, limit=1)
|
| 207 |
-
if latest_msg and latest_msg[0].buttons:
|
| 208 |
-
message = latest_msg[0]
|
| 209 |
-
continue
|
| 210 |
-
await zzz(hunt_delay + 2)
|
| 211 |
-
|
| 212 |
-
return False
|
| 213 |
-
|
| 214 |
-
# ===== AUTO RECOVERY LOOP =====
|
| 215 |
-
@kanha_bot.on(events.NewMessage)
|
| 216 |
-
async def auto_recovery(event):
|
| 217 |
-
global hoenn, last_hunt_time
|
| 218 |
-
if hoenn and time.time() - last_hunt_time > hunt_delay + 15:
|
| 219 |
-
await safe_hunt(event.client)
|
| 220 |
-
|
| 221 |
-
# ===== NEW MESSAGE HANDLER =====
|
| 222 |
@kanha_bot.on(events.NewMessage(chats=chat, incoming=True))
|
| 223 |
-
async def
|
| 224 |
-
|
| 225 |
-
if
|
| 226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
-
text
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
for row in message.buttons:
|
| 232 |
-
for
|
| 233 |
-
if
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
elif any(p in text for p in pokemon_list):
|
| 242 |
-
if message.buttons:
|
| 243 |
-
for row in message.buttons:
|
| 244 |
-
for btn in row:
|
| 245 |
-
if btn.text in ["Engage", "Battle"]:
|
| 246 |
-
await click_with_retry(message, btn.text)
|
| 247 |
-
elif any(x in text for x in ["A wild", "An expert"]):
|
| 248 |
-
await zzz(hunt_delay + 2)
|
| 249 |
-
await safe_hunt(event.client)
|
| 250 |
-
if "Wild" in text:
|
| 251 |
-
await zzz(hunt_delay + 2)
|
| 252 |
-
await click_with_retry(message, "Throw ball")
|
| 253 |
-
return
|
| 254 |
|
| 255 |
-
# ===== EDIT MESSAGE HANDLER =====
|
| 256 |
@kanha_bot.on(events.MessageEdited(chats=chat, incoming=True))
|
| 257 |
-
async def
|
|
|
|
| 258 |
global hoenn
|
| 259 |
if not hoenn:
|
| 260 |
return
|
| 261 |
|
| 262 |
-
message = event.message
|
| 263 |
-
text = message.text or ""
|
| 264 |
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
-
|
| 270 |
try:
|
|
|
|
| 271 |
lines = text.splitlines()
|
| 272 |
enemy_line = lines[0]
|
| 273 |
level_line = lines[1]
|
|
@@ -278,86 +173,104 @@ async def edited_handler_battle(event):
|
|
| 278 |
wild_level = int(level_line.split("Lv.")[1].split("•")[0].strip())
|
| 279 |
player_level = int(player_line.split("Lv.")[1].split("•")[0].strip()) if "Lv." in player_line else 50
|
| 280 |
|
|
|
|
|
|
|
| 281 |
if any(t in enemy_type for t in ["bug", "water"]):
|
| 282 |
-
await click_with_retry(message, "Net")
|
| 283 |
-
if any(name in enemy_name.lower() for name in ["electrode", "jolteon", "ninjask", "crobat", "greninja", "magnemite", "grimer", "tangela"]):
|
| 284 |
-
await click_with_retry(message, "Fast")
|
| 285 |
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
await click_with_retry(message, "Nest")
|
| 291 |
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
|
| 296 |
except Exception as e:
|
| 297 |
-
await
|
| 298 |
hoenn = False
|
| 299 |
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
for row in message.buttons:
|
| 315 |
-
for btn in row:
|
| 316 |
-
if btn.text.lower() == "poke balls":
|
| 317 |
-
await click_with_retry(message, "Poke Balls")
|
| 318 |
-
await zzz(hunt_delay + 2)
|
| 319 |
|
| 320 |
-
|
| 321 |
-
await zzz(
|
| 322 |
try:
|
| 323 |
-
for x in range(
|
| 324 |
-
for y in range(
|
| 325 |
-
|
|
|
|
| 326 |
await event.click(x, y)
|
| 327 |
return
|
| 328 |
except:
|
| 329 |
pass
|
| 330 |
|
| 331 |
-
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
async def stop(event):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
global hoenn
|
| 335 |
hoenn = False
|
| 336 |
-
await event.edit("Stopped manually")
|
| 337 |
-
if hunt_monitor_task:
|
| 338 |
-
hunt_monitor_task.cancel()
|
| 339 |
-
hunt_monitor_task = None
|
| 340 |
-
# ===== AUTO STOP =====
|
| 341 |
-
@kanha_bot.on(events.NewMessage(chats=chat))
|
| 342 |
-
@kanha_bot.on(events.MessageEdited(chats=chat))
|
| 343 |
-
async def auto_stop_detector(event):
|
| 344 |
-
global hoenn, hunt_lock
|
| 345 |
-
if ("run out of Safari Balls" in event.text or "Safari Game has finished" in event.text):
|
| 346 |
-
if random() < 0.5:
|
| 347 |
-
hoenn = False
|
| 348 |
-
hunt_lock = True
|
| 349 |
-
if hunt_monitor_task:
|
| 350 |
-
hunt_monitor_task.cancel()
|
| 351 |
-
hunt_monitor_task = None
|
| 352 |
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
if hoenn:
|
| 357 |
-
text = event.text
|
| 358 |
if "✨" in text:
|
| 359 |
-
await
|
| 360 |
-
await zzz(
|
| 361 |
-
await
|
| 362 |
if "want to release" in text:
|
| 363 |
-
await
|
|
|
|
| 1 |
from telethon import events
|
| 2 |
from asyncio import sleep as zzz
|
| 3 |
+
from random import randint
|
| 4 |
import time
|
| 5 |
+
from . import *
|
| 6 |
|
| 7 |
chat = "@HeXamonbot"
|
| 8 |
infomers = "@teamkanha"
|
| 9 |
informer = "@princeji211"
|
| 10 |
|
| 11 |
hoenn = False
|
| 12 |
+
hexa_speed = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
pokemon_list = [
|
| 15 |
+
"Mewtwo", "Ho-oh", "Lugia", "Rayquaza", "Deoxys", "Kyogre", "Jirachi", "Groudon", "Dialga", "Regigigas", "Giratina",
|
| 16 |
+
"Arceus", "Palkia", "Kyurem", "Zekrom", "Reshiram", "Latios", "Latias", "Virizion", "Cobalion", "Terrakion", "Victini",
|
| 17 |
+
"Genesect", "Meloetta", "Keldeo", "Diancie", "Zygarde", "Xerneas", "Yveltal", "Volcanion", "Necrozma", "Solgaleo",
|
| 18 |
+
"Lunala", "Buzzwole", "Cosmoem", "Kartana", "Cosmog", "Blacephalon", "Pheromosa", "Guzzlord", "Magearna", "Marshadow",
|
| 19 |
+
"Tapu", "Silvally", "Zacian", "Zamazenta", "Eternatus", "Spectrier", "Glastrier", "Urshifu", "✨", "Entei", "Suicune",
|
| 20 |
+
"Raikou", "Celebi", "Shaymin", "Heatran", "Hoopa", "Naganadel", "Poipole", "Cresselia", "Nihilego", "Xurkitree",
|
| 21 |
+
"Celesteela", "Melmetal", "Stakataka", "Meltan", "Kubfu", "Regidrago", "Zarude", "Enamorus", "Beldum", "Metang",
|
| 22 |
+
"Koraidon", "Miraidon", "Ting-Lu", "Chien-Pao", "Wo-Chien", "Shu-Tao", "Walking Wake", "Aerodactyl", "Darumaka",
|
| 23 |
+
"Abra", "Litwick", "Gardevoir", "Gallade", "Froakie", "Slakoth", "Tauros", "Wurmple", "Jolteon", "Espeon", "Drakloak",
|
| 24 |
+
"Cincinno", "Miltank", "Vikavolt", "Cyndaquil", "Oranguru", "Heracross", "Mimikyu", "Drampa", "Rotom", "Lapras",
|
| 25 |
+
"Druddigon", "Bouffalant", "Durant", "Meowstic", "Hawlucha", "Morpeko", "Sirfetch'd", "Morpeko", "Spiritomb"
|
|
|
|
| 26 |
]
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
@kanha_bot.on(events.NewMessage(outgoing=True, pattern='.safari'))
|
| 29 |
+
async def autohexa(event):
|
| 30 |
+
client = event.client
|
| 31 |
+
i = True
|
| 32 |
+
await event.edit("safari is on the way")
|
| 33 |
+
if i:
|
| 34 |
+
for _ in range(5):
|
| 35 |
+
try:
|
| 36 |
+
async with client.conversation(chat) as conv:
|
| 37 |
+
start = time.monotonic()
|
| 38 |
+
await conv.send_message("/enter")
|
| 39 |
+
await conv.get_response(timeout=10)
|
| 40 |
+
end = time.monotonic()
|
| 41 |
+
global hexa_speed
|
| 42 |
+
hexa_speed = round(end - start)
|
| 43 |
+
await zzz(hexa_speed + 3)
|
| 44 |
+
break
|
| 45 |
+
except:
|
| 46 |
+
await zzz(2)
|
| 47 |
+
else:
|
| 48 |
+
await event.edit("Stopping safari due to no response in 5 tries")
|
| 49 |
+
return
|
| 50 |
|
| 51 |
+
global hoenn
|
| 52 |
+
hoenn = True
|
| 53 |
+
x = await client.send_message(chat, "/hunt")
|
| 54 |
try:
|
| 55 |
+
async with client.conversation(chat) as conv:
|
| 56 |
+
await conv.get_response(x.id)
|
| 57 |
+
except:
|
| 58 |
+
await zzz(hexa_speed + 3)
|
| 59 |
+
await client.send_message(chat, "/hunt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
@kanha_bot.on(events.NewMessage(chats=chat, incoming=True))
|
| 62 |
+
async def hunt(event):
|
| 63 |
+
client = event.client
|
| 64 |
+
if hoenn:
|
| 65 |
+
text = event.message.text
|
| 66 |
+
message = await client.get_messages(chat, ids=event.message.id)
|
| 67 |
+
if "lund" in text:
|
| 68 |
+
await client.disconnect()
|
| 69 |
+
elif "TM" in text:
|
| 70 |
+
await zzz(randint(1, 3) + hexa_speed)
|
| 71 |
+
x = await client.send_message(chat, "/hunt")
|
| 72 |
try:
|
| 73 |
+
async with client.conversation(chat) as conv:
|
| 74 |
+
await conv.get_response(x.id)
|
| 75 |
+
except:
|
| 76 |
+
await zzz(hexa_speed + 3)
|
| 77 |
+
await client.send_message(chat, "/hunt")
|
| 78 |
+
elif any(item in text for item in pokemon_list) and event.message.buttons:
|
| 79 |
+
for row in event.message.buttons:
|
| 80 |
+
for button in row:
|
| 81 |
+
if button.text in ["Engage", "Battle"]:
|
| 82 |
+
for _ in range(5):
|
| 83 |
+
old = event.message.text
|
| 84 |
+
await message.click(text=button.text)
|
| 85 |
+
await zzz(hexa_speed + 3)
|
| 86 |
+
new_msg = await client.get_messages(chat, ids=event.message.id)
|
| 87 |
+
if new_msg.text != old:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
break
|
| 89 |
+
elif "A wild" in text or "An expert" in text:
|
| 90 |
+
await zzz(randint(2, 5) + hexa_speed)
|
| 91 |
+
x = await client.send_message(chat, "/hunt")
|
| 92 |
+
try:
|
| 93 |
+
async with client.conversation(chat) as conv:
|
| 94 |
+
await conv.get_response(x.id)
|
| 95 |
+
except:
|
| 96 |
+
await zzz(hexa_speed + 3)
|
| 97 |
+
await client.send_message(chat, "/hunt")
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
@kanha_bot.on(events.NewMessage(chats=chat, incoming=True))
|
| 100 |
+
async def hoenn(event):
|
| 101 |
+
client = event.client
|
| 102 |
+
if hoenn and event.message.text.startswith("Wild"):
|
| 103 |
+
message = await client.get_messages(chat, ids=event.message.id)
|
| 104 |
+
await zzz(hexa_speed + 3)
|
| 105 |
+
if event.message.buttons:
|
| 106 |
+
for row in event.message.buttons:
|
| 107 |
+
for button in row:
|
| 108 |
+
if button.text == "Throw ball":
|
| 109 |
+
for _ in range(5):
|
| 110 |
+
old = event.message.text
|
| 111 |
+
await message.click(text="Throw ball")
|
| 112 |
+
await zzz(hexa_speed + 3)
|
| 113 |
+
new_msg = await client.get_messages(chat, ids=event.message.id)
|
| 114 |
+
if new_msg.text != old:
|
| 115 |
+
break
|
| 116 |
|
| 117 |
+
elif event.message.text.startswith("Battle begins!") and event.message.buttons:
|
| 118 |
+
message = await client.get_messages(chat, ids=event.message.id)
|
| 119 |
+
await zzz(hexa_speed + 3)
|
| 120 |
+
for row in event.message.buttons:
|
| 121 |
+
for button in row:
|
| 122 |
+
if button.text == "Poke Balls":
|
| 123 |
+
for _ in range(5):
|
| 124 |
+
old = event.message.text
|
| 125 |
+
await message.click(text="Poke Balls")
|
| 126 |
+
await zzz(hexa_speed + 3)
|
| 127 |
+
new_msg = await client.get_messages(chat, ids=event.message.id)
|
| 128 |
+
if new_msg.text != old:
|
| 129 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
|
|
|
| 131 |
@kanha_bot.on(events.MessageEdited(chats=chat, incoming=True))
|
| 132 |
+
async def cacther(event):
|
| 133 |
+
client = event.client
|
| 134 |
global hoenn
|
| 135 |
if not hoenn:
|
| 136 |
return
|
| 137 |
|
| 138 |
+
message = await client.get_messages(chat, ids=event.message.id)
|
|
|
|
| 139 |
|
| 140 |
+
try:
|
| 141 |
+
buttons = (await message.get_buttons())[0]
|
| 142 |
+
if any(btn.text == "Poke Balls" for btn in buttons):
|
| 143 |
+
for _ in range(5):
|
| 144 |
+
old = event.message.text
|
| 145 |
+
await message.click(text="Poke Balls")
|
| 146 |
+
await zzz(hexa_speed + 3)
|
| 147 |
+
new_msg = await client.get_messages(chat, ids=event.message.id)
|
| 148 |
+
if new_msg.text != old:
|
| 149 |
+
break
|
| 150 |
+
except:
|
| 151 |
+
pass
|
| 152 |
+
|
| 153 |
+
elif event.message.text.startswith("Your Safari"):
|
| 154 |
+
await zzz(hexa_speed + 3)
|
| 155 |
+
for _ in range(5):
|
| 156 |
+
old = event.message.text
|
| 157 |
+
await message.click(text="Throw ball")
|
| 158 |
+
await zzz(hexa_speed + 3)
|
| 159 |
+
new_msg = await client.get_messages(chat, ids=event.message.id)
|
| 160 |
+
if new_msg.text != old:
|
| 161 |
+
break
|
| 162 |
|
| 163 |
+
elif event.message.text.startswith("Wild") and "Lv." in event.message.text:
|
| 164 |
try:
|
| 165 |
+
text = event.message.text
|
| 166 |
lines = text.splitlines()
|
| 167 |
enemy_line = lines[0]
|
| 168 |
level_line = lines[1]
|
|
|
|
| 173 |
wild_level = int(level_line.split("Lv.")[1].split("•")[0].strip())
|
| 174 |
player_level = int(player_line.split("Lv.")[1].split("•")[0].strip()) if "Lv." in player_line else 50
|
| 175 |
|
| 176 |
+
clicked = False
|
| 177 |
+
|
| 178 |
if any(t in enemy_type for t in ["bug", "water"]):
|
| 179 |
+
clicked = await click_with_retry(client, message, "Net")
|
|
|
|
|
|
|
| 180 |
|
| 181 |
+
if any(name in enemy_name.lower() for name in [
|
| 182 |
+
"electrode", "jolteon", "ninjask", "crobat", "greninja", "magnemite", "grimer", "tangela"
|
| 183 |
+
]):
|
| 184 |
+
clicked = await click_with_retry(client, message, "Fast")
|
|
|
|
| 185 |
|
| 186 |
+
ratio = player_level / wild_level if wild_level else 1
|
| 187 |
+
if not clicked and ratio >= 4:
|
| 188 |
+
clicked = await click_with_retry(client, message, "Level")
|
| 189 |
+
elif not clicked and wild_level <= 15:
|
| 190 |
+
clicked = await click_with_retry(client, message, "Nest")
|
| 191 |
+
|
| 192 |
+
if not clicked:
|
| 193 |
+
for ball in ["Repeat", "Safari", "Ultra", "Great", "Quick"]:
|
| 194 |
+
clicked = await click_with_retry(client, message, ball)
|
| 195 |
+
if clicked:
|
| 196 |
+
break
|
| 197 |
+
|
| 198 |
+
if not clicked:
|
| 199 |
+
await client.send_message(informer, "hut bc pokeball hi koni \n\nbuy krle bakchod")
|
| 200 |
+
hoenn = False
|
| 201 |
|
| 202 |
except Exception as e:
|
| 203 |
+
await client.send_message(informer, f"❌ Error parsing battle: {e}")
|
| 204 |
hoenn = False
|
| 205 |
|
| 206 |
+
elif any(k in event.message.text.lower() for k in ['fled', 'caught']):
|
| 207 |
+
await zzz(hexa_speed + 3)
|
| 208 |
+
try:
|
| 209 |
+
await event.click(text="Release")
|
| 210 |
+
except:
|
| 211 |
+
pass
|
| 212 |
+
await zzz(randint(4, 5) + hexa_speed)
|
| 213 |
+
x = await client.send_message(chat, "/hunt")
|
| 214 |
+
try:
|
| 215 |
+
async with client.conversation(chat) as conv:
|
| 216 |
+
await conv.get_response(x.id)
|
| 217 |
+
except:
|
| 218 |
+
await zzz(hexa_speed + 3)
|
| 219 |
+
await client.send_message(chat, "/hunt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
|
| 221 |
+
elif "Choose your next pokemon." in event.message.text and event.message.buttons:
|
| 222 |
+
await zzz(hexa_speed + 3)
|
| 223 |
try:
|
| 224 |
+
for x in range(len(event.buttons)):
|
| 225 |
+
for y in range(len(event.buttons[x])):
|
| 226 |
+
button_text = event.buttons[x][y].text if event.buttons[x][y].text else ""
|
| 227 |
+
if button_text.strip():
|
| 228 |
await event.click(x, y)
|
| 229 |
return
|
| 230 |
except:
|
| 231 |
pass
|
| 232 |
|
| 233 |
+
async def click_with_retry(client, message, button_text):
|
| 234 |
+
for _ in range(5):
|
| 235 |
+
old = message.text
|
| 236 |
+
try:
|
| 237 |
+
await message.click(text=button_text)
|
| 238 |
+
await zzz(hexa_speed + 3)
|
| 239 |
+
new_msg = await client.get_messages(chat, ids=message.id)
|
| 240 |
+
if new_msg.text != old:
|
| 241 |
+
return True
|
| 242 |
+
except:
|
| 243 |
+
pass
|
| 244 |
+
return False
|
| 245 |
+
|
| 246 |
+
@kanha_bot.on(events.NewMessage(outgoing=True, pattern='.stop'))
|
| 247 |
async def stop(event):
|
| 248 |
+
await event.edit("Stopping.....")
|
| 249 |
+
global hoenn
|
| 250 |
+
hoenn = False
|
| 251 |
+
|
| 252 |
+
@kanha_bot.on(events.NewMessage(chats=chat, func=lambda e: (
|
| 253 |
+
"You have run out of Safari Balls and are now exiting the Hoenn Safari Zone" in e.text or
|
| 254 |
+
"The Safari Game has finished and you were kicked out" in e.text)))
|
| 255 |
+
async def stoppp(event):
|
| 256 |
global hoenn
|
| 257 |
hoenn = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
+
@kanha_bot.on(events.MessageEdited(chats=chat, func=lambda e: (
|
| 260 |
+
"You have run out of Safari Balls and are now exiting the Hoenn Safari Zone" in e.text or
|
| 261 |
+
"The Safari Game has finished and you were kicked out" in e.text)))
|
| 262 |
+
async def stoppp(event):
|
| 263 |
+
global hoenn
|
| 264 |
+
hoenn = False
|
| 265 |
+
|
| 266 |
+
@kanha_bot.on(events.NewMessage(chats=chat, incoming=True))
|
| 267 |
+
async def infom(event):
|
| 268 |
+
client = event.client
|
| 269 |
if hoenn:
|
| 270 |
+
text = event.message.text
|
| 271 |
if "✨" in text:
|
| 272 |
+
await client.forward_messages(infomers, event.message)
|
| 273 |
+
await zzz(hexa_speed + 3)
|
| 274 |
+
await client.forward_messages(informer, event.message)
|
| 275 |
if "want to release" in text:
|
| 276 |
+
await client.forward_messages(informer, event.message)
|