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

NAME

App::Wubot::Reactor::User - try to identify user from the 'username' field

VERSION

version 0.3.6

SYNOPSIS

      - name: user
        plugin: User

DESCRIPTION

The user reactor will parse the username field.

The original user id will always be preserved in the username_orig field. If the username_orig field already exists, it will not be overwritten.

If the username field contains an email address (e.g. the from on an mbox monitor message), then the domain will be captured into the username_domain field. If the email contains a full name it will be captured into username_full. Any leading or trailing quotes or spaces will be removed from the full username field.

Commonly usernames in IRC may contain some comment such as username|idle or username{idle}. Any such comments will be extracted into the username_comment field.

Any remaining text will be left in the username field.

After this plugin has reacted on the message, you may want to send it through the Icon reactor to determine if there is an appropriate icon for the user in your images directory. For more information, please see the 'notifications' document.

USER DATABASE

The user database is still under construction.

You can define information about your contacts in:

  ~/wubot/userdb/{username}.yaml

Here is an example:

  ~/wubot/userdb/dude.yaml

  ---
  color: green
  aliases:
    - lebowski
    - El Duderino
  image: dude.png

If you define a 'color' or an 'image', then any messages that match the username will have those values set in the message. This will override any pre-existing 'color' or 'image' fields.

You can define any aliases for your user in the 'aliases' section of the config. This allows you to recognize the same user in case they have different usernames for email, twitter, etc. The 'username' field will be updated to use the username from the file name. If the username is modified, the original username will be stored in the 'username_orig' field.

Using the example above, if a message had the username set to 'lebowski', then the following fields would be set on the message:

  username: dude
  username_orig: lebowski
  color: green
  image: dude.png

Each time a message comes through that has a username for which some user data is defined, the user's file will be scanned to see if it has been updated. If so, the userdb file will be re-read.

RULES

You can now include a custom set of rules to run any time a message is received from a user by creating a rules tree in the user config file.

  aliases:
    - lebowski

  rules:

    - name: set foo field on messages from the dude
      plugin: SetField
      config:
        field: foo
        value: bar

The rules will run after an other userdb config has been processed. This means that you could use it to things like set a custom color or image based on other fields in the message. For example, you might set different colors for the user in different feeds, or based on the user alias being used.

LIMITATIONS

The file name must be completely lower case, and all usernames and aliases will automatically be converted to lower case. This should be fixed in the future.

Adding an alias to a contact will not yet be automatically re-read if a message is received from that alias. In that case it will be necessary to restart the reactor to pick up the new alias. This is because it does not know which file to read when it receives a message from the new alias. In the future there should be some mechanism to scan the directory occasionally to look for changed files that could contain new aliases.

SUBROUTINES/METHODS

react( $message, $config )

The standard reactor plugin react() method.

get_user_info( $username )

Given a username or alias, look up the information about the user in the userdb.