diff --git a/II/Config.pm b/II/Config.pm index e2033e3..fcf5b31 100644 --- a/II/Config.pm +++ b/II/Config.pm @@ -1,6 +1,9 @@ package II::Config; use Config::Tiny; +use LWP::UserAgent; +use HTTP::Request; +use Data::Dumper; sub new { my $class = shift; @@ -18,13 +21,17 @@ sub load { my $tiny = Config::Tiny->new(); $config = $tiny->read($file); - + my $key = $config->{auth}->{key}; my $nick = $config->{auth}->{nick}; my $host = $config->{node}->{host}; my @echoareas = split /,/, $config->{node}->{echoareas}; my $name = $config->{node}->{name}; + if ( $config->{node}->{list} eq 'yes' ) { + @echoareas = echo_from_list($host); + } + $c = { nick => $nick, key => $key, @@ -38,4 +45,28 @@ sub load { return $c; } +# Make echoareas list from list.txt +sub echo_from_list { + my ($host) = @_; + + my $list = $host . 'list.txt'; + my @echoes; + + my $ua = LWP::UserAgent->new(); + $ua->agent("Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0)"); + + my $req = HTTP::Request->new( GET => $list ); + my $res = $ua->request($req); + + if ( $res->is_success ) { + my @e = split /\n/, $res->content(); + while (<@e>) { + my @description = split /:/, $_; + push @echoes, $description[0]; + } + } + + return @echoes; +} + 1; diff --git a/config.ini b/config.ini index b4d64d5..2fb21f8 100644 --- a/config.ini +++ b/config.ini @@ -4,8 +4,9 @@ nick = [node] host = http://ii-net.tk/ii/ii-point.php?q=/ +list = yes ;host = http://spline.rooker.ru/i/ii-point.php?q=/ -echoareas = ii.14,pipe.2032,lit.14,linux.14,lor-opennet.15,ru.humor.14,music.14,bone.14,lenta.dark.14,mlp.15,habra.16,ifiction.15,game.rogue.14,vk-news.14,lenta.rss.15.4,piratemedia.rss.15,younglinux.info.14,iing.15,python.15 +echoareas = ii.14,pipe.2032,lit.14,linux.14,lor-opennet.15,ru.humor.14,music.14,bone.14,lenta.dark.14,mlp.15,habra.16,ifiction.15,game.rogue.14,vk-news.14,lenta.rss.15.4,piratemedia.rss.15,younglinux.info.14,iing.15,python.15,develop.16 ;echoareas = python.15 [elastic]