The `air-quality` repository contains a Python-based project designed to provide automated air quality updates for Phnom Penh, Cambodia, via a Telegram bot. The primary goal is to keep users informed
Updated December 2, 2025
Page Viewers
131
0 users~131 guests
Guest Views
~131 views from anonymous visitors
v2
Overview
The air-quality repository contains a Python-based project designed to provide automated air quality updates for Phnom Penh, Cambodia, via a Telegram bot. The primary goal is to keep users informed about the current air quality conditions and offer relevant advice in multiple languages.
Main Purpose
The core functionality revolves around the intell1slt_bot Telegram bot, which periodically fetches air quality data for Phnom Penh and disseminates this information to a designated Telegram chat. It aims to raise awareness and provide actionable guidance based on the Air Quality Index (AQI).
Key Features
Automated Air Quality Monitoring: Regularly retrieves the Air Quality Index (AQI) for Phnom Penh, Cambodia, from the AirVisual API.
Multilingual Support: All messages are generated and sent in four languages: Khmer (kh), English (en), Japanese (jp), and German (de), catering to a diverse audience.
Dynamic Advice System: Based on the current AQI value, the bot provides category-specific verdicts (e.g., "good," "moderate," "unhealthy") and practical advice (e.g., "Go outside," "Wear a mask," "Stay indoors").
Scheduled Updates:
Sends a comprehensive morning message at 6:00 AM daily.
Sends a sign-off message at 9:00 PM daily.
Provides hourly updates for "good" and "moderate" air quality categories.
Increases update frequency to every 30, 15, 10, or 5 minutes for "unhealthy for sensitive groups," "unhealthy," "very unhealthy," and "hazardous" categories, respectively, ensuring timely alerts during critical periods.
AQI Change Detection: The bot tracks previous AQI values and reports whether the air quality has "improved," "deteriorated," or remained "stagnant," along with any changes in category.
Visual Cues: Each air quality update is accompanied by a corresponding image (.png files assumed to be in a ./labels/ directory), visually representing the current category.
APIs Used
AirVisual API: The primary API used for fetching real-time air quality data (AQIUS, MAINUS) for specific cities.
Telegram Bot API: Utilized through the pyTelegramBotAPI library to send messages and photos to a Telegram chat.
Workflow
The bot.py script runs continuously, operating on a time-based loop:
It checks the current time (hour, minute, second).
At predefined intervals (e.g., 6:00 AM, 9:00 PM, and varying intervals throughout the day based on AQI levels), it calls the AirVisual API to get the latest air quality data for Phnom Penh.
It then determines the AQI category (e.g., "good", "moderate").
It compares the current AQI to the previously recorded AQI to identify any changes or trends.
A comprehensive message is constructed, including the current AQI, its category, advice, and the detected change, presented in all four supported languages.
The bot selects an appropriate image corresponding to the AQI category.
Finally, it sends the image followed by the multilingual text message to the configured Telegram chat.
The bot also manages a keys.json file to persist the aqius_prior value between runs, ensuring accurate change detection.
While an openweather.py file exists in the repository for fetching OpenWeatherMap API data and calculating AQI based on pollutant concentrations, this functionality is not integrated into the main bot.py and thus not part of the current Telegram bot's operational workflow.