Skip to content

Commit

Permalink
feat: Support multiple Parade Miis in the channel
Browse files Browse the repository at this point in the history
  • Loading branch information
noahpistilli committed Jul 5, 2024
1 parent 0986a55 commit f2b7ff9
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions url1/special/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
@app.route("/url1/special/<page>/page.xml")
@xml_node_name("SpPage")
def special_page_n(page):
room_data = Rooms.query.filter(Rooms.room_id == page).first()

query = (
db.session.query(Rooms, RoomMiis, MiiData)
.filter(Rooms.room_id == page)
.filter(Rooms.room_id == RoomMiis.room_id)
db.session.query(RoomMiis, MiiData)
.filter(RoomMiis.mii_id == MiiData.mii_id)
.first()
.order_by(RoomMiis.seq)
.all()
)

if not query:
return exceptions.NotFound()

room_data, room_mii, mii_data = query
menu_data = db.session.query(RoomMenu).filter(RoomMenu.room_id == page).all()

menus = []
Expand All @@ -41,10 +41,25 @@ def special_page_n(page):
)
)

mii_msgs = []
for i, msg in enumerate(room_mii.mii_msg.split("\n")):
mii_msgs.append(
RepeatedElement({"msgseq": i + 1, "msg": "\n".join(wrap(msg, 23))})
miis = []
for room_mii, mii_data in query:
mii_msgs = []
for i, msg in enumerate(room_mii.mii_msg.split("\n")):
mii_msgs.append(
RepeatedElement({"msgseq": i + 1, "msg": "\n".join(wrap(msg, 23))})
)

print(room_mii.seq)
miis.append(
RepeatedElement(
{
"seq": room_mii.seq,
"miiid": mii_data.mii_id,
"color1": mii_data.color1,
"color2": mii_data.color2,
"msginfo": mii_msgs,
},
)
)

return {
Expand All @@ -60,13 +75,7 @@ def special_page_n(page):
# If we have contact data, we should enable contacting.
"contact": room_data.contact_data is not None,
"intro": {"inmsginfo": intro_msgs},
"miiinfo": {
"seq": 1,
"miiid": mii_data.mii_id,
"color1": mii_data.color1,
"color2": mii_data.color2,
"msginfo": mii_msgs,
},
"miiinfo": miis,
"menu": menus,
"logo": {
# We hardcode all parade logo IDs to g1234.
Expand Down

0 comments on commit f2b7ff9

Please sign in to comment.