There is a network of lightning sensors which detect lightning strikes. You can see this information, for example, on various weather-radar apps. The network feeds back to the automated weather station and allows the AWOS/ASOS to display lightning information.
From the AIM 7–1–10d:
2. Every ASOS/AWOS will contain the following basic set of sensors:
(i) Automated Lightning Detection and Reporting System (ALDARS) (excluding Alaska and Pacific Island sites).
High-level information on ALDARS can be found, for example, in this brochure from the FAA William J. Hughes Technical Center and this column from Flying Magazine.
As for how the detectors themselves actually work: some may indeed use optical sensors, but most use antennas to detect the burst of radio frequency energy caused by lightning. NOAA's National Severe Storms Laboratory and SciJinks websites contain more information on detection systems; the Wikipedia article on lightning detection would be another starting point for more research.