URI: 
       Add support for random timezone webcam. - annna - Annna the nice friendly bot.
  HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
       ---
   DIR commit 91a6d460bd418ce4e0a1d776abb73d53e26f44af
   DIR parent a00f155cd9c433ac3ca23db20e58a8acce39f7d1
  HTML Author: Annna Robert-Houdin <annna@bitreich.org>
       Date:   Tue, 13 Jan 2026 20:32:35 +0100
       
       Add support for random timezone webcam.
       
       Diffstat:
         M annna-message-common                |      10 +++++++++-
         A tz-webcam                           |      61 +++++++++++++++++++++++++++++++
         M weather                             |      12 +++++++-----
       
       3 files changed, 77 insertions(+), 6 deletions(-)
       ---
   DIR diff --git a/annna-message-common b/annna-message-common
       @@ -725,8 +725,16 @@ case "${IRC_PRIVMSG_TEXT}" in
                        weatherplace="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
                                | sed 's,.*weather .. \(.*\),\1,' \
                                | tr -d '?')"
       -                if weathertext="$(weather "${weatherplace}")"
       +                if weathertext="$(weather "${weatherplace}")";
                        then
       +                        tzstr="$(printf "%s\n" "${weathertext}" \
       +                                | cut -d':' -f 3 \
       +                                | cut -c 3- \
       +                                | sed 's,\(.[0-9][0-9]\)\([0-9][0-9]\),\1:\2,')"
       +                        if tzwebcam="$(tz-webcam -- "${tzstr}")";
       +                        then
       +                                weathertext="${weathertext} tzwebcam: ${tzwebcam}"
       +                        fi
                                annna-say "${IRC_CMD_USER}, the weather at ${weatherplace} is ${weathertext}"
                        else
                                annna-say "${IRC_CMD_USER}, there is no weather at ${weatherplace}."
   DIR diff --git a/tz-webcam b/tz-webcam
       @@ -0,0 +1,61 @@
       +#!/usr/bin/env python
       +# coding=utf-8
       +#
       +
       +import io
       +import os
       +import sys
       +import getopt
       +import requests
       +import random
       +from lxml import etree
       +
       +def usage(app):
       +    app = os.path.basename(app)
       +    print("usage: %s [-h] [--] [-]XX:XX" % (app), file=sys.stderr)
       +    sys.exit(1)
       +
       +def main(args):
       +    try:
       +        opts, largs = getopt.getopt(args[1:], "h")
       +    except getopt.GetoptError as err:
       +        print(str(err))
       +        usage(args[0])
       +
       +    for o, a in opts:
       +        if o == "-h":
       +            usage(args[0])
       +        else:
       +            assert False, "unhandled option"
       +
       +    tzstr = largs[0]
       +    if tzstr == "+00:00" or tzstr == "-00:00":
       +        tzstr = "-"
       +
       +    headers = {
       +        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
       +    }
       +
       +    try:
       +        page = requests.get("http://www.insecam.org/en/bytimezone/%s/" % (tzstr),\
       +                headers=headers)
       +        xml = etree.parse(io.StringIO(page.text), etree.HTMLParser())
       +        pages = int(xml.xpath("//nav[@class=\"navigation\"]/ul/script")[0].text.strip().split(",")[1].strip())
       +        randpage = random.randint(1, pages)
       +        if randpage != 1:
       +            page = requests.get("http://www.insecam.org/en/bytimezone/%s/?page=%d" % (tzstr, randpage),\
       +                    headers=headers)
       +            xml = etree.parse(io.StringIO(page.text), etree.HTMLParser())
       +        imgitem = random.choice(xml.xpath("//img"))
       +        uri = imgitem.attrib["src"]
       +        if not uri.startswith("http"):
       +            imgitem = random.choice(xml.xpath("//img"))
       +            uri = imgitem.attrib["src"]
       +        print("%s" % (uri))
       +        return 0
       +    except:
       +        return 1
       +
       +if __name__ == "__main__":
       +    sys.exit(main(sys.argv))
       +
   DIR diff --git a/weather b/weather
       @@ -1,9 +1,11 @@
        #!/bin/sh
        
       -[ -z "$1" ] && {
       -    printf 'usage: %s <location>\n' "${0##*/}" >&2
       -    exit 1
       -}
       +if [ $# -lt 1 ];
       +then
       +        printf 'usage: %s <location>\n' "${0##*/}" >&2
       +        exit 1
       +fi
        
       -location=$(printf %s "$1" | sed 's, ,\%20,g')
       +location=$(printf "%s" "$1" | sed 's, ,\%20,g')
        curl -sfm 10 --globoff "https://wttr.in/$location?format=%C+%t+%h+%w+%T\n"
       +