🕒 Time Plugin Help
!time <any city> – Get current time for ANY city worldwide
!time <IANA zone> – e.g., Europe/London, Asia/Karachi
!time help – Show this help
Examples:
!time Lahore
!time New York
!time Paris
!time Asia/Karachi
No city names are hardcoded. The bot uses Open-Meteo's geocoding API.
"""
def setup(bot):
logging.info("Time plugin (zero hardcoded cities) loaded.")
async def handle_command(room, message, bot, prefix, config):
match = botlib.MessageMatch(room, message, bot, prefix)
if not (match.is_not_from_this_bot() and match.prefix() and match.command("time")):
return
args = match.args()
if not args or args[0].lower() == "help":
await bot.api.send_markdown_message(room.room_id, help_text())
return
query = " ".join(args).strip()
await bot.api.send_text_message(room.room_id, f"🕒 Looking up time for: {query}...")
async with aiohttp.ClientSession() as session:
data, display = await resolve_time(session, query)
if data is None:
await bot.api.send_text_message(room.room_id, f"❌ {display}")
return
await bot.api.send_markdown_message(room.room_id, format_response(data, display))
logging.info(f"Time sent for {query}")