Skip to content

Commit

Permalink
Item1803: changed command to 'tweet'; only read account info from con…
Browse files Browse the repository at this point in the history
…fig file

git-svn-id: http://svn.foswiki.org/trunk/WikiBot@4472 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
WillNorris authored and WillNorris committed Jul 8, 2009
1 parent 92e2720 commit 8c57bd1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions BotModules/Twitter.bm
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
# see http://mxr.mozilla.org/mozilla/source/webtools/mozbot/BotModules/devel.txt

use lib qw( /root/lib/CPAN/lib /root/lib/CPAN/lib/arch );

package BotModules::Twitter;
use Net::Twitter::Lite;
use base qw( BotModules );
Expand All @@ -12,8 +14,8 @@ sub Help {
my ($event) = @_;

return {
'' => 'IRC to Twitter gateway',
'twitter' => 'Send command to twitter (only update command currently)',
'' => 'The Twitter module provides an IRC to Twitter gateway.',
'tweet' => 'Post a tweet to twitter',
};
}

Expand All @@ -22,7 +24,7 @@ sub RegisterConfig {
my $self = shift;
$self->SUPER::RegisterConfig(@_);
$self->registerVariables(
['username', 1, 1, 'Foswiki'],
['username', 1, 1, undef],
['password', 1, 1, undef],
['clientname', 1, 1, '#foswiki'],
);
Expand All @@ -32,19 +34,20 @@ sub RegisterConfig {
sub Told {
my $self = shift;
my ($event, $message) = @_;
if ($message =~ /^\s*twitter\s+update\s+(.*)$/osi) {
my $tweet;
if ($message =~ /^\s*tweet\s+(.*)$/osi) {
my $tweet = '';
$tweet .= '(' . $event->{from} . ') ' if $event->{from};
$tweet .= $1;

my $twitter = Net::Twitter->new(
my $twitter = Net::Twitter::Lite->new(
username => $self->{username},
password => $self->{password},
clientname => $self->{clientname},
clientname => '#foswiki',
clienturl => 'http://foswiki.org/Development/FoswikiBot',
);

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

0 comments on commit 8c57bd1

Please sign in to comment.