agus1111 commited on
Commit
f1bf7f5
·
verified ·
1 Parent(s): 36f663f

Update bot_core.py

Browse files
Files changed (1) hide show
  1. bot_core.py +15 -5
bot_core.py CHANGED
@@ -14,7 +14,7 @@ STRING_SESSION = os.environ.get("STRING_SESSION", "")
14
  SOURCE_CHAT = os.environ.get("SOURCE_CHAT", "https://t.me/MidasTouchsignalll")
15
  TARGET_CHAT = os.environ.get("TARGET_CHAT", "@solana_trojanbot")
16
 
17
- # (Opsional) label tombol jumlah/amount di bot target (mis. "0.1 SOL" atau "Buy 0.01")
18
  AMOUNT_LABEL = os.environ.get("AMOUNT_LABEL", "").strip()
19
 
20
  # Label retri (klik berulang jika buy gagal karena slippage, dsb)
@@ -44,8 +44,9 @@ CA_SOL_RE = re.compile(r"\b([1-9A-HJ-NP-Za-km-z]{32,44})(?:pump)?\b")
44
  CA_EVM_RE = re.compile(r"\b0x[a-fA-F0-9]{40}\b")
45
 
46
  # Tombol
47
- BUY_PAT = re.compile(r"(?i)buy")
48
- RETRY_PAT = re.compile(r"(?i)(" + "|".join(map(re.escape, RETRY_LABELS)) + r")") if RETRY_LABELS else re.compile(r"$^")
 
49
 
50
  # Tier tag dalam pesan, contoh:
51
  # [Low 🌱], [Medium ⚡️], [Strong 💪], [High], [FOMO🔥]
@@ -209,7 +210,16 @@ async def buy_flow_with_ca(addr: str):
209
  msg_kb = msg2 or await refresh_message(msg_kb)
210
  baseline_id = max(baseline_id, getattr(msg_kb, "id", baseline_id))
211
 
212
- # klik BUY (cari tombol bertuliskan 'Buy')
 
 
 
 
 
 
 
 
 
213
  ok_buy = await click_first_match(msg_kb, BUY_PAT)
214
  if not ok_buy:
215
  # coba cari di pesan terbaru lainnya
@@ -218,7 +228,7 @@ async def buy_flow_with_ca(addr: str):
218
  msg_kb = hit
219
  ok_buy = True
220
 
221
- # fallback: klik tombol terakhir baris terakhir (kadang itu Buy)
222
  if not ok_buy and msg_kb.buttons and msg_kb.buttons[-1]:
223
  try:
224
  await msg_kb.click(len(msg_kb.buttons) - 1, 0)
 
14
  SOURCE_CHAT = os.environ.get("SOURCE_CHAT", "https://t.me/MidasTouchsignalll")
15
  TARGET_CHAT = os.environ.get("TARGET_CHAT", "@solana_trojanbot")
16
 
17
+ # (Opsional) label tombol jumlah/amount di bot target (mis. "0.002 SOL", "X SOL", dst.)
18
  AMOUNT_LABEL = os.environ.get("AMOUNT_LABEL", "").strip()
19
 
20
  # Label retri (klik berulang jika buy gagal karena slippage, dsb)
 
44
  CA_EVM_RE = re.compile(r"\b0x[a-fA-F0-9]{40}\b")
45
 
46
  # Tombol
47
+ BUY_PAT = re.compile(r"(?i)buy")
48
+ REFRESH_PAT = re.compile(r"(?i)refresh")
49
+ RETRY_PAT = re.compile(r"(?i)(" + "|".join(map(re.escape, RETRY_LABELS)) + r")") if RETRY_LABELS else re.compile(r"$^")
50
 
51
  # Tier tag dalam pesan, contoh:
52
  # [Low 🌱], [Medium ⚡️], [Strong 💪], [High], [FOMO🔥]
 
210
  msg_kb = msg2 or await refresh_message(msg_kb)
211
  baseline_id = max(baseline_id, getattr(msg_kb, "id", baseline_id))
212
 
213
+ # === Tambahan: tunggu + Refresh 2x sebelum BUY ===
214
+ await asyncio.sleep(15)
215
+ await click_first_match(msg_kb, REFRESH_PAT)
216
+
217
+ await asyncio.sleep(15)
218
+ msg_kb = await refresh_message(msg_kb) # pastikan state terbaru
219
+ await click_first_match(msg_kb, REFRESH_PAT)
220
+ # ================================================
221
+
222
+ # klik BUY
223
  ok_buy = await click_first_match(msg_kb, BUY_PAT)
224
  if not ok_buy:
225
  # coba cari di pesan terbaru lainnya
 
228
  msg_kb = hit
229
  ok_buy = True
230
 
231
+ # fallback: klik tombol pertama di baris terakhir (kadang itu Buy)
232
  if not ok_buy and msg_kb.buttons and msg_kb.buttons[-1]:
233
  try:
234
  await msg_kb.click(len(msg_kb.buttons) - 1, 0)