Skip to content

Commit

Permalink
Parse m/identica respond/ to reply a dent on identi.ca
Browse files Browse the repository at this point in the history
  • Loading branch information
jotamjr committed Nov 20, 2010
1 parent 949a598 commit e8f7c21
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions bot.pl
Expand Up @@ -446,8 +446,15 @@ sub on_public {
$about =~ s/^$target\ +//;
&sayto($target, $about);
}
elsif ($msg =~ m/^identica say (.+)/) {
chomp($1);
elsif ($msg =~ m/^identica\s+say\s+(.+)|^identica\s+respond\s+(\d+)\s+(.+)/) {
my $msg_to_say;
if (defined $3) {
chomp($3);
$msg_to_say = $3;
} else {
chomp ($1) if defined;
$msg_to_say = $1;
}

my $check = undef;
my $checkNick = undef;
Expand Down Expand Up @@ -475,7 +482,10 @@ sub on_public {
if( ($check) && ($checkNick) )
{
if ($identica) {
my $text = &identica_say($1,$nick);
my $text;
if (defined $2) {
$text = &identica_say($2, $msg_to_say, $nick);
} else { $text = &identica_say(undef, $1,$nick); }
&say("les comento que *$nick* dijo en identi.ca: $text", $nick, $usenick, 'no') if $text;
} else {
&say("el plugin de identi.ca no esta configurado :\\", $nick, $usenick, $priv);
Expand Down Expand Up @@ -1580,7 +1590,7 @@ sub getpipianlvl {
=cut

sub identica_say {
my ($message,$nick) = @_;
my ($conversation_no, $message,$nick) = @_;

if(defined($bconf{$bishowNick}) && ($bconf{$bishowNick} eq 'true'))
{
Expand All @@ -1590,22 +1600,14 @@ sub identica_say {
my $size = length($message);
if ($size <= 140){
$message = decode("utf-8", $message);
return $message if $identica->update("$message");
if (defined $conversation_no) {
return $message if $identica->update({ status => $message, in_reply_to_status_id => $conversation_no });
} else { return $message if $identica->update("$message"); }
}else{
return undef;
}
}

sub identica_respond {
my ($conversation_no, $message) = @_;
my $size = lenght($message);
if ($size <= 140){
$message = decode("utf-8", $message);
return $message if $identica->update({ status => $message, in_reply_to_status_id => $conversation_no });
}else{
return undef;
}
}
sub identica_pull {
my $nick = shift @_;
if ($nick) {
Expand Down

0 comments on commit e8f7c21

Please sign in to comment.