Government Security
Network Security Resources

Jump to content

Photo

[Perl] Irc Rss Feed Bot


  • Please log in to reply
3 replies to this topic

#1 Emery

Emery

    Private

  • Members
  • 16 posts

Posted 18 January 2010 - 04:08 PM


Ok this is part of a bot i'm working and have decided
to release this part as an RSS Bot for the GSO community.
You can add your triggers down on the commands section
and your feeds at the bottom, should be pretty easy to figure out.
Also the RSS feed does tend to spam a little as i've not finished it
so if you don't like spam it might require some fine tuning
If you decide to use this code give credit where it's due Posted Image

Enjoy.


#!/usr/bin/perl
#__   ___    	_____ _ 	_ 
#\ \ / (_)  	/  ___| |   (_)
# \ V / _ ______\ `--.| |__  _ 
# /   \| |______|`--. \ '_ \| |
#/ /^\ \ |  	/\__/ / | | | |
#\/   \/_|  	\____/|_| |_|_|BOT[RSS Version] Created By Emery
[/font]


[font="Lucida Console"]use IO::Socket::INET ;
use LWP::UserAgent;
use LWP::Simple;
use XML::Simple;[/font]

[font="Lucida Console"]##Bot Configuration
my $server = "irc.server.com";
my $port = "6667";
my $nick ="RSS";
my $name = "rss user bawt perl";
my $channel = "#rss";[/font]


[font="Lucida Console"]system('cls');
print "\n [+] Connection To $server ....\n";[/font]


[font="Lucida Console"]##Server Connection
$connection = IO::Socket::INET->new(PeerAddr=>"$server",
PeerPort=>"$port",
Proto=>'tcp',
Timeout=>'30') or print " [!] Couldnt Connect To $server\n";
print " [+] Connected  To $server ....\n\n";[/font]


[font="Lucida Console"]##Authentication
print $connection "USER $name\n";
print $connection "NICK $nick\r\n";[/font]

[font="Lucida Console"]##Commands
while($response = <$connection>)
{ 
##IRC Screen
print $response;
   
##Join Channel
if($response =~ m/<img src='http://www.governmentsecurity.org/forum/public/style_emoticons/<#EMO_DIR#>/sad.gif' class='bbc_emoticon' alt=':(' />.*) 00(.*) (.*) :/) 
{
print $connection "JOIN $channel\r\n";
}
   
	##Bot commands
  if($response =~ m/:!Feeds/) 
  {
  print $connection "PRIVMSG $channel : ----------------== RSS Feeds ==---------------\r\n";
 		print $connection "PRIVMSG $channel : BBC RSS Feed     		=> :   !bbc-tech  \r\n";
  print $connection "PRIVMSG $channel : Some RSS Feed         	  	=> :   !rss   	\r\n";
  }
 		
  

    	#-------------------- RSS FEEDS ------------------
    	
    	##BBC Tech News
if ($response =~m/:!bbc-tech/)
{ 
  my $rss = get('http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/technology/rss.xml');
	my $xml = XMLin($rss);
	my $spl = scalar(@{$xml->{channel}->{item}}); 
	for ($i=0; $i<$spl; $i++)
	{
   print $connection "PRIVMSG $channel :\n";
  	print $connection "PRIVMSG $channel :Date : $xml->{channel}->{item}->[$i]->{pubDate}\n";
  	print $connection "PRIVMSG $channel :Title: $xml->{channel}->{item}->[$i]->{title}\n";
  	print $connection "PRIVMSG $channel :Link : $xml->{channel}->{item}->[$i]->{link}\n\n";
	}; 
}
    	
[/font]


[font="Lucida Console"]


#2 Guest_DiabloHorn_*

Guest_DiabloHorn_*
  • Guests

Posted 18 January 2010 - 04:18 PM

nice that's very little code :) nifty programming.

#3 Emery

Emery

    Private

  • Members
  • 16 posts

Posted 18 January 2010 - 04:43 PM

Well it doesn't do alot really apart from relay RSS feeds into an IRC channel :)
but thanks :)

#4 Guest_DiabloHorn_*

Guest_DiabloHorn_*
  • Guests

Posted 19 January 2010 - 12:56 AM

still nicely coded I expected a lot more code for some odd reason:\ prolly just me not paying attention.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users