secret
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
sub getDataC{
my @ret =();
my @remSubs = @ponySubs;
my $json='';
my @cSubs;
while(@cSubs = splice(@remSubs,0,49)){
my $urll = 'http://www.reddit.com/r/'.join('+',@cSubs).'/comments.json?limit=20';
$json = $ua->get($urll."&r=".int(rand(1000))) or return @ret;
$json = $json->content;
eval{$json = decode_json($json); @ret = (@ret,@{$json->{'data'}{'children'}});} or do{print "JSON parse failed.\n";};
}
return reverse(@ret);
}
 
 
my @s = getDataC() or return(print "failed getDataC()\n");
foreach my $s(@s){
my $s = $s->{data};
my ($comment,$subreddit,$author,$id,$lid) = @{$s}{'body','subreddit','author','id','link_id'};
$lid =~ s/t3_//;
chomp $comment;
$author =~ s/nallar/nal‍lar/;
my $msg = "\x0304\x02$subreddit\x03\x02: $comment - \x0312by \x02$author\x02 \x0311 at http://reddit.com/comments/$lid/_/$id";
$msg =~ s/\r\n/\n/g;
$msg =~ s/\n+/\n/g;
$msg = decode_entities($msg);
my @msg = split /(?:\n)/, $msg;
my $isAlert = 0;
my $tMsg = decode_entities($comment);
if($author ne "nal‍lar"){
foreach my $alStr(@remAlerts){
$tMsg =~ s/$alStr//;
}
foreach my $alStr(@alerts){
if($tMsg =~ /$alStr/i){
$isAlert=1;
last;
}
}
}
my $lCount = 0;
if((!exists($cdone{$id}))){
if(!$init){
#print "$msg\n";
foreach my $msgPart(@msg){
sendPriv(CCHANNEL, $msgPart);
if($isAlert){
sendPriv('nallar', $msgPart);
}
if($lCount > 1){
$cdone{$id."_".$lCount}=time();
}
$lCount++;
}
}
}
$cdone{$id}=time();
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.