Skip to content

Commit

Permalink
Item1803: first pass at irc->twitter gateway
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/WikiBot@4461 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
WillNorris authored and WillNorris committed Jul 7, 2009
1 parent 83def7a commit 92e2720
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions BotModules/Twitter.bm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
# see http://mxr.mozilla.org/mozilla/source/webtools/mozbot/BotModules/devel.txt

package BotModules::Twitter;
use Net::Twitter::Lite;
use base qw( BotModules );
1;


sub Help {
my $self = shift;
my ($event) = @_;

return {
'' => 'IRC to Twitter gateway',
'twitter' => 'Send command to twitter (only update command currently)',
};
}


sub RegisterConfig {
my $self = shift;
$self->SUPER::RegisterConfig(@_);
$self->registerVariables(
['username', 1, 1, 'Foswiki'],
['password', 1, 1, undef],
['clientname', 1, 1, '#foswiki'],
);
}


sub Told {
my $self = shift;
my ($event, $message) = @_;
if ($message =~ /^\s*twitter\s+update\s+(.*)$/osi) {
my $tweet;
$tweet .= '(' . $event->{from} . ') ' if $event->{from};
$tweet .= $1;

my $twitter = Net::Twitter->new(
username => $self->{username},
password => $self->{password},
clientname => $self->{clientname},
);

$twitter->update( $tweet );
$self->say( $event, 'twitted' );
} else {
return $self->SUPER::Told(@_);
}
return 0;
}

0 comments on commit 92e2720

Please sign in to comment.