Spaces:
Sleeping
Sleeping
房價
Browse files- location.py +56 -0
location.py
CHANGED
|
@@ -245,6 +245,40 @@ def handle_location_message(event):
|
|
| 245 |
}
|
| 246 |
]
|
| 247 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
}
|
| 249 |
]
|
| 250 |
}
|
|
@@ -394,6 +428,16 @@ def handle_postback(event):
|
|
| 394 |
messages=[TextMessage(text=rental_info)]
|
| 395 |
)
|
| 396 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
|
| 398 |
|
| 399 |
def search_nearby_restaurants(lat, lng, api_key, radius=500, limit=10):
|
|
@@ -498,4 +542,16 @@ def get_rental_info(lat, lng, address):
|
|
| 498 |
f"地點:{address}\n"
|
| 499 |
f"平均租金:USD 650/月\n"
|
| 500 |
f"建議:適合學生與上班族居住。"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
)
|
|
|
|
| 245 |
}
|
| 246 |
]
|
| 247 |
}
|
| 248 |
+
},
|
| 249 |
+
{
|
| 250 |
+
"type": "bubble",
|
| 251 |
+
"hero": {
|
| 252 |
+
"type": "image",
|
| 253 |
+
"url": "https://cdn-icons-png.flaticon.com/512/1040/1040253.png",
|
| 254 |
+
"size": "full",
|
| 255 |
+
"aspectRatio": "20:13",
|
| 256 |
+
"aspectMode": "cover"
|
| 257 |
+
},
|
| 258 |
+
"body": {
|
| 259 |
+
"type": "box",
|
| 260 |
+
"layout": "vertical",
|
| 261 |
+
"contents": [
|
| 262 |
+
{"type": "text", "text": "房價行情", "weight": "bold", "size": "xl"},
|
| 263 |
+
{"type": "text", "text": address, "size": "sm", "color": "#888888", "wrap": True}
|
| 264 |
+
]
|
| 265 |
+
},
|
| 266 |
+
"footer": {
|
| 267 |
+
"type": "box",
|
| 268 |
+
"layout": "vertical",
|
| 269 |
+
"spacing": "sm",
|
| 270 |
+
"contents": [
|
| 271 |
+
{
|
| 272 |
+
"type": "button",
|
| 273 |
+
"style": "primary",
|
| 274 |
+
"action": {
|
| 275 |
+
"type": "postback",
|
| 276 |
+
"label": "查詢房價行情",
|
| 277 |
+
"data": f"housing,{latitude},{longitude},{address}"
|
| 278 |
+
}
|
| 279 |
+
}
|
| 280 |
+
]
|
| 281 |
+
}
|
| 282 |
}
|
| 283 |
]
|
| 284 |
}
|
|
|
|
| 428 |
messages=[TextMessage(text=rental_info)]
|
| 429 |
)
|
| 430 |
)
|
| 431 |
+
elif data.startswith("housing,"):
|
| 432 |
+
_, lat, lng, address = data.split(",", 3)
|
| 433 |
+
housing_info = get_housing_info(lat, lng, address)
|
| 434 |
+
with ApiClient(configuration) as api_client:
|
| 435 |
+
MessagingApi(api_client).reply_message(
|
| 436 |
+
ReplyMessageRequest(
|
| 437 |
+
reply_token=event.reply_token,
|
| 438 |
+
messages=[TextMessage(text=housing_info)]
|
| 439 |
+
)
|
| 440 |
+
)
|
| 441 |
|
| 442 |
|
| 443 |
def search_nearby_restaurants(lat, lng, api_key, radius=500, limit=10):
|
|
|
|
| 542 |
f"地點:{address}\n"
|
| 543 |
f"平均租金:USD 650/月\n"
|
| 544 |
f"建議:適合學生與上班族居住。"
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
def get_housing_info(lat, lng, address):
|
| 549 |
+
"""Fetch nearby housing price information."""
|
| 550 |
+
# Placeholder logic for fetching housing data
|
| 551 |
+
# Replace this with actual API calls or database queries
|
| 552 |
+
return (
|
| 553 |
+
f"🏠 附近房價行情:\n"
|
| 554 |
+
f"地點:{address}\n"
|
| 555 |
+
f"平均房價:USD 500,000\n"
|
| 556 |
+
f"建議:適合家庭居住。"
|
| 557 |
)
|