The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::Wubot::Plugin::WebMatches - monitor a web page for items matching a regexp

VERSION

version 0.3.2

SYNOPSIS

  ~/wubot/config/plugins/WebMatches/openssl.yaml

  ---
  delay: 1d
  url: http://www.openssl.org/sourcex/
  regexp: '\"(openssl\-[\d\.]+[a-z]?\.tar\.gz)\"'

DESCRIPTION

This plugin allows you define a regexp will capture match one or more items on a web page. Each time a new item shows up on the page that matches your regexp, a message will get sent with the matching item.

The message will contain a field called 'match' which will contain the matched text, and 'link' which will point to the source URL.

In the event of a failure retrieving content from the specified URL, a message will be sent containing a subject field such as:

  subject: Request failure: {$error}

HINTS

If you simply want to capture a single occurrence of a regexp from a page at regular intervals, you may want to use the App::Wubot::Plugin::WebFetch plugin instead. This plugin will cache previously seen values and will only send a message when a new item shows up in the list of matches.

EXAMPLE

I like to use this plugin to monitor for new releases of software when there is no RSS feed or other mechanism to notify you of a new release. For example, here is the complete monitor config I use for monitoring for new OpenSSL releases:

  ---
  delay: 1d
  url: http://www.openssl.org/sourcex/
  regexp: '\"(openssl\-[\d\.]+[a-z]?\.tar\.gz)\"'

  react:

    - name: matched
      condition: match is true
      rules:

        - name: field
          plugin: SetField
          config:
          field: sticky
          value: 1

        - name: subject
          plugin: Template
          config:
            template: 'New openssl release: {$match}'
            target_field: subject

CACHE

This monitor uses the global cache mechanism, so each time the check runs, it will update a file such as:

  ~/wubot/cache/WebMatches-myfeed.yaml

The monitor caches all matches in the feed in this file. When a new (previously unseen) match shows up on the feed, the message will be sent, and the cache will be updated. Removing the cache file will cause all matching items to be sent again.

SEE ALSO

This plugin uses App::Wubot::Util::WebFetcher.

SUBROUTINES/METHODS

check( $inputs )

The standard monitor check() method.