Skip to content

ceshine/aqi-bot

Repository files navigation

aqi-bot

Build Status

A minimal Telegram AQI notification bot

The latest version uses Cloud Firestore as the persistent storage backend. The original in-memory version can be found in the in-memory branch.

Set Up

You need to provide two environment variables:

  1. AQI_TOKEN
  2. BOT_TOKEN

And save your service account JSON keyfile from Google Cloud as keyfile.json in the root folder.

AQI token

Get your token from aqi.cn.

Bot token

Get your token from @BotFather

Cloud Firestore

This bot uses collection named subscriptions, and use the chat_id as key.

The free tier should be more than enough to cover the read/write from this bot. However, currently we haven't implemented anti-abuse mechanisms. Be extra careful if you've enabled billing for your project.

Docker

We provide a simple Dockerfile and sample docker-compose.yml for you to get started.

Public Demo Bot

@aqi_monitor_bot

Please do not abuse this service (excessive /set, /unset, or /get commands).

Usage

1. Find the nearest station

/find <lat> <lng>

find.png

2. Subscribe

Use the station id from /find. /set <station_id>

set

3. Unsubsribe

/unset

unset

Missing Features

1. Adaptive notification

Adjust behaviors according to the pollution level.

2. More robust schedule

Sometimes the update from an station can be delayed for more than 20 minutes(the maximum allowed delay in the current setting). Need a retry mechanism.

About

A minimal Telegram AQI notification bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published