Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
CarolinePascal commited on
feat(Santiago): adding Santiago's information
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import calendar
|
|
| 2 |
import os
|
| 3 |
import threading
|
| 4 |
from datetime import datetime, timedelta
|
|
|
|
| 5 |
|
| 6 |
import discord
|
| 7 |
import gradio as gr
|
|
@@ -15,6 +16,73 @@ MY_GUILD = discord.Object(id=MY_GUILD_ID)
|
|
| 15 |
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN")
|
| 16 |
stripe.api_key = os.environ.get("STRIPE_API_KEY")
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
class Bot(commands.Bot):
|
| 20 |
"""This structure allows slash commands to work instantly."""
|
|
@@ -245,10 +313,19 @@ async def eta(interaction: discord.Interaction, invoice: str = None):
|
|
| 245 |
inv = results.data[0]
|
| 246 |
purchase_date = datetime.fromtimestamp(inv.created)
|
| 247 |
purchase_date = purchase_date.replace(hour=0, minute=0, second=0, microsecond=0)
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
else:
|
| 253 |
view = DatePickerView()
|
| 254 |
await interaction.response.send_message(
|
|
|
|
| 2 |
import os
|
| 3 |
import threading
|
| 4 |
from datetime import datetime, timedelta
|
| 5 |
+
from enum import Enum
|
| 6 |
|
| 7 |
import discord
|
| 8 |
import gradio as gr
|
|
|
|
| 16 |
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN")
|
| 17 |
stripe.api_key = os.environ.get("STRIPE_API_KEY")
|
| 18 |
|
| 19 |
+
# ORDER DETAILS
|
| 20 |
+
class ReachyMiniType(Enum):
|
| 21 |
+
Wireless = "Reachy-Mini (with Onboard Compute and battery)"
|
| 22 |
+
Lite = "Reachy Mini (Lite version)"
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def detect_reachy_types(inv) -> set[ReachyMiniType]:
|
| 26 |
+
types = set()
|
| 27 |
+
for line in inv.lines.data:
|
| 28 |
+
desc = line.description or ""
|
| 29 |
+
for rtype in ReachyMiniType:
|
| 30 |
+
if rtype.value in desc:
|
| 31 |
+
types.add(rtype)
|
| 32 |
+
return types
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def format_order_items(inv) -> str:
|
| 36 |
+
items = []
|
| 37 |
+
for line in inv.lines.data:
|
| 38 |
+
items.append(f"β’ {line.description} (x{line.quantity})")
|
| 39 |
+
return "\n".join(items)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def get_invoice_digits(invoice_number: str) -> int:
|
| 43 |
+
parts = invoice_number.split("-")
|
| 44 |
+
return int(parts[-1]) if parts[-1].isdigit() else 0
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def early_shipping_notes(types: set[ReachyMiniType], invoice_number: str, arrival_date: datetime) -> str:
|
| 48 |
+
now = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
|
| 49 |
+
notes = []
|
| 50 |
+
|
| 51 |
+
if ReachyMiniType.Lite in types:
|
| 52 |
+
if now < datetime(2026, 5, 1) and arrival_date > datetime(2026, 4, 30):
|
| 53 |
+
notes.append(
|
| 54 |
+
"π¬ All Reachy Mini Lite orders will be shipped **late April 2026** "
|
| 55 |
+
"β yours might arrive before the expected date!"
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
if ReachyMiniType.Wireless in types:
|
| 59 |
+
inv_num = get_invoice_digits(invoice_number)
|
| 60 |
+
if inv_num < 7000:
|
| 61 |
+
if now < datetime(2026, 4, 1) and arrival_date > datetime(2026, 3, 31):
|
| 62 |
+
notes.append(
|
| 63 |
+
"π¬ Reachy Mini Wireless orders with invoice number before 7000 will be shipped **late March 2026/early April 2026** "
|
| 64 |
+
"β yours might arrive before the expected date!"
|
| 65 |
+
)
|
| 66 |
+
else:
|
| 67 |
+
if now < datetime(2026, 7, 1) and arrival_date > datetime(2026, 6, 15):
|
| 68 |
+
notes.append(
|
| 69 |
+
"π¬ Reachy Mini Wireless orders with invoice number 7000 and above will be shipped **early June 2026** "
|
| 70 |
+
"β yours might arrive before the expected date!"
|
| 71 |
+
)
|
| 72 |
+
elif now < datetime(2026, 7, 1) and arrival_date <= datetime(2026, 6, 1):
|
| 73 |
+
notes.append(
|
| 74 |
+
"β οΈ There is a chance your Reachy Mini Wireless shipment might be delayed until **early June 2026**. "
|
| 75 |
+
"The Wireless version has been trickier to produce due to longer supply times "
|
| 76 |
+
"for some components (especially the Raspberry Pi). We apologize for the inconvenience."
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
notes.append(
|
| 80 |
+
"π You can manage your order through our Stripe customer portal:\n"
|
| 81 |
+
"https://billing.stripe.com/p/login/7sY5kFal10614vB4W873G00"
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
return "\n\n".join(notes)
|
| 85 |
+
|
| 86 |
|
| 87 |
class Bot(commands.Bot):
|
| 88 |
"""This structure allows slash commands to work instantly."""
|
|
|
|
| 313 |
inv = results.data[0]
|
| 314 |
purchase_date = datetime.fromtimestamp(inv.created)
|
| 315 |
purchase_date = purchase_date.replace(hour=0, minute=0, second=0, microsecond=0)
|
| 316 |
+
arrival_date = purchase_date + timedelta(days=90)
|
| 317 |
+
|
| 318 |
+
items_text = format_order_items(inv)
|
| 319 |
+
types = detect_reachy_types(inv)
|
| 320 |
+
shipping_notes = early_shipping_notes(types, invoice, arrival_date)
|
| 321 |
+
|
| 322 |
+
message = f"π Invoice number **{invoice}** found!\n\n"
|
| 323 |
+
message += f"π **Ordered items:**\n{items_text}\n\n"
|
| 324 |
+
message += format_eta_result(purchase_date)
|
| 325 |
+
if shipping_notes:
|
| 326 |
+
message += f"\n\n{shipping_notes}"
|
| 327 |
+
|
| 328 |
+
await interaction.followup.send(message, ephemeral=True)
|
| 329 |
else:
|
| 330 |
view = DatePickerView()
|
| 331 |
await interaction.response.send_message(
|