pair-scanner-bot 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,259 @@
1
+ import csv
2
+ import io
3
+ import logging
4
+ import os
5
+ from datetime import datetime
6
+ from importlib.metadata import PackageNotFoundError, version
7
+
8
+ import sentry_sdk
9
+ from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
10
+ from telegram.error import BadRequest
11
+ from telegram.ext import (
12
+ Application,
13
+ CallbackQueryHandler,
14
+ CommandHandler,
15
+ ContextTypes,
16
+ MessageHandler,
17
+ filters,
18
+ )
19
+
20
+ from . import jobs
21
+ from .blocks import scanner as scanner_screen
22
+ from .blocks import settings as settings_screen
23
+ from .blocks.balances import balances_block
24
+ from .db import close_db, init_scanner_db
25
+ from .db.pairs import pairs_get_by_status
26
+ from .health import scanner_health
27
+ from .networks import refresh_networks
28
+ from .settings import ENV_VARS, OPTIONS, SETTINGS, is_owner, is_test_mode, setup
29
+ from .w3 import close_w3
30
+
31
+ try:
32
+ __version__ = version("pair-scanner-bot")
33
+ except PackageNotFoundError:
34
+ __version__ = "0.0.0"
35
+
36
+ NOISE = (
37
+ "httpx.ReadError",
38
+ "RemoteProtocolError",
39
+ "Timed out",
40
+ "Query is too old",
41
+ "query id is invalid",
42
+ "Message is not modified",
43
+ "Conflict: terminated by other getUpdates",
44
+ )
45
+
46
+ __all__ = [
47
+ "__version__",
48
+ "balances_block",
49
+ "handle_button",
50
+ "handle_text_input",
51
+ "scanner_block",
52
+ "scanner_health",
53
+ "start_scanner_bot",
54
+ "stop_scanner_bot",
55
+ ]
56
+
57
+
58
+ async def scanner_block(context: ContextTypes.DEFAULT_TYPE, brief=False):
59
+ return await scanner_screen.handle_block(context, brief=brief)
60
+
61
+
62
+ async def home_block():
63
+ trading = int(OPTIONS.get("trading_enabled", 0))
64
+ text = "🎯 *Pair Scanner*\n\n" + (
65
+ "💸 Trading is on." if trading else "👀 Watch-only: trading is off."
66
+ )
67
+ return {
68
+ "text": text,
69
+ "parse_mode": "Markdown",
70
+ "reply_markup": InlineKeyboardMarkup(
71
+ [
72
+ [
73
+ InlineKeyboardButton("🎯 Scanner", callback_data="scanner:home"),
74
+ InlineKeyboardButton(
75
+ "₿ Balances", callback_data="scanner:balances"
76
+ ),
77
+ ],
78
+ [InlineKeyboardButton("⚙️ Settings", callback_data="scanner:settings")],
79
+ [InlineKeyboardButton("❌ Close", callback_data="cancel")],
80
+ ]
81
+ ),
82
+ }
83
+
84
+
85
+ async def handle_button(update: Update, context: ContextTypes.DEFAULT_TYPE):
86
+ query = update.callback_query
87
+ data = query.data
88
+
89
+ if not is_owner(query.from_user.id):
90
+ await query.answer("This bot only answers its owner.", show_alert=True)
91
+ return
92
+
93
+ if data.startswith("scanner:settings"):
94
+ await settings_screen.handle_button(update, context)
95
+ return
96
+
97
+ await query.answer()
98
+
99
+ if data == "ignore":
100
+ return
101
+
102
+ if data == "cancel":
103
+ try:
104
+ await query.message.delete()
105
+ except BadRequest:
106
+ await query.edit_message_reply_markup(None)
107
+ return
108
+
109
+ if data.startswith("scanner:export:"):
110
+ table = data.split(":")[2]
111
+ if table not in ("pairs", "positions"):
112
+ return
113
+ rows = await pairs_get_by_status(None, table) or []
114
+ buf = io.StringIO()
115
+ if rows:
116
+ writer = csv.DictWriter(buf, fieldnames=list(rows[0]))
117
+ writer.writeheader()
118
+ writer.writerows(rows)
119
+ stamp = datetime.now().strftime("%Y-%m-%d")
120
+ await context.bot.send_document(
121
+ chat_id=query.message.chat_id,
122
+ document=io.BytesIO(buf.getvalue().encode("utf-8-sig")),
123
+ filename=f"{table}_{stamp}.csv",
124
+ caption=f"📤 {table.capitalize()}: {len(rows)} rows",
125
+ )
126
+ return
127
+
128
+ if data in ("scanner:menu", "scanner:home", "scanner:balances"):
129
+ if data == "scanner:menu":
130
+ block = await home_block()
131
+ elif data == "scanner:home":
132
+ block = await scanner_screen.handle_block(context)
133
+ else:
134
+ block = await balances_block()
135
+ await query.edit_message_text(
136
+ block["text"],
137
+ reply_markup=block.get("reply_markup"),
138
+ parse_mode="Markdown",
139
+ disable_web_page_preview=True,
140
+ )
141
+ return
142
+
143
+ await scanner_screen.handle_button(update, context)
144
+
145
+
146
+ async def handle_text_input(update: Update, context: ContextTypes.DEFAULT_TYPE):
147
+ if not is_owner(update.effective_user.id):
148
+ return
149
+ state = context.user_data.get("state") or ""
150
+ if not state.startswith("scanner:settings:"):
151
+ return
152
+ text = (update.message.text or "").strip()
153
+ try:
154
+ await update.message.delete()
155
+ except Exception:
156
+ pass
157
+ await settings_screen.handle_text(update, context, text)
158
+
159
+
160
+ async def command_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
161
+ if not is_owner(update.effective_user.id):
162
+ await update.message.reply_text("This bot only answers its owner.")
163
+ return
164
+ context.user_data.pop("state", None)
165
+ block = await home_block()
166
+ await update.message.reply_text(
167
+ block["text"], reply_markup=block["reply_markup"], parse_mode="Markdown"
168
+ )
169
+
170
+
171
+ async def error_handler(update: Update, context: ContextTypes.DEFAULT_TYPE):
172
+ if any(n.lower() in str(context.error).lower() for n in NOISE):
173
+ return
174
+ sentry_sdk.capture_exception(context.error)
175
+
176
+
177
+ async def start_scanner_bot(share_with=None, env_prefix=None, **options):
178
+ if env_prefix is None:
179
+ env_prefix = "" if share_with is None else "SCANNER_"
180
+ setup(env_prefix, **options)
181
+ required = ("owner_id", "db_url", "wallet_address")
182
+ if share_with is None:
183
+ required = ("token", *required)
184
+ missing = [
185
+ f"{env_prefix}{ENV_VARS[name]}"
186
+ for name in required
187
+ if not getattr(SETTINGS, name)
188
+ ]
189
+ if missing:
190
+ raise ValueError(f"Pair scanner needs these settings: {', '.join(missing)}")
191
+ if not SETTINGS.alerts_chat_id:
192
+ SETTINGS.alerts_chat_id = SETTINGS.owner_id
193
+ refresh_networks()
194
+
195
+ os.environ.setdefault("PTB_TIMEDELTA", "1")
196
+ for name in ("telegram", "httpx"):
197
+ logging.getLogger(name).addFilter(
198
+ lambda record: not any(n in record.getMessage() for n in NOISE)
199
+ )
200
+
201
+ await init_scanner_db()
202
+
203
+ mode = "trading" if int(OPTIONS.get("trading_enabled", 0)) else "watch-only"
204
+ if is_test_mode():
205
+ mode = "test mode"
206
+ if share_with is not None and not SETTINGS.token:
207
+ jobs.application = share_with
208
+ jobs.shares_host = True
209
+ if not is_test_mode():
210
+ jobs.start_jobs(share_with)
211
+ print(f"🚀 Pair scanner running on the host's bot ({mode})")
212
+ return share_with
213
+
214
+ application = Application.builder().token(SETTINGS.token).build()
215
+ application.add_handler(CommandHandler("start", command_start))
216
+ application.add_handler(
217
+ CallbackQueryHandler(handle_button, pattern=r"^(scanner:|cancel$|ignore$)")
218
+ )
219
+ application.add_handler(
220
+ MessageHandler(
221
+ filters.TEXT & ~filters.COMMAND & ~filters.UpdateType.CHANNEL_POSTS,
222
+ handle_text_input,
223
+ )
224
+ )
225
+ application.add_error_handler(error_handler)
226
+ if share_with is not None:
227
+ application.bot_data["host"] = share_with
228
+
229
+ await application.initialize()
230
+ await application.start()
231
+ jobs.application = application
232
+ jobs.shares_host = False
233
+ if not is_test_mode():
234
+ jobs.start_jobs(application)
235
+ await application.updater.start_polling(allowed_updates=Update.ALL_TYPES)
236
+ print(
237
+ f"🚀 Pair scanner running on its own bot @{application.bot.username} ({mode})"
238
+ )
239
+ return application
240
+
241
+
242
+ async def stop_scanner_bot():
243
+ application = jobs.application
244
+ if application is not None:
245
+ await jobs.stop_jobs(application)
246
+ if jobs.shares_host:
247
+ for name in jobs.JOBS:
248
+ for job in application.job_queue.get_jobs_by_name(name):
249
+ job.schedule_removal()
250
+ elif application.updater and application.updater.running:
251
+ await application.updater.stop()
252
+ if not jobs.shares_host and application.running:
253
+ await application.stop()
254
+ if not jobs.shares_host and application._initialized:
255
+ await application.shutdown()
256
+ jobs.application = None
257
+ jobs.shares_host = False
258
+ await close_w3()
259
+ await close_db()
@@ -0,0 +1,28 @@
1
+ import asyncio
2
+ import os
3
+
4
+ import sentry_sdk
5
+ from dotenv import find_dotenv, load_dotenv
6
+
7
+ from pair_scanner import start_scanner_bot, stop_scanner_bot
8
+
9
+
10
+ async def main():
11
+ load_dotenv(find_dotenv(usecwd=True))
12
+ sentry_sdk.init(dsn=os.environ.get("SENTRY_DSN"))
13
+ try:
14
+ await start_scanner_bot()
15
+ except ValueError as e:
16
+ print(f"❌ {e}. Add them to .env (see .env.example).")
17
+ return
18
+ try:
19
+ await asyncio.Event().wait()
20
+ finally:
21
+ await stop_scanner_bot()
22
+
23
+
24
+ if __name__ == "__main__":
25
+ try:
26
+ asyncio.run(main())
27
+ except KeyboardInterrupt:
28
+ pass
File without changes
@@ -0,0 +1,54 @@
1
+ import asyncio
2
+
3
+ from telegram import InlineKeyboardButton, InlineKeyboardMarkup
4
+
5
+ from ..networks import NETWORKS
6
+ from ..settings import SETTINGS
7
+ from ..w3.tools import eth_balance_delta, fetch_eth_usd_price, fetch_network_bal
8
+
9
+
10
+ async def balances_block(brief=False):
11
+ eth_usd = await fetch_eth_usd_price()
12
+
13
+ tasks = [
14
+ fetch_network_bal(n, c, SETTINGS.wallet_address) for n, c in NETWORKS.items()
15
+ ]
16
+ results = await asyncio.gather(*tasks)
17
+
18
+ total_eth = 0.0
19
+ buttons = []
20
+ body = ""
21
+ for name, eth_val in results:
22
+ if eth_val is not None:
23
+ usd_val = eth_val * eth_usd
24
+ total_eth += eth_val
25
+ body += f" ├ {name}: {eth_val:.4f} ETH (${usd_val:.2f})\n"
26
+ conf = NETWORKS.get(name, {})
27
+ base = conf.get("scan", "").replace("/tx/", "")
28
+ buttons.append(
29
+ InlineKeyboardButton(
30
+ f"View {name}", url=f"{base}/address/{SETTINGS.wallet_address}"
31
+ )
32
+ )
33
+ else:
34
+ body += f" ├ {name}: ⚠️ Connection Error\n"
35
+
36
+ total_usd = total_eth * eth_usd
37
+ body += f" └ *Total: {total_eth:.4f} ETH (${total_usd:.2f})*\n"
38
+
39
+ delta = await eth_balance_delta(total_eth)
40
+ delta_str = f" ({delta:+.2f}% 24h)" if delta is not None else ""
41
+
42
+ text = f" ₿ *Crypto*{delta_str}\n" + body + "\n"
43
+
44
+ kb = [buttons[i : i + 2] for i in range(0, len(buttons), 2)]
45
+
46
+ kb.append([InlineKeyboardButton("🔄 Refresh", callback_data="scanner:balances")])
47
+ kb.append([InlineKeyboardButton("❌ Close", callback_data="cancel")])
48
+
49
+ return {
50
+ "text": text,
51
+ "reply_markup": InlineKeyboardMarkup(kb),
52
+ "parse_mode": "Markdown",
53
+ "disable_web_page_preview": True,
54
+ }
@@ -0,0 +1,313 @@
1
+ from datetime import datetime, timedelta
2
+ from zoneinfo import ZoneInfo
3
+
4
+ from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
5
+ from telegram.ext import ContextTypes
6
+
7
+ from ..constants import PAIR_STATUS
8
+ from ..db.core import get_neighbours
9
+ from ..db.pairs import (
10
+ pairs_get_by_id,
11
+ pairs_get_by_status,
12
+ pairs_get_rejection_counts,
13
+ )
14
+ from ..helpers import (
15
+ escape_markdown,
16
+ format_duration,
17
+ format_timestamp,
18
+ )
19
+ from ..networks import NETWORKS
20
+ from ..settings import OPTIONS, SETTINGS
21
+ from ..w3.audit import (
22
+ audit_pair,
23
+ )
24
+
25
+
26
+ async def block_detail(context: ContextTypes.DEFAULT_TYPE, row_id, table):
27
+ pair_data = await pairs_get_by_id(row_id, "pairs")
28
+ prev_id, next_id = await get_neighbours(int(row_id), "pairs")
29
+
30
+ if not pair_data:
31
+ return {
32
+ "text": "❌ Pair not found (it may have been cleared).",
33
+ "reply_markup": InlineKeyboardMarkup(
34
+ [[InlineKeyboardButton("🔙 Back", callback_data="scanner:home")]]
35
+ ),
36
+ }
37
+
38
+ symbol = escape_markdown(pair_data.get("symbol") or "Unknown")
39
+ target = pair_data["target_address"]
40
+ pair_addr = pair_data["pair_address"]
41
+ status = pair_data["status"].upper()
42
+
43
+ local_tz = ZoneInfo(SETTINGS.timezone)
44
+ now = datetime.now(local_tz)
45
+ found_at = pair_data["found_at"].astimezone(local_tz)
46
+ audit_time = float(OPTIONS.get("audit_cooldown", 120))
47
+ unlock_time = found_at + timedelta(minutes=audit_time)
48
+
49
+ remaining_str = ""
50
+ if not pair_data["audit_done"]:
51
+ if now < unlock_time:
52
+ diff = unlock_time - now
53
+ total_mins = int(diff.total_seconds() / 60)
54
+ remaining_str = f" in {format_duration(total_mins)}"
55
+ else:
56
+ remaining_str = " Ready!"
57
+
58
+ date_str, age_str = format_timestamp(pair_data["found_at"])
59
+ network = pair_data["network"]
60
+ network_config = NETWORKS.get(network, NETWORKS["Base"])
61
+ explorer = network_config["scan"].replace("/tx/", "/address/")
62
+ dex = network_config["dex"]
63
+
64
+ retry_count = pair_data.get("retry_count", 0)
65
+ retry_str = f" ({retry_count} retries)" if retry_count > 0 else ""
66
+
67
+ msg = (
68
+ f"💎 *Pair Details: #{row_id}* (${symbol})\n\n"
69
+ f"🚦 *Status:* `{status}` {retry_str}\n"
70
+ f"🌐 *Network:* {network}\n"
71
+ f"🎯 *Token:* `{target}`\n"
72
+ f"💧 *Pair:* `{pair_addr}`\n"
73
+ f"🕒 *Found:* {date_str}\n"
74
+ f"⏳ *Age:* {age_str}\n"
75
+ f"📈 *Audit:*{'✅ Done' if pair_data['audit_done'] else remaining_str}\n"
76
+ )
77
+
78
+ keyboard = [
79
+ [
80
+ InlineKeyboardButton("🌍 Token Explorer", url=f"{explorer}{target}"),
81
+ InlineKeyboardButton("📊 Chart", url=f"{dex}{pair_addr}"),
82
+ ]
83
+ ]
84
+
85
+ if status != "completed":
86
+ keyboard.append(
87
+ [
88
+ InlineKeyboardButton(
89
+ "👀 Preview", callback_data=f"scanner:preview:{row_id}"
90
+ )
91
+ ]
92
+ )
93
+
94
+ keyboard.append(
95
+ [
96
+ InlineKeyboardButton(
97
+ "🗑️ Remove Pair",
98
+ callback_data=f"scanner:remove_confirm:{table}:{row_id}",
99
+ )
100
+ ]
101
+ )
102
+
103
+ nav_row = []
104
+ if prev_id:
105
+ nav_row.append(
106
+ InlineKeyboardButton(
107
+ f"⬅️ {prev_id}", callback_data=f"scanner:status:{prev_id}"
108
+ )
109
+ )
110
+ else:
111
+ nav_row.append(InlineKeyboardButton(" ", callback_data="ignore"))
112
+
113
+ nav_row.append(
114
+ InlineKeyboardButton("🔄 Refresh", callback_data=f"scanner:status:{row_id}")
115
+ )
116
+
117
+ if next_id:
118
+ nav_row.append(
119
+ InlineKeyboardButton(
120
+ f"{next_id} ➡️", callback_data=f"scanner:status:{next_id}"
121
+ )
122
+ )
123
+ else:
124
+ nav_row.append(InlineKeyboardButton(" ", callback_data="ignore"))
125
+
126
+ keyboard.append(nav_row)
127
+ keyboard.append(
128
+ [
129
+ InlineKeyboardButton(
130
+ f"🔙 Back to {pair_data['status'].replace('-', ' ').title()}",
131
+ callback_data=f"scanner:status:{pair_data['status']}",
132
+ )
133
+ ]
134
+ )
135
+ keyboard.append([InlineKeyboardButton("❌ Close", callback_data="cancel")])
136
+
137
+ return {
138
+ "text": msg,
139
+ "reply_markup": InlineKeyboardMarkup(keyboard),
140
+ "disable_web_page_preview": True,
141
+ }
142
+
143
+
144
+ async def block_list(context: ContextTypes.DEFAULT_TYPE, status_arg):
145
+ parts = status_arg.split(":")
146
+ status_input = parts[0].lower()
147
+ current_page = int(parts[1]) if len(parts) > 1 else 0
148
+
149
+ found_pairs = await pairs_get_by_status(status_input, "pairs")
150
+ if not found_pairs:
151
+ kb = InlineKeyboardMarkup(
152
+ [[InlineKeyboardButton("🔙 Back ", callback_data="scanner:home")]]
153
+ )
154
+ return {
155
+ "text": f"No pairs found with status: {status_input.capitalize()}",
156
+ "reply_markup": kb,
157
+ }
158
+
159
+ page_size = 10
160
+ total_count = len(found_pairs)
161
+ total_pages = (total_count + page_size - 1) // page_size
162
+ chunk = found_pairs[current_page * page_size : (current_page + 1) * page_size]
163
+
164
+ details = []
165
+ id_buttons = []
166
+ for entry in chunk:
167
+ rid = entry["id"]
168
+ sym = escape_markdown(entry.get("symbol") or "???")
169
+ _, age_str = format_timestamp(entry.get("found_at"))
170
+ details.append(f"`{rid}` | *{sym}* | {age_str}")
171
+ id_buttons.append(
172
+ InlineKeyboardButton(f"{rid}", callback_data=f"scanner:status:{rid}")
173
+ )
174
+
175
+ response_text = (
176
+ f"📋 *{status_input.upper()} Pairs* (Page {current_page + 1}/{total_pages})\n\n"
177
+ + "\n".join(details)
178
+ )
179
+
180
+ keyboard = []
181
+ nav_row = []
182
+ if current_page > 0:
183
+ nav_row.append(
184
+ InlineKeyboardButton(
185
+ "⬅️ Prev",
186
+ callback_data=f"scanner:status:{status_input}:{current_page - 1}",
187
+ )
188
+ )
189
+ if current_page < total_pages - 1:
190
+ nav_row.append(
191
+ InlineKeyboardButton(
192
+ "Next ➡️",
193
+ callback_data=f"scanner:status:{status_input}:{current_page + 1}",
194
+ )
195
+ )
196
+ if nav_row:
197
+ keyboard.append(nav_row)
198
+ for i in range(0, len(id_buttons), 5):
199
+ keyboard.append(id_buttons[i : i + 5])
200
+ keyboard.append(
201
+ [InlineKeyboardButton("🔙 Back to Scanner", callback_data="scanner:home")]
202
+ )
203
+
204
+ return {
205
+ "text": response_text,
206
+ "reply_markup": InlineKeyboardMarkup(keyboard),
207
+ "disable_web_page_preview": True,
208
+ }
209
+
210
+
211
+ async def button_buy_confirm(update: Update, context: ContextTypes.DEFAULT_TYPE):
212
+ query = update.callback_query
213
+ parts = query.data.split(":")
214
+ row_id = parts[2]
215
+ record = await pairs_get_by_id(row_id, "pairs")
216
+ symbol = escape_markdown((record or {}).get("symbol") or "Unknown")
217
+
218
+ await query.edit_message_text(
219
+ f"⚠️ *Confirm manual buy?*\n\n${symbol} #{row_id}\n",
220
+ parse_mode="Markdown",
221
+ reply_markup=InlineKeyboardMarkup(
222
+ [
223
+ [
224
+ InlineKeyboardButton(
225
+ "❌ Cancel",
226
+ callback_data=f"scanner:status:{row_id}",
227
+ ),
228
+ InlineKeyboardButton(
229
+ "✅ Yes, Buy",
230
+ callback_data=f"scanner:buy:{row_id}",
231
+ ),
232
+ ]
233
+ ]
234
+ ),
235
+ )
236
+
237
+
238
+ async def button_buy(update: Update, context: ContextTypes.DEFAULT_TYPE):
239
+ query = update.callback_query
240
+ parts = query.data.split(":")
241
+ row_id = parts[2]
242
+
243
+ pair_data = await pairs_get_by_id(row_id, "pairs")
244
+ result = await audit_pair(context, pair_data, force_buy=True) if pair_data else ""
245
+
246
+ block = await block_detail(context, row_id, "pairs")
247
+ await query.edit_message_text(
248
+ f"{block['text']}\n\n*{result}*" if result else block["text"],
249
+ reply_markup=block["reply_markup"],
250
+ parse_mode="Markdown",
251
+ disable_web_page_preview=True,
252
+ )
253
+
254
+
255
+ async def button_preview(update: Update, context: ContextTypes.DEFAULT_TYPE):
256
+ query = update.callback_query
257
+ parts = query.data.split(":")
258
+ row_id = parts[2]
259
+
260
+ pair_data = await pairs_get_by_id(row_id, "pairs")
261
+ block = await block_detail(context, row_id, "pairs")
262
+ if not pair_data:
263
+ await query.edit_message_text(
264
+ block["text"], reply_markup=block["reply_markup"], parse_mode="Markdown"
265
+ )
266
+ return
267
+
268
+ preview = await audit_pair(context, pair_data, preview=True)
269
+
270
+ preview_cb = f"scanner:preview:{row_id}"
271
+ buy_btn = InlineKeyboardButton(
272
+ "💰 Buy", callback_data=f"scanner:buy_confirm:{row_id}"
273
+ )
274
+ rows = [
275
+ [buy_btn if b.callback_data == preview_cb else b for b in row]
276
+ for row in block["reply_markup"].inline_keyboard
277
+ ]
278
+
279
+ await query.edit_message_text(
280
+ f"{block['text']}\n{preview}",
281
+ reply_markup=InlineKeyboardMarkup(rows),
282
+ parse_mode="Markdown",
283
+ disable_web_page_preview=True,
284
+ )
285
+
286
+
287
+ async def button_rejected(update: Update, context: ContextTypes.DEFAULT_TYPE):
288
+ query = update.callback_query
289
+ counts = await pairs_get_rejection_counts()
290
+ kb = []
291
+ for s in PAIR_STATUS:
292
+ count = counts.get(s, 0)
293
+ if count > 0:
294
+ display = s.replace("-", " ").title()
295
+ kb.append(
296
+ [
297
+ InlineKeyboardButton(
298
+ f"📁 {display} ({count})",
299
+ callback_data=f"scanner:status:{s}",
300
+ )
301
+ ]
302
+ )
303
+
304
+ kb.append(
305
+ [InlineKeyboardButton("🔙 Back to Scanner", callback_data="scanner:home")]
306
+ )
307
+ kb.append([InlineKeyboardButton("❌ Close", callback_data="cancel")])
308
+
309
+ await query.edit_message_text(
310
+ text="❌ *Rejected Audit Breakdown*\n\nSelect a category to view pairs:",
311
+ reply_markup=InlineKeyboardMarkup(kb),
312
+ parse_mode="Markdown",
313
+ )