Changeset d1bb4f3


Ignore:
Timestamp:
Mar 12, 2008, 9:20:00 PM (13 years ago)
Author:
nelhage@mit.edu <nelhage@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
1c24c69
Parents:
30f0680
Message:
Wildcard support
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/BarnOwl/Module/Twitter.pm

    r30f0680 rd1bb4f3  
    3535# Which was fixed in svn r819
    3636if((BarnOwl::getvar('twitter:class')||'') eq '') {
     37    my $desc = <<'END_DESC';
     38BarnOwl::Module::Twitter will watch for authentic zephyrs to
     39-c $twitter:class -i $twitter:instance -O $twitter:opcode
     40from your sender and mirror them to Twitter.
     41
     42A value of '*' in any of these fields acts a wildcard, accepting
     43messages with any value of that field.
     44END_DESC
    3745    BarnOwl::new_variable_string('twitter:class',
    3846                               {
    3947                                   default => $class,
    40                                    summary => 'Class to watch for Twitter messages'
     48                                   summary => 'Class to watch for Twitter messages',
     49                                   description => $desc
    4150                                  });
    4251    BarnOwl::new_variable_string('twitter:instance',
    4352                               {
    4453                                   default => $instance,
    45                                    summary => 'Instance on twitter:class to watch for Twitter messages'
     54                                   summary => 'Instance on twitter:class to watch for Twitter messages.',
     55                                   description => $desc
    4656                                  });
    4757    BarnOwl::new_variable_string('twitter:opcode',
    4858                               {
    4959                                   default => $opcode,
    50                                    summary => 'Opcode for zephyrs that will be sent as twitter updates'
     60                                   summary => 'Opcode for zephyrs that will be sent as twitter updates',
     61                                   description => $desc
    5162                                  });
    5263}
     
    7182}
    7283
     84sub match {
     85    my $val = shift;
     86    my $pat = shift;
     87    return $pat eq "*" || ($val eq $pat);
     88}
     89
    7390sub handle_message {
    7491    my $m = shift;
    7592    ($class, $instance, $opcode) = map{BarnOwl::getvar("twitter:$_")} qw(class instance opcode);
    7693    if($m->sender eq $user
    77        && $m->class eq $class
    78        && $m->instance eq $instance
    79        && $m->opcode eq $opcode
     94       && match($m->class, $class)
     95       && match($m->instance, $instance)
     96       && match($m->opcode, $opcode)
    8097       && $m->auth eq 'YES') {
    8198        twitter($m->body);
Note: See TracChangeset for help on using the changeset viewer.