-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item1803: first pass at irc->twitter gateway
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |