alphabagibagi commited on
Commit
152fdc7
·
verified ·
1 Parent(s): 75cd573

Update admin.py

Browse files
Files changed (1) hide show
  1. admin.py +58 -2
admin.py CHANGED
@@ -1557,6 +1557,38 @@ def format_message_to_html(text):
1557
 
1558
  return text
1559
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1560
  @app.route('/api/broadcast', methods=['POST'])
1561
  @login_required
1562
  def api_broadcast():
@@ -1624,6 +1656,17 @@ def api_broadcast():
1624
 
1625
  if resp.status_code == 200:
1626
  sent_count += 1
 
 
 
 
 
 
 
 
 
 
 
1627
  else:
1628
  error_detail = resp.json().get('description', 'Unknown error')
1629
  print(f"Broadcast Failed for {chat_id}: {error_detail}")
@@ -1699,12 +1742,25 @@ def cron_reset_coins():
1699
  if "/bot" in base_url.lower(): url = f"{base_url}{token}/sendMessage"
1700
  else: url = f"{base_url}/bot{token}/sendMessage"
1701
 
1702
- requests.post(url, json={
1703
  "chat_id": chat_id,
1704
  "text": formatted_message,
1705
  "parse_mode": "HTML"
1706
  }, timeout=5)
1707
- sent_count += 1
 
 
 
 
 
 
 
 
 
 
 
 
 
1708
  except:
1709
  continue
1710
 
 
1557
 
1558
  return text
1559
 
1560
+ # Define Bot Menus for post-broadcast restoration
1561
+ BOT_MENUS = {
1562
+ "main": {
1563
+ "text": "Welcome to the @iceboxai_bot.\n\n✨ <b>What you can create:</b>\n• Realistic photos\n• Anime & illustration\n• Cinematic portraits\n• Fantasy & concept art\n• Logos & product visuals\n\nChoose an option below to get started 👇",
1564
+ "keyboard": [
1565
+ [{"text": "Generate Image", "callback_data": "generate_mode"}],
1566
+ [{"text": "Generate Voice", "url": "https://t.me/iceboxai_voice_bot"}],
1567
+ [{"text": "GPT-5.1", "url": "https://t.me/chaticeboxai_bot"}],
1568
+ [{"text": "My Profile", "callback_data": "profile"}],
1569
+ [{"text": "Help & Support", "callback_data": "help"}]
1570
+ ]
1571
+ },
1572
+ "voice": {
1573
+ "text": "<b>Welcome to IceboxAI Voice</b>\n\nGenerate natural text-to-speech in seconds.\n\nSelect an option below to begin.\nEnter your text and choose your voice.",
1574
+ "keyboard": [
1575
+ [{"text": "Generate Voice", "callback_data": "generate_voice"}],
1576
+ [{"text": "Generate Image", "url": "https://t.me/iceboxai_bot"}],
1577
+ [{"text": "GPT-5.1", "url": "https://t.me/chaticeboxai_bot"}],
1578
+ [{"text": "My Profile", "callback_data": "profile"}],
1579
+ [{"text": "Help & Support", "callback_data": "help"}]
1580
+ ]
1581
+ },
1582
+ "chat": {
1583
+ "text": "<b>Welcome to Icebox AI Chat!</b>\n\nI'm an AI assistant that can help you:\n• Answer questions\n• Write and summarize text\n• Search the web\n\n<pre>\n📟 How to start:\nJust send any message.\n\nExamples:\n> Give me business ideas\n> Summarize this article\n> Find the latest AI news\n</pre>\n\n<b>⚙️ Commands:</b>\n• /help — show help\n• /model — model info\n• /clear — delete chat history",
1584
+ "keyboard": [
1585
+ [{"text": "⚙️ Model Settings", "callback_data": "select_model"}],
1586
+ [{"text": "🗑️ Clear Chat History", "callback_data": "clear_history"}],
1587
+ [{"text": "🏞️ Create Image", "url": "https://t.me/iceboxai_bot"}]
1588
+ ]
1589
+ }
1590
+ }
1591
+
1592
  @app.route('/api/broadcast', methods=['POST'])
1593
  @login_required
1594
  def api_broadcast():
 
1656
 
1657
  if resp.status_code == 200:
1658
  sent_count += 1
1659
+ # Restore Home Menu so user has keyboard back
1660
+ menu = BOT_MENUS.get(bot_target)
1661
+ if menu:
1662
+ import json
1663
+ menu_payload = {
1664
+ "chat_id": chat_id,
1665
+ "text": menu["text"],
1666
+ "parse_mode": "HTML",
1667
+ "reply_markup": json.dumps({"inline_keyboard": menu["keyboard"]})
1668
+ }
1669
+ requests.post(url, json=menu_payload, timeout=5)
1670
  else:
1671
  error_detail = resp.json().get('description', 'Unknown error')
1672
  print(f"Broadcast Failed for {chat_id}: {error_detail}")
 
1742
  if "/bot" in base_url.lower(): url = f"{base_url}{token}/sendMessage"
1743
  else: url = f"{base_url}/bot{token}/sendMessage"
1744
 
1745
+ res_notify = requests.post(url, json={
1746
  "chat_id": chat_id,
1747
  "text": formatted_message,
1748
  "parse_mode": "HTML"
1749
  }, timeout=5)
1750
+
1751
+ if res_notify.status_code == 200:
1752
+ sent_count += 1
1753
+ # Restore Home Menu
1754
+ menu = BOT_MENUS.get('main')
1755
+ if menu:
1756
+ import json
1757
+ menu_payload = {
1758
+ "chat_id": chat_id,
1759
+ "text": menu["text"],
1760
+ "parse_mode": "HTML",
1761
+ "reply_markup": json.dumps({"inline_keyboard": menu["keyboard"]})
1762
+ }
1763
+ requests.post(url, json=menu_payload, timeout=5)
1764
  except:
1765
  continue
1766