// code from goatstore // api: https://store.agi.bd const axios = require("axios"); module.exports.config = { name: "weather", version: "1.0.0", author: "Zihad", aliases: ["w"], role: 0, category: "utility" }; module.exports.run = async function ({ api, event, args }) { const city = args.join(" ") || "Dhaka"; try { const geo = await axios.get( "https://geocoding-api.open-meteo.com/v1/search", { params: { name: city, count: 1, language: "en", format: "json" } } ); if (!geo.data.results || geo.data.results.length === 0) { return api.sendMessage( "❌ City not found!\nExample: /weather Dhaka", event.threadID, event.messageID ); } const location = geo.data.results[0]; const res = await axios.get( "https://api.open-meteo.com/v1/forecast", { params: { latitude: location.latitude, longitude: location.longitude, current_weather: true, timezone: "auto" } } ); const w = res.data.current_weather; const codes = { 0: "☀️ পরিষ্কার আকাশ", 1: "🌤️ হালকা মেঘ", 2: "⛅ আংশিক মেঘলা", 3: "☁️ মেঘলা", 45: "🌫️ কুয়াশা", 48: "🌫️ কুয়াশা", 51: "🌦️ হালকা গুঁড়ি বৃষ্টি", 53: "🌦️ গুঁড়ি বৃষ্টি", 55: "🌧️ বেশি গুঁড়ি বৃষ্টি", 61: "🌧️ হালকা বৃষ্টি", 63: "🌧️ বৃষ্টি", 65: "🌧️ ভারী বৃষ্টি", 80: "🌦️ বৃষ্টির ঝাপটা", 81: "🌧️ বৃষ্টির ঝাপটা", 82: "⛈️ ভারী বৃষ্টির ঝাপটা", 95: "⛈️ বজ্রঝড়", 96: "⛈️ বজ্রঝড় ও শিলাবৃষ্টি", 99: "⛈️ ভারী বজ্রঝড়" }; const condition = codes[w.weathercode] || "🌍 আবহাওয়া অজানা"; const msg = "🌦️ LIVE WEATHER\n" + "━━━━━━━━━━━━━━\n" + "📍 " + location.name + "\n" + "🌡️ Temperature: " + Math.round(w.temperature) + "°C\n" + condition + "\n" + "💨 Wind: " + Math.round(w.windspeed) + " km/h\n" + "🧭 Wind Direction: " + w.winddirection + "°\n" + "🕒 Time: " + w.time + "\n" + "━━━━━━━━━━━━━━\n" + "⚡ Weather by Zihad"; return api.sendMessage( msg, event.threadID, event.messageID ); } catch (error) { console.log(error); return api.sendMessage( "❌ Weather তথ্য পাওয়া যাচ্ছে না।\n🔄 কিছুক্ষণ পর আবার চেষ্টা করুন।", event.threadID, event.messageID ); } };