Download modules/bank.py from ABO3MR/df: direct link, hf CLI and curl.
- Browser
- Download file 24.1 kB
-
https://huggingface.co/spaces/ABO3MR/df/resolve/main/modules/bank.py
- Command line
-
hf download hf://spaces/ABO3MR/df/modules/bank.py
-
curl -L -o bank.py https://huggingface.co/spaces/ABO3MR/df/resolve/main/modules/bank.py
24.1 kB
| """لعبة البنك: حسابات، راتب، حظ، كنز، بخشيش، زرف، هجوم، تحويل، هدايا، | |
| إيداع بفوايد، استثمار، مضاربة، متجر ومخزن، توب الفلوس، كشف حساب. | |
| كل الفلوس وهمية للتسلية بس. الكولداونات بتمنع السبام.""" | |
| import random, time | |
| from telegram import InlineKeyboardMarkup | |
| from telegram.ext import CallbackQueryHandler | |
| from core.router import exact, prefix | |
| from core.store import settings | |
| from core import ranks as R | |
| from core.kb import btn | |
| from strings_ar import S, frame | |
| import config | |
| START_BONUS = 5000 | |
| DAILY_AMT = 1000 | |
| INTEREST_RATE = 0.05 # 5% كل يوم على رصيد البنك | |
| CD = {"راتب": 86400, "حظ": 300, "بخشيش": 1800, "كنز": 7200, | |
| "زرف": 3600, "هجوم": 14400, "مضاربه": 600, "روليت": 120} | |
| SHOP = [ | |
| ("☕ قهوة", 100), ("🍕 بيتزا", 150), ("🎧 سماعة", 2000), ("🚲 عجلة", 5000), | |
| ("📱 موبايل", 15000), ("💻 لابتوب", 30000), ("🛵 موتوسيكل", 40000), | |
| ("🚗 عربية", 150000), ("🏎 عربية سبورت", 400000), ("🏠 شقة", 500000), | |
| ("🏰 قصر", 2000000), ("🛥 يخت", 5000000), ("✈️ طيارة خاصة", 20000000), | |
| ("🏝 جزيرة خاصة", 100000000), | |
| ] | |
| SHOP_MAP = {name: price for name, price in SHOP} | |
| SELL_RATE = 0.7 | |
| def _db(chat): | |
| return settings.get(chat, "bank2", {}) | |
| def _save(chat, d): | |
| settings.set(chat, "bank2", d) | |
| def _acc(chat, uid): | |
| return _db(chat).get(str(uid)) | |
| def _new_acc(): | |
| return {"w": START_BONUS, "b": 0, "dep_t": time.time(), "inv": None, | |
| "cd": {}, "log": ["فتح الحساب +5,000"], "items": {}} | |
| def _open(chat, uid): | |
| d = _db(chat) | |
| a = _new_acc() | |
| d[str(uid)] = a | |
| _save(chat, d) | |
| return a | |
| def _touch(chat, uid, a): | |
| d = _db(chat) | |
| d[str(uid)] = a | |
| _save(chat, d) | |
| def _log(chat, uid, a, line): | |
| a["log"] = (a.get("log") or [])[-9:] + [line] | |
| _touch(chat, uid, a) | |
| def _fmt(n): | |
| return f"{int(n):,}" | |
| def _cd_left(a, name): | |
| left = a.get("cd", {}).get(name, 0) + CD[name] - time.time() | |
| return max(0, left) | |
| def _left_txt(sec): | |
| sec = int(sec) | |
| if sec >= 3600: | |
| return f"{sec // 3600} ساعة و{(sec % 3600) // 60} دقيقة" | |
| if sec >= 60: | |
| return f"{sec // 60} دقيقة و{sec % 60} ثانية" | |
| return f"{sec} ثانية" | |
| def _mark_cd(a, name): | |
| a.setdefault("cd", {})[name] = time.time() | |
| def _apply_interest(chat, uid, a): | |
| """بيحسب الفوايد المستحقة (5% لكل يوم كامل، بحد أقصى 30 يوم).""" | |
| days = int((time.time() - a.get("dep_t", time.time())) // 86400) | |
| days = min(days, 30) | |
| if days > 0 and a.get("b", 0) > 0: | |
| gain = int(a["b"] * INTEREST_RATE * days) | |
| a["b"] += gain | |
| a["dep_t"] = time.time() | |
| _log(chat, uid, a, f"فوايد +{_fmt(gain)}") | |
| return gain | |
| return 0 | |
| async def _reply_to(update): | |
| r = update.message.reply_to_message | |
| return r.from_user if r else None | |
| # ---------- الحساب ---------- | |
| async def open_acc(update, ctx, arg=""): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| if _acc(c, u): | |
| await update.message.reply_text(S["bank_have"]) | |
| return | |
| _open(c, u) | |
| await update.message.reply_text(S["bank_open"]) | |
| async def wallet(update, ctx, arg=""): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]) | |
| return | |
| _apply_interest(c, u, a) | |
| await update.message.reply_text(S["bank_wallet"].format( | |
| w=_fmt(a["w"]), b=_fmt(a["b"]), t=_fmt(a["w"] + a["b"]), | |
| items=sum(a.get("items", {}).values()))) | |
| async def his_wallet(update, ctx, arg=""): | |
| t = await _reply_to(update) | |
| c = update.effective_chat.id | |
| if not t: | |
| await update.message.reply_text(S["need_reply"]) | |
| return | |
| a = _acc(c, t.id) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]) | |
| return | |
| _apply_interest(c, t.id, a) | |
| await update.message.reply_text(S["bank_wallet_his"].format( | |
| name=t.first_name, w=_fmt(a["w"]), b=_fmt(a["b"]), t=_fmt(a["w"] + a["b"]))) | |
| async def reset_me(update, ctx, arg=""): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| d = _db(c) | |
| d.pop(str(u), None) | |
| _save(c, d) | |
| await update.message.reply_text(S["bank_reset"]) | |
| # ---------- قائمة البنك ---------- | |
| def _bank_kb(): | |
| return InlineKeyboardMarkup([ | |
| [btn("💰 راتب", "bk:daily", style="success"), btn("🎲 حظ", "bk:luck", style="primary")], | |
| [btn("💎 كنز", "bk:treasure", style="primary"), btn("🤲 بخشيش", "bk:tip", style="primary")], | |
| [btn("📈 فوايد", "bk:interest", style="primary"), btn("📊 استثماري", "bk:invest_status", style="primary")], | |
| [btn("🛒 المتجر", "bk:shop", style="success"), btn("🎒 مخزني", "bk:inv", style="success")], | |
| [btn("🏆 توب الفلوس", "bk:top", style="primary"), btn("📜 كشف حساب", "bk:log", style="primary")], | |
| [btn("💳 فلوسي", "bk:wallet", style="primary")], | |
| ]) | |
| async def bank_menu(update, ctx, arg=""): | |
| await update.message.reply_text(S["bank_menu"], reply_markup=_bank_kb()) | |
| # ---------- الدخل والحظ ---------- | |
| async def _earn_cmd(update, ctx, name, func): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]); return | |
| left = _cd_left(a, name) | |
| if left: | |
| await update.message.reply_text(S["bank_cd"].format(h=_left_txt(left))); return | |
| _mark_cd(a, name) | |
| await func(update, c, u, a) | |
| async def _do_daily(update, c, u, a): | |
| a["w"] += DAILY_AMT | |
| _log(c, u, a, f"راتب +{_fmt(DAILY_AMT)}") | |
| await update.message.reply_text(S["bank_daily"].format(amt=_fmt(DAILY_AMT))) | |
| async def daily(update, ctx, arg=""): | |
| await _earn_cmd(update, ctx, "راتب", _do_daily) | |
| async def _do_luck(update, c, u, a): | |
| amt = random.randint(50, 800) | |
| if random.random() < 0.5: | |
| a["w"] += amt | |
| _log(c, u, a, f"حظ +{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_luck_win"].format(amt=_fmt(amt))) | |
| else: | |
| lose = min(a["w"], amt) | |
| a["w"] -= lose | |
| _log(c, u, a, f"حظ -{_fmt(lose)}") | |
| await update.message.reply_text(S["bank_luck_lose" if lose else "bank_luck_lose_none"].format(amt=_fmt(lose))) | |
| async def luck(update, ctx, arg=""): | |
| await _earn_cmd(update, ctx, "حظ", _do_luck) | |
| async def _do_tip(update, c, u, a): | |
| amt = random.randint(50, 300) | |
| a["w"] += amt | |
| _log(c, u, a, f"بخشيش +{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_tip"].format(amt=_fmt(amt))) | |
| async def tip(update, ctx, arg=""): | |
| await _earn_cmd(update, ctx, "بخشيش", _do_tip) | |
| async def _do_treasure(update, c, u, a): | |
| if random.random() < 0.2: | |
| _touch(c, u, a) | |
| await update.message.reply_text(S["bank_treasure_none"]); return | |
| amt = random.randint(200, 2000) | |
| a["w"] += amt | |
| _log(c, u, a, f"كنز +{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_treasure"].format(amt=_fmt(amt))) | |
| async def treasure(update, ctx, arg=""): | |
| await _earn_cmd(update, ctx, "كنز", _do_treasure) | |
| # ---------- زرف وهجوم (بالرد) ---------- | |
| async def _steal_common(update, ctx, name, chance, lo, hi, fine_rate): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| t = await _reply_to(update) | |
| if not t or t.id == u: | |
| await update.message.reply_text(S["need_reply"]); return | |
| a, v = _acc(c, u), _acc(c, t.id) | |
| if not a or not v: | |
| await update.message.reply_text(S["bank_none"]); return | |
| left = _cd_left(a, name) | |
| if left: | |
| await update.message.reply_text(S["bank_cd"].format(h=_left_txt(left))); return | |
| _mark_cd(a, name) | |
| if v["w"] < 50: | |
| _touch(c, u, a) | |
| await update.message.reply_text(S["bank_steal_poor"]); return | |
| if random.random() < chance: | |
| amt = max(10, int(v["w"] * random.uniform(lo, hi))) | |
| v["w"] -= amt | |
| a["w"] += amt | |
| _log(c, u, a, f"{name} من {t.first_name} +{_fmt(amt)}") | |
| _log(c, t.id, v, f"ات{'' if name=='زرف' else 'ه'}جم عليك {update.effective_user.first_name} -{_fmt(amt)}") | |
| await update.message.reply_text( | |
| S["bank_steal_ok" if name == "زرف" else "bank_attack_ok"].format(amt=_fmt(amt), victim=t.first_name)) | |
| else: | |
| fine = max(0, int(a["w"] * fine_rate)) | |
| a["w"] -= fine | |
| v["w"] += fine | |
| _log(c, u, a, f"غرامة {name} -{_fmt(fine)}") | |
| _log(c, t.id, v, f"تعويض من {update.effective_user.first_name} +{_fmt(fine)}") | |
| await update.message.reply_text( | |
| S["bank_steal_fail" if name == "زرف" else "bank_attack_fail"].format(amt=_fmt(fine), victim=t.first_name)) | |
| async def steal(update, ctx, arg=""): | |
| await _steal_common(update, ctx, "زرف", 0.45, 0.10, 0.30, 0.10) | |
| async def attack(update, ctx, arg=""): | |
| await _steal_common(update, ctx, "هجوم", 0.30, 0.30, 0.50, 0.25) | |
| # ---------- روليت (رهان بمبلغ، فرصة 45% تدبل) ---------- | |
| async def roulette(update, ctx, arg): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]); return | |
| amt = _parse_amount(arg) | |
| if amt is None: | |
| await update.message.reply_text(S["bank_amount"]); return | |
| left = _cd_left(a, "روليت") | |
| if left: | |
| await update.message.reply_text(S["bank_cd"].format(h=_left_txt(left))); return | |
| if a["w"] < amt: | |
| await update.message.reply_text(S["bank_no_funds"]); return | |
| _mark_cd(a, "روليت") | |
| a["w"] -= amt | |
| if random.random() < 0.45: | |
| win = amt * 2 | |
| a["w"] += win | |
| _log(c, u, a, f"روليت +{_fmt(win)}") | |
| await update.message.reply_text(S["bank_roulette_win"].format(amt=_fmt(amt), win=_fmt(win))) | |
| else: | |
| _log(c, u, a, f"روليت -{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_roulette_lose"].format(amt=_fmt(amt))) | |
| # ---------- تحويل وهدية ---------- | |
| def _parse_amount(arg): | |
| arg = (arg or "").replace(",", "").strip() | |
| return int(arg) if arg.isdigit() and int(arg) > 0 else None | |
| async def _move(update, ctx, arg, is_gift): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| t = await _reply_to(update) | |
| amt = _parse_amount(arg) | |
| if not t or amt is None: | |
| await update.message.reply_text(S["bank_usage"]); return | |
| a, v = _acc(c, u), _acc(c, t.id) | |
| if not a or not v or t.id == u: | |
| await update.message.reply_text(S["bank_none"]); return | |
| if a["w"] < amt: | |
| await update.message.reply_text(S["bank_no_funds"]); return | |
| a["w"] -= amt | |
| v["w"] += amt | |
| verb = "هدية" if is_gift else "تحويل" | |
| _log(c, u, a, f"{verb} لـ {t.first_name} -{_fmt(amt)}") | |
| _log(c, t.id, v, f"{verb} من {update.effective_user.first_name} +{_fmt(amt)}") | |
| key = "bank_gift" if is_gift else "bank_transfer" | |
| await update.message.reply_text(S[key].format(amt=_fmt(amt), name=t.first_name, | |
| a=update.effective_user.first_name, b=t.first_name)) | |
| async def transfer(update, ctx, arg): | |
| await _move(update, ctx, arg, False) | |
| async def gift(update, ctx, arg): | |
| await _move(update, ctx, arg, True) | |
| # ---------- إيداع وسحب وفوايد ---------- | |
| async def deposit(update, ctx, arg): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| amt = _parse_amount(arg) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]); return | |
| if amt is None: | |
| await update.message.reply_text(S["bank_amount"]); return | |
| _apply_interest(c, u, a) | |
| if a["w"] < amt: | |
| await update.message.reply_text(S["bank_no_funds"]); return | |
| a["w"] -= amt | |
| a["b"] += amt | |
| _log(c, u, a, f"ايداع -{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_deposit"].format(amt=_fmt(amt))) | |
| async def withdraw(update, ctx, arg): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| amt = _parse_amount(arg) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]); return | |
| if amt is None: | |
| await update.message.reply_text(S["bank_amount"]); return | |
| _apply_interest(c, u, a) | |
| if a["b"] < amt: | |
| await update.message.reply_text(S["bank_no_funds"]); return | |
| a["b"] -= amt | |
| a["w"] += amt | |
| _log(c, u, a, f"سحب +{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_withdraw"].format(amt=_fmt(amt))) | |
| async def interest(update, ctx, arg=""): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]); return | |
| gain = _apply_interest(c, u, a) | |
| if gain: | |
| await update.message.reply_text(S["bank_interest"].format(amt=_fmt(gain), b=_fmt(a["b"]))) | |
| else: | |
| await update.message.reply_text(S["bank_interest_none"]) | |
| # ---------- استثمار ومضاربة ---------- | |
| async def invest(update, ctx, arg): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| amt = _parse_amount(arg) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]); return | |
| if amt is None: | |
| await update.message.reply_text(S["bank_amount"]); return | |
| if a.get("inv"): | |
| left = a["inv"]["t"] + 21600 - time.time() | |
| await update.message.reply_text(S["bank_invest_wait"].format(h=_left_txt(max(0, left)))); return | |
| if a["w"] < amt: | |
| await update.message.reply_text(S["bank_no_funds"]); return | |
| a["w"] -= amt | |
| a["inv"] = {"amt": amt, "t": time.time()} | |
| _log(c, u, a, f"استثمار -{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_invest_start"].format(amt=_fmt(amt))) | |
| async def invest_status(update, ctx, arg=""): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| if not a or not a.get("inv"): | |
| await update.message.reply_text(S["bank_invest_none"]); return | |
| left = a["inv"]["t"] + 21600 - time.time() | |
| if left > 0: | |
| await update.message.reply_text(S["bank_invest_wait"].format(h=_left_txt(left))); return | |
| amt = a["inv"]["amt"] | |
| a["inv"] = None | |
| if random.random() < 0.25: | |
| back = int(amt * random.uniform(0.6, 0.9)) | |
| result = f"خسارة {_fmt(amt - back)} 😔" | |
| else: | |
| back = int(amt * random.uniform(1.05, 1.9)) | |
| result = f"ربح {_fmt(back - amt)} 🤑" | |
| a["w"] += back | |
| _log(c, u, a, f"حصاد استثمار +{_fmt(back)}") | |
| await update.message.reply_text(S["bank_invest_done"].format(amt=_fmt(back), result=result)) | |
| async def gamble(update, ctx, arg): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]); return | |
| amt = _parse_amount(arg) | |
| if amt is None: | |
| await update.message.reply_text(S["bank_amount"]); return | |
| left = _cd_left(a, "مضاربه") | |
| if left: | |
| await update.message.reply_text(S["bank_cd"].format(h=_left_txt(left))); return | |
| if a["w"] < amt: | |
| await update.message.reply_text(S["bank_no_funds"]); return | |
| _mark_cd(a, "مضاربه") | |
| if random.random() < 0.5: | |
| a["w"] += amt | |
| _log(c, u, a, f"مضاربة كسبانة +{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_gamble_win"].format(amt=_fmt(amt), won=_fmt(amt * 2))) | |
| else: | |
| a["w"] -= amt | |
| _log(c, u, a, f"مضاربة خسرانة -{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_gamble_lose"].format(amt=_fmt(amt))) | |
| # ---------- المتجر والمخزن ---------- | |
| def _shop_kb(): | |
| rows = [] | |
| row = [] | |
| for i, (name, price) in enumerate(SHOP): | |
| row.append(btn(f"{name} - {_fmt(price)}", f"shop:buy:{i}", style="success")) | |
| if len(row) == 2: | |
| rows.append(row); row = [] | |
| if row: | |
| rows.append(row) | |
| return InlineKeyboardMarkup(rows) | |
| async def shop(update, ctx, arg=""): | |
| await update.message.reply_text(S["shop_title"], reply_markup=_shop_kb()) | |
| def _inv_kb(a): | |
| rows = [] | |
| for name, cnt in (a.get("items") or {}).items(): | |
| if cnt > 0: | |
| sell = int(SHOP_MAP.get(name, 0) * SELL_RATE) | |
| rows.append([btn(f"بيع {name} (x{cnt}) +{_fmt(sell)}", f"shop:sell:{name}", style="primary")]) | |
| return InlineKeyboardMarkup(rows) if rows else None | |
| async def inv(update, ctx, arg=""): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]); return | |
| items = {k: v for k, v in (a.get("items") or {}).items() if v > 0} | |
| if not items: | |
| await update.message.reply_text(S["inv_empty"]); return | |
| lines = [S["inv_title"]] + [f"✧︙{k} × {v}" for k, v in items.items()] | |
| lines.append("✧︙دوس على زر البيع تحت لو عايز تبيع حاجة (بـ 70% من سعرها)") | |
| await update.message.reply_text("\n".join(lines), reply_markup=_inv_kb(a)) | |
| async def shop_cb(update, ctx): | |
| q = update.callback_query | |
| c, u = q.message.chat.id, q.from_user.id | |
| parts = q.data.split(":", 2) | |
| a = _acc(c, u) | |
| if not a: | |
| await q.answer(S["bank_none"], show_alert=True); return | |
| if parts[1] == "buy": | |
| name, price = SHOP[int(parts[2])] | |
| if a["w"] < price: | |
| await q.answer(S["shop_poor"].format(item=name), show_alert=True); return | |
| a["w"] -= price | |
| a.setdefault("items", {})[name] = a.setdefault("items", {}).get(name, 0) + 1 | |
| _log(c, u, a, f"شراء {name} -{_fmt(price)}") | |
| await q.answer(S["shop_buy"].format(item=name, amt=_fmt(price)), show_alert=True) | |
| elif parts[1] == "sell": | |
| name = parts[2] | |
| if a.get("items", {}).get(name, 0) <= 0: | |
| await q.answer("✧︙مش موجود في مخزنك.", show_alert=True); return | |
| sell = int(SHOP_MAP.get(name, 0) * SELL_RATE) | |
| a["items"][name] -= 1 | |
| a["w"] += sell | |
| _log(c, u, a, f"بيع {name} +{_fmt(sell)}") | |
| await q.answer(S["inv_sell"].format(item=name, amt=_fmt(sell)), show_alert=True) | |
| try: | |
| await q.edit_message_reply_markup(reply_markup=_inv_kb(a)) | |
| except Exception: | |
| pass | |
| # ---------- توب الفلوس وكشف الحساب ---------- | |
| async def top_money(update, ctx, arg=""): | |
| c = update.effective_chat.id | |
| d = _db(c) | |
| if not d: | |
| await update.message.reply_text(S["bank_top_empty"]); return | |
| rows = [] | |
| for uid, a in d.items(): | |
| rows.append((uid, a.get("w", 0) + a.get("b", 0))) | |
| rows.sort(key=lambda x: -x[1]) | |
| lines = [S["bank_top"]] | |
| for i, (uid, total) in enumerate(rows[:10], 1): | |
| try: | |
| m = await update.effective_chat.get_member(int(uid)) | |
| nm = m.user.first_name | |
| except Exception: | |
| nm = "عضو " + uid | |
| lines.append(f"{i}⏐ {nm} ← {_fmt(total)} جنيه") | |
| await update.message.reply_text("\n".join(lines)) | |
| async def log_cmd(update, ctx, arg=""): | |
| c, u = update.effective_chat.id, update.effective_user.id | |
| a = _acc(c, u) | |
| if not a or not a.get("log"): | |
| await update.message.reply_text(S["bank_log_empty"]); return | |
| lines = [S["bank_log"]] + ["✧︙" + x for x in reversed(a["log"][-8:])] | |
| await update.message.reply_text("\n".join(lines)) | |
| # ---------- أوامر إدارة البنك ---------- | |
| async def confiscate(update, ctx, arg=""): | |
| if await R.effective_level(update) < R.level("ادمن"): | |
| await update.message.reply_text(S["need_rank"]); return | |
| t = await _reply_to(update) | |
| if not t: | |
| await update.message.reply_text(S["need_reply"]); return | |
| c = update.effective_chat.id | |
| a = _acc(c, t.id) | |
| if not a: | |
| await update.message.reply_text(S["bank_none"]); return | |
| a["w"] = 0; a["b"] = 0 | |
| _log(c, t.id, a, "مصادرة الإدارة") | |
| await update.message.reply_text(S["bank_confiscate"].format(name=t.first_name)) | |
| async def bonus(update, ctx, arg): | |
| """المطور بس: بونص مبلغ بالرد (فلوس وهمية).""" | |
| if update.effective_user.id != config.OWNER_ID: | |
| await update.message.reply_text(S["need_rank"]); return | |
| t = await _reply_to(update) | |
| amt = _parse_amount(arg) | |
| if not t or amt is None: | |
| await update.message.reply_text(S["bank_usage"]); return | |
| c = update.effective_chat.id | |
| a = _acc(c, t.id) or _open(c, t.id) | |
| a["w"] += amt | |
| _log(c, t.id, a, f"بونص المطور +{_fmt(amt)}") | |
| await update.message.reply_text(S["bank_bonus"].format(name=t.first_name, amt=_fmt(amt))) | |
| # ---------- أزرار قائمة البنك ---------- | |
| async def bank_cb(update, ctx): | |
| q = update.callback_query | |
| action = q.data.split(":")[1] | |
| c, u = q.message.chat.id, q.from_user.id | |
| a = _acc(c, u) | |
| class FakeMsg: | |
| def __init__(self, q): | |
| self._q = q | |
| self.reply_to_message = None | |
| async def reply_text(self, text, **kw): | |
| await self._q.message.reply_text(text, **kw) | |
| fake_update = type("U", (), {"message": FakeMsg(q), "effective_chat": q.message.chat, | |
| "effective_user": q.from_user})() | |
| if action == "shop": | |
| await q.answer() | |
| await q.message.reply_text(S["shop_title"], reply_markup=_shop_kb()) | |
| return | |
| if action == "inv": | |
| await q.answer() | |
| await inv(fake_update, ctx) | |
| return | |
| if action == "top": | |
| await q.answer() | |
| await top_money(fake_update, ctx) | |
| return | |
| if action == "log": | |
| await q.answer() | |
| await log_cmd(fake_update, ctx) | |
| return | |
| if action == "wallet": | |
| await q.answer() | |
| await wallet(fake_update, ctx) | |
| return | |
| if action == "invest_status": | |
| await q.answer() | |
| await invest_status(fake_update, ctx) | |
| return | |
| if action == "interest": | |
| await q.answer() | |
| await interest(fake_update, ctx) | |
| return | |
| # باقي الأزرار: أوامر دخل ليها كولداون | |
| name = {"daily": "راتب", "luck": "حظ", "tip": "بخشيش", "treasure": "كنز"}.get(action) | |
| if not name: | |
| await q.answer(); return | |
| if not a: | |
| await q.answer(S["bank_none"], show_alert=True); return | |
| left = _cd_left(a, name) | |
| if left: | |
| await q.answer(S["bank_cd"].format(h=_left_txt(left)), show_alert=True); return | |
| await q.answer() | |
| _mark_cd(a, name) | |
| fn = {"راتب": _do_daily, "حظ": _do_luck, "بخشيش": _do_tip, "كنز": _do_treasure}[name] | |
| await fn(fake_update, c, u, a) | |
| HANDLERS = [CallbackQueryHandler(shop_cb, pattern=r"^shop:"), | |
| CallbackQueryHandler(bank_cb, pattern=r"^bk:")] | |