From 1f55745f726ca54b8f403ef121fa0a32442b1274 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 16 Mar 2014 17:31:05 +0100 Subject: new_feeds up2date --- news/new_feeds | 260 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 168 insertions(+), 92 deletions(-) (limited to 'news') diff --git a/news/new_feeds b/news/new_feeds index 97f2f762..f6025f7e 100644 --- a/news/new_feeds +++ b/news/new_feeds @@ -1,110 +1,186 @@ -faz_feui|http://www.faz.net/rss/aktuell/feuilleton/|#news +aje|http://www.aljazeera.com/Services/Rss/?PostingId=2007731105943979989|#news +aktuelle_themen|http://bundestag.de/service/rss/Bundestag_Aktuelle_Themen.rss|#news #bundestag +allafrica|http://allafrica.com/tools/headlines/rdf/latest/headlines.rdf|#news +anon|http://anoninsiders.net/feed/|#news +antirez|http://antirez.com/rss|#news +arbor|http://feeds2.feedburner.com/asert/|#news +archlinux|http://www.archlinux.org/feeds/news/|#news +ars|http://feeds.arstechnica.com/arstechnica/index?format=xml|#news +asiaone_asia|http://news.asiaone.com/rss/asia|#news +asiaone_business|http://business.asiaone.com/rss.xml|#news +asiaone_sci|http://news.asiaone.com/rss/science-and-tech|#news +asiaone_world|http://news.asiaone.com/rss/world|#news +augustl|http://augustl.com/atom.xml|#news +bbc|http://feeds.bbci.co.uk/news/rss.xml|#news +bdt_drucksachen|http://www.bundestag.de/dip21rss/bundestag_drucksachen.rss|#news #bundestag +bdt_plenarproto|http://www.bundestag.de/rss_feeds/plenarprotokolle.rss|#news #bundestag +bdt_pressemitteilungen|http://bundestag.de/service/rss/Bundestag_Presse.rss|#news #bundestag +bdt_wd|http://bundestag.de/service/rss/Bundestag_WD.rss|#news #bundestag +bitcoinboard|http://bitcoinboard.net/feed/|#news #financial +bitcoinpakistan|https://bitcoinspakistan.com/feed/|#news #financial +bmj|http://www.bmj.com/rss|#news +businessweek|http://www.businessweek.com/feeds/homepage.rss|#news +cancer|http://feeds.feedburner.com/ncinewsreleases?format=xml|#news +carta|http://feeds2.feedburner.com/carta-standard-rss|#news catholic_news|http://feeds.feedburner.com/catholicnewsagency/dailynews|#news -lisp|http://planet.lisp.org/rss20.xml|#news -sciencemag|http://news.sciencemag.org/rss/current.xml|#news -weechat|http://dev.weechat.org/feed/atom|#news -nnewsg|http://www.net-news-global.net/rss/rssfeed.xml|#news +cbc_busi|http://rss.cbc.ca/lineup/business.xml|#news +cbc_offbeat|http://www.cbc.ca/cmlink/rss-offbeat|#news +cbc_pol|http://rss.cbc.ca/lineup/politics.xml|#news +cbc_tech|http://rss.cbc.ca/lineup/technology.xml|#news +cbc_top|http://rss.cbc.ca/lineup/topstories.xml|#news ccc|http://www.ccc.de/rss/updates.rdf|#news +chan_b|http://boards.4chan.org/b/index.rss|#brainfuck +chan_biz|http://boards.4chan.org/biz/index.rss|#news #brainfuck +chan_g|http://boards.4chan.org/g/index.rss|#news #brainfuck +chan_int|http://boards.4chan.org/int/index.rss|#news #brainfuck +cna|http://www.channelnewsasia.com/starterkit/servlet/cna/rss/home.xml|#news +cryptanalysis|https://cryptanalys.is/rss.php|#news +coindesk|http://feeds.feedburner.com/CoinDesk?format=xml|#news #financial +coinspotting|http://coinspotting.com/rss|#news #financial +cryptoarticles|http://www.cryptoarticles.com/crypto-news?format=rss|#news +cryptocoinsnews|http://www.cryptocoinsnews.com/feed/|#news #financial +cryptogon|http://www.cryptogon.com/?feed=rss2|#news +csm|http://rss.csmonitor.com/feeds/csm|#news +csm_world|http://rss.csmonitor.com/feeds/world|#news +cyberguerrilla|https://www.cyberguerrilla.org/a/2012/?feed=rss2|#news danisch|http://www.danisch.de/blog/feed/|#news -tinc|http://tinc-vpn.org/news/index.rss|#news -ft_india|http://www.ft.com/rss/home/india|#news -nasa_news|http://www.nasa-usa.de/rss/dyn/breaking_news.rss|#news -GerForPol|http://www.german-foreign-policy.com/de/news/rss-2.0|#news -un_me|http://www.un.org/apps/news/rss/rss_mideast.asp|#news -shz_news|http://www.shz.de/nachrichten/newsticker/rss|#news -wp_world|http://feeds.washingtonpost.com/rss/rss_blogpost|#news -fbi_nat_press|http://www.fbi.gov/news/rss|#news +dod|http://www.defense.gov/news/rss/|#news dwn|http://deutsche-wirtschafts-nachrichten.de/feed/customfeed/|#news -faz_politik|http://www.faz.net/rss/aktuell/politik/|#news -spiegel_top|http://www.spiegel.de/schlagzeilen/tops/index.rss|#news -presseportal|http://www.presseportal.de/rss/presseportal.rss2|#news -telegraph_uk|http://www.telegraph.co.uk/news/uknews/rss|#news -LtU|http://lambda-the-ultimate.org/rss.xml|#news -vimperator|https://sites.google.com/a/vimperator.org/www/blog/posts.xml|#news -schallurauch|http://feeds.feedburner.com/SchallUndRauch|#news -add|kernel|#news -anon|http://anoninsiders.net/feed/|#news -4chan_status|http://status.4chan.org/feeds/posts/default?alt=rss| -nytimes|http://rss.nytimes.com/services/xml/rss/nyt/World.xml|#news -bbc|http://feeds.bbci.co.uk/news/rss.xml|#news -bild|http://rss.bild.de/bild.xml|#news -reddit_world|http://www.reddit.com/r/worldnews/.rss|#news -fbi|http://www.fbi.gov/homepage/RSS|#news -reddit_sci|http://www.reddit.com/r/science/.rss|#news -geheimorganisation|http://geheimorganisation.org/feed/|#news +ecat|http://ecat.com/feed|#news eia_press|http://www.eia.gov/rss/press_rss.xml|#news -nsa|http://www.nsa.gov/rss.shtml|#news -travel_warnings|http://feeds.travel.state.gov/ca/travelwarnings-alerts|#news -tigsource|http://www.tigsource.com/feed/|#news -un_top|http://www.un.org/apps/news/rss/rss_top.asp|#news -archlinux|http://www.archlinux.org/feeds/news/|#news -sec-db|http://feeds.security-database.com/SecurityDatabaseToolsWatch|#news -coinspotting|http://coinspotting.com/rss|#news -fefe|http://blog.fefe.de/rss.xml|#news +eia_today|http://www.eia.gov/rss/todayinenergy.xml|#news embargowatch|https://embargowatch.wordpress.com/feed/|#news -spiegel_eil|http://www.spiegel.de/schlagzeilen/eilmeldungen/index.rss|#news -aje|http://www.aljazeera.com/Services/Rss/?PostingId=2007731105943979989|#news -gulli|http://ticker.gulli.com/rss/|#news -us_math_society|http://www.ams.org/cgi-bin/content/news_items.cgi?rss=1|#news -tagesschau|http://www.tagesschau.de/newsticker.rdf|#news +ethereum-comments|http://blog.ethereum.org/comments/feed|#news +ethereum|http://blog.ethereum.org/feed|#news +europa_ric|http://ec.europa.eu/research/infocentre/rss/infocentre-rss.xml|#news +eu_survei|http://www.eurosurveillance.org/public/RSSFeed/RSS.aspx|#news +exploitdb|http://www.exploit-db.com/rss.xml|#news +fars|http://www.farsnews.com/rss.php|#news #test +faz_feui|http://www.faz.net/rss/aktuell/feuilleton/|#news +faz_politik|http://www.faz.net/rss/aktuell/politik/|#news +faz_wirtschaft|http://www.faz.net/rss/aktuell/wirtschaft/|#news #financial +fbi|http://www.fbi.gov/homepage/RSS|#news #bullerei +fbi_nat_press|http://www.fbi.gov/news/rss|#news #bullerei fbi_news|http://www.fbi.gov/news/news_blog/rss.xml|#news -bmj|http://www.bmj.com/rss|#news -ft_me|http://www.ft.com/rss/home/middleeast|#news -fbi_stories|http://www.fbi.gov/news/stories/all-stories/rss.xml|#news -sz_wirtschaft|http://rss.sueddeutsche.de/rss/Wirtschaft|#news -arbor|http://feeds2.feedburner.com/asert/|#news -reddit_tech|http://www.reddit.com/r/technology/.rss|#news +fbi_press|http://www.fbi.gov/news/current/rss.xml|#news #bullerei +fbi_stories|http://www.fbi.gov/news/stories/all-stories/rss.xml|#news #bullerei +fedreserve|http://www.federalreserve.gov/feeds/press_all.xml|#news #financial +fefe|http://blog.fefe.de/rss.xml|#news +forbes|http://www.forbes.com/forbes/feed2/|#news +forbes_realtime|http://www.forbes.com/real-time/feed2/|#news +fox|http://feeds.foxnews.com/foxnews/latest|#news +fvwm|http://freecode.com/projects/fvwm/releases.atom|#news +geheimorganisation|http://geheimorganisation.org/feed/|#news +GerForPol|http://www.german-foreign-policy.com/de/news/rss-2.0|#news +gmanet|http://www.gmanetwork.com/news/rss/news|#news golem|http://www.golem.de/rss.php?feed=RSS1.0|#news +google|http://news.google.com/?output=rss|#news +greenpeace|http://www.greenpeace.de/nachrichten/feed/rss2/|#news +guardian_uk|http://feeds.theguardian.com/theguardian/uk-news/rss|#news +gulli|http://ticker.gulli.com/rss/|#news +handelsblatt|http://www.handelsblatt.com/contentexport/feed/schlagzeilen|#news #financial heise|http://heise.de.feedsportal.com/c/35207/f/653902/index.rss|#news -fbi_press|http://www.fbi.gov/news/current/rss.xml|#news -ars|http://feeds.arstechnica.com/arstechnica/index?format=xml|#news -cancer|http://feeds.feedburner.com/ncinewsreleases?format=xml|#news -un_eu|http://www.un.org/apps/news/rss/rss_europe.asp|#news -europa_ric|http://ec.europa.eu/research/infocentre/rss/infocentre-rss.xml|#news -fedreserve|http://www.federalreserve.gov/feeds/press_all.xml|#news -exploitdb|http://www.exploit-db.com/rss.xml|#news -xkcd|https://xkcd.com/rss.xml|#news -reddit_prog|http://reddit.com/r/programming/|#news +hindu_business|http://www.thehindubusinessline.com/?service=rss|#news #financial +hindu|http://www.thehindu.com/?service=rss|#news +hintergrund|http://www.hintergrund.de/index.php?option=com_bca-rss-syndicator&feed_id=8|#news HN|http://news.ycombinator.com/rss|#news -sz_wissen|http://suche.sueddeutsche.de/rss/Wissen|#news -scmp|http://www.scmp.com/rss/91/feed|#news -shackspace|http://shackspace.de/?feed=rss2|#news -greenpeace|http://www.greenpeace.de/nachrichten/feed/rss2/|#news -rt|http://rt.com/rss/news/|#news +ign|http://feeds.ign.com/ign/all|#news +independent|http://www.independent.com/rss/headlines/|#news +indymedia|http://de.indymedia.org/RSS/newswire.xml|#news +info_libera|http://www.informationliberation.com/rss.xml|#news +klagen-gegen-rundfuckbeitrag|http://klagen-gegen-rundfunkbeitrag.blogspot.com/feeds/posts/default|#news +korea_herald|http://www.koreaherald.com/rss_xml.php|#news +linuxinsider|http://www.linuxinsider.com/perl/syndication/rssfull.pl|#news +lisp|http://planet.lisp.org/rss20.xml|#news +liveleak|http://www.liveleak.com/rss|#news +lolmythesis|http://lolmythesis.com/rss|#news +LtU|http://lambda-the-ultimate.org/rss.xml|#news +lukepalmer|http://lukepalmer.wordpress.com/feed/|#news +mit|http://web.mit.edu/newsoffice/rss-feeds.feed?type=rss|#news +mongrel2_master|https://github.com/zedshaw/mongrel2/commits/master.atom|#news nasa_iotd|http://www.nasa-usa.de/rss/dyn/lg_image_of_the_day.rss|#news -z0r|https://www.facebook.com/feeds/page.php?format=atom10&id=278857186139|#news -stz|http://www.stuttgarter-zeitung.de/rss/topthemen.rss.feed|#news +nasa_news|http://www.nasa-usa.de/rss/dyn/breaking_news.rss|#news +nds|http://www.nachdenkseiten.de/?feed=atom|#news +netzpolitik|https://netzpolitik.org/feed/|#news +newsbtc|http://newsbtc.com/feed/|#news #financial +nnewsg|http://www.net-news-global.net/rss/rssfeed.xml|#news +npr_busi|http://www.npr.org/rss/rss.php?id=1006|#news +npr_headlines|http://www.npr.org/rss/rss.php?id=1001|#news +npr_pol|http://www.npr.org/rss/rss.php?id=1012|#news +npr_world|http://www.npr.org/rss/rss.php?id=1004|#news +nsa|http://www.nsa.gov/rss.shtml|#news #bullerei +nytimes|http://rss.nytimes.com/services/xml/rss/nyt/World.xml|#news +phys|http://phys.org/rss-feed/|#news +piraten|https://www.piratenpartei.de/feed/|#news +polizei_berlin|http://www.berlin.de/polizei/presse-fahndung/_rss_presse.xml|#news #bullerei +presse_polizei|http://www.presseportal.de/rss/polizei.rss2|#news #bullerei +presseportal|http://www.presseportal.de/rss/presseportal.rss2|#news +prisonplanet|http://prisonplanet.com/feed.rss|#news +proofmarket|https://proofmarket.org/feed_problem|#news +rawstory|http://www.rawstory.com/rs/feed/|#news +reddit_4chan|http://www.reddit.com/r/4chan/new/.rss|#news #brainfuck +reddit_anticonsum|http://www.reddit.com/r/Anticonsumption/new/.rss|#news +reddit_btc|http://www.reddit.com/r/Bitcoin/new/.rss|#news #financial +reddit_consp|http://reddit.com/r/conspiracy/.rss|#news +reddit_prog|http://reddit.com/r/programming/|#news +reddit_sci|http://www.reddit.com/r/science/.rss|#news +reddit_tech|http://www.reddit.com/r/technology/.rss|#news +reddit_tpp|http://www.reddit.com/r/twitchplayspokemon/.rss|#news #tpp +reddit_world|http://www.reddit.com/r/worldnews/.rss|#news +r-ethereum|http://www.reddit.com/r/ethereum/.rss|#news reuters|http://feeds.reuters.com/Reuters/worldNews|#news -gmanet|http://www.gmanetwork.com/news/rss/news|#news -un_am|http://www.un.org/apps/news/rss/rss_americas.asp|#news +reuters-odd|http://feeds.reuters.com/reuters/oddlyEnoughNews?format=xml|#news +rt|http://rt.com/rss/news/|#news +schallurauch|http://feeds.feedburner.com/SchallUndRauch|#news +sciencemag|http://news.sciencemag.org/rss/current.xml|#news +scmp|http://www.scmp.com/rss/91/feed|#news +sec-db|http://feeds.security-database.com/SecurityDatabaseToolsWatch|#news +shackspace|http://shackspace.de/?feed=rss2|#news +shz_news|http://www.shz.de/nachrichten/newsticker/rss|#news +sky_busi|http://news.sky.com/feeds/rss/business.xml|#news +sky_pol|http://news.sky.com/feeds/rss/politics.xml|#news +sky_strange|http://news.sky.com/feeds/rss/strange.xml|#news +sky_tech|http://news.sky.com/feeds/rss/technology.xml|#news +sky_world|http://news.sky.com/feeds/rss/world.xml|#news slashdot|http://rss.slashdot.org/Slashdot/slashdot|#news -antirez|http://antirez.com/rss|#news +slate|http://feeds.slate.com/slate|#news +spiegel_eil|http://www.spiegel.de/schlagzeilen/eilmeldungen/index.rss|#news +spiegelfechter|http://feeds.feedburner.com/DerSpiegelfechter?format=xml|#news +spiegel_top|http://www.spiegel.de/schlagzeilen/tops/index.rss|#news +standardmedia_ke|http://www.standardmedia.co.ke/rss/headlines.php|#news +stern|http://www.stern.de/feed/standard/all/|#news +stz|http://www.stuttgarter-zeitung.de/rss/topthemen.rss.feed|#news +sz_politik|http://rss.sueddeutsche.de/rss/Politik|#news +sz_wirtschaft|http://rss.sueddeutsche.de/rss/Wirtschaft|#news #financial +sz_wissen|http://suche.sueddeutsche.de/rss/Wissen|#news +tagesschau|http://www.tagesschau.de/newsticker.rdf|#news +taz|http://taz.de/Themen-des-Tages/!p15;rss/|#news +telegraph_finance|http://www.telegraph.co.uk/finance/rss|#news #financial +telegraph_pol|http://www.telegraph.co.uk/news/politics/rss|#news +telegraph_uk|http://www.telegraph.co.uk/news/uknews/rss|#news telegraph_world|http://www.telegraph.co.uk/news/worldnews/rss|#news -fvwm|http://freecode.com/projects/fvwm/releases.atom|#news -eu_survei|http://www.eurosurveillance.org/public/RSSFeed/RSS.aspx|#news -eia_today|http://www.eia.gov/rss/todayinenergy.xml|#news -reddit_consp|http://reddit.com/r/conspiracy/.rss|#news -ft_uk|http://www.ft.com/rss/home/uk|#news +telepolis|http://www.heise.de/tp/rss/news-atom.xml|#news +the_insider|http://www.theinsider.org/rss/news/headlines-xml.asp|#news +tigsource|http://www.tigsource.com/feed/|#news times|http://www.thetimes.co.uk/tto/news/rss|#news -phys|http://phys.org/rss-feed/|#news -stern|http://www.stern.de/feed/standard/all/|#news -zdnet|http://www.zdnet.com/news/rss.xml|#news -presse_polizei|http://www.presseportal.de/rss/polizei.rss2|#news +tinc|http://tinc-vpn.org/news/index.rss|#news +topix_b|http://www.topix.com/rss/wire/de/berlin|#news +torr_bits|http://feeds.feedburner.com/TorrentfreakBits|#news +torrentfreak|http://feeds.feedburner.com/Torrentfreak|#news torr_news|http://feed.torrentfreak.com/Torrentfreak/|#news -faz_wirtschaft|http://www.faz.net/rss/aktuell/wirtschaft/|#news -telegraph_finance|http://www.telegraph.co.uk/finance/rss|#news -linuxinsider|http://www.linuxinsider.com/perl/syndication/rssfull.pl|#news -telegraph_pol|http://www.telegraph.co.uk/news/politics/rss|#news -lolmythesis|http://lolmythesis.com/rss|#news -taz|http://taz.de/Themen-des-Tages/!p15;rss/|#news +travel_warnings|http://feeds.travel.state.gov/ca/travelwarnings-alerts|#news +truther|http://truthernews.wordpress.com/feed/|#news un_afr|http://www.un.org/apps/news/rss/rss_africa.asp|#news -ft_us|http://www.ft.com/rss/home/us|#news -telepolis|http://www.heise.de/tp/rss/news-atom.xml|#news -ft_europe|http://www.ft.com/rss/home/europe|#news -handelblatt|http://www.handelsblatt.com/contentexport/feed/schlagzeilen|#news -rawstory|http://www.rawstory.com/rs/feed/|#news -sz_politik|http://rss.sueddeutsche.de/rss/Politik|#news +un_am|http://www.un.org/apps/news/rss/rss_americas.asp|#news +un_eu|http://www.un.org/apps/news/rss/rss_europe.asp|#news +un_me|http://www.un.org/apps/news/rss/rss_mideast.asp|#news un_pac|http://www.un.org/apps/news/rss/rss_asiapac.asp|#news -torr_bits|http://feeds.feedburner.com/TorrentfreakBits|#news -ign|http://feeds.ign.com/ign/all|#news -ft_asia|http://www.ft.com/rss/home/asia|#news +un_top|http://www.un.org/apps/news/rss/rss_top.asp|#news +us_math_society|http://www.ams.org/cgi-bin/content/news_items.cgi?rss=1|#news +vimperator|https://sites.google.com/a/vimperator.org/www/blog/posts.xml|#news +weechat|http://dev.weechat.org/feed/atom|#news +wp_world|http://feeds.washingtonpost.com/rss/rss_blogpost|#news +xkcd|https://xkcd.com/rss.xml|#news +yahoo|http://news.yahoo.com/rss/|#news +z0r|https://www.facebook.com/feeds/page.php?format=atom10&id=278857186139|#news +zdnet|http://www.zdnet.com/news/rss.xml|#news -- cgit v1.2.3 From 8745dcde4ed5a1661c058f4bfb1bf1fbc9f999a0 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 16 Mar 2014 18:51:18 +0100 Subject: news: initialize newsbot.js --- news/.gitignore | 1 + news/newsbot.js | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 news/.gitignore create mode 100644 news/newsbot.js (limited to 'news') diff --git a/news/.gitignore b/news/.gitignore new file mode 100644 index 00000000..07e6e472 --- /dev/null +++ b/news/.gitignore @@ -0,0 +1 @@ +/node_modules diff --git a/news/newsbot.js b/news/newsbot.js new file mode 100644 index 00000000..fda7f7f4 --- /dev/null +++ b/news/newsbot.js @@ -0,0 +1,151 @@ +var IRC = require('irc') +var FeedParser = require('feedparser') +var Request = require('request') + +var irc_server = 'ire.retiolum' +var master_nick = 'knews' +var news_channel = '&testing' +var feeds_file = 'new_feeds' +var feedbot_loop_delay = 60 * 1000 // [ms] + +function main () { + // XXX mangle nick to not clash with newsbot.py + var master = new IRC.Client(irc_server, master_nick + '_2', { + channels: [ news_channel ], + }) + + master.on('message' + news_channel, function (nick, text, message) { + if (is_talking_to(master_nick, text)) { + var parse = /^[^:]*:\s*(\S*\S)\s*$/.exec(text) + if (parse) { + client.say(to, nick + ': ' + parse[1] + '?') + } + }) + + master.once('registered', function () { + // read feeds file and create a feedbot for each entry + require('fs') + .readFileSync(feeds_file) + .toString() + .split('\n') + //.filter((function () { + // var n = 2; + // return function () { + // return n-- > 0 + // } + //})()) + .filter(function (line) { + return line.length > 0 + }) + .forEach(function (line) { + var parts = line.split('|') + if (parts.length !== 3) { + console.log('bad new_feeds line ' + lines + ': ' + line) + return + } + + // XXX mangle nick to not clash with newsbot.py + var nick = parts[0] + '_2' + var uri = parts[1] + var channels = parts[2].split(' ') + + // XXX mangle channel to not clash with newsbot.py + channels = channels.map(function (channel) { + return channel === '#news' ? news_channel : channel + }) + + return create_feedbot(nick, uri, channels) + }) + }) +} + +function create_feedbot (nick, uri, channels) { + var client = new IRC.Client(irc_server, nick, { + channels: channels, + }) + + // say text in every joined channel + function broadcast (text) { + Object.keys(client.chans).forEach(function (channel) { + client.say(channel, text) + }) + } + + client.once('registered', loop_feedparser) + + client.on('error', function (error) { + console.log('Error:', error) + }) + + // TODO stopping criteria + function loop_feedparser () { + try { + var request = Request(uri) + var feedparser = new FeedParser() + } catch (error) { + return broadcast('4' + error) + } + + request.on('error', function (error) { + broadcast('4request ' + error) + }) + request.on('response', function (response) { + if (response.statusCode !== 200) { + return this.emit('error', new Error('Bad status code')) + } + this.pipe(feedparser) + }) + + var items = [] + + feedparser.on('error', function (error) { + broadcast('4feedparser ' + error) + }) + feedparser.on('readable', function () { + for (var item; item = this.read(); ) { + items.push(item) + } + }) + feedparser.on('end', function () { + items = items.sort(function (a, b) { + return a.date - b.date + }) + + var indexOfLastTitle = items + .map(function (x) { return x.title }) + .indexOf(client.lastTitle) + + var newitems = items + var olditems = [] + + // if items contain lastTitle, then only items after that are news + if (!!~indexOfLastTitle) { + olditems = newitems.splice(0, indexOfLastTitle + 1) + } + + if (newitems.length > 0) { + // only broadcast news if we're not starting up + // (i.e. we already have a lastTitle) + if (client.lastTitle) { + newitems.forEach(function (item) { + broadcast(item.title + ' ' + item.link) + }) + } + + client.lastTitle = newitems[newitems.length - 1].title + } + + return setTimeout(loop_feedparser, feedbot_loop_delay) + }) + } +} + +// return true if text "is talking to" my_nick +function is_talking_to (my_nick, text) { + return text.slice(0, my_nick.length) === my_nick + && text[my_nick.length] === ':' +} + +if (require.main === module) { + main() +} -- cgit v1.2.3 From f21fd0c806da24212b04eeb009222b1ed1c1cea9 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 16 Mar 2014 20:10:00 +0100 Subject: newsbot.js: fix typo --- news/newsbot.js | 1 + 1 file changed, 1 insertion(+) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index fda7f7f4..9228e5d4 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -20,6 +20,7 @@ function main () { if (parse) { client.say(to, nick + ': ' + parse[1] + '?') } + } }) master.once('registered', function () { -- cgit v1.2.3 From e90b6909dd62e95d58f434a4352ef2163e3f62c6 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 16 Mar 2014 20:10:24 +0100 Subject: newsbos.js: i cant hear you(deaf_myself) --- news/newsbot.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 9228e5d4..62609f00 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -73,6 +73,7 @@ function create_feedbot (nick, uri, channels) { } client.once('registered', loop_feedparser) + client.once('registered', deaf_myself) client.on('error', function (error) { console.log('Error:', error) @@ -139,6 +140,9 @@ function create_feedbot (nick, uri, channels) { return setTimeout(loop_feedparser, feedbot_loop_delay) }) } + function deaf_myself () { + client.send('mode', nick, '+D') + } } // return true if text "is talking to" my_nick -- cgit v1.2.3 From 2dc26fdb5d5b0fa55a4b6ad656f373a4453a47dc Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 16 Mar 2014 20:14:17 +0100 Subject: newsbot.py: better space finding --- news/newsbot.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'news') diff --git a/news/newsbot.py b/news/newsbot.py index 8834851d..0161f818 100644 --- a/news/newsbot.py +++ b/news/newsbot.py @@ -203,14 +203,14 @@ class RssBot(asybot): def send_msg(self, target, string): if self.connected: for line in string.split('\n'): - if len(line) < 450: - self.PRIVMSG(target, line) - else: - space = 0 - for x in range(math.ceil(len(line)/400)): - oldspace = space - space = line.find(" ", (x+1)*400, (x+1)*400+50) - self.PRIVMSG(target, line[oldspace:space]) + while len(line)>0: + if len(line) < 450: + self.PRIVMSG(target, line) + line = '' + else: + space = line.rfind(" ", 1, 450) + self.PRIVMSG(target, line[:space]) + line=line[space:] else: self.reconnect() while not self.connected: -- cgit v1.2.3 From cb259188f3f7c9b5c37a5b11692b5c7c5f1e146a Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 16 Mar 2014 20:14:48 +0100 Subject: newsbot.py: debug messages before sleeping --- news/newsbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'news') diff --git a/news/newsbot.py b/news/newsbot.py index 0161f818..19ca3647 100644 --- a/news/newsbot.py +++ b/news/newsbot.py @@ -214,8 +214,8 @@ class RssBot(asybot): else: self.reconnect() while not self.connected: - sleep(10) print(self.nickname + ' waiting for reconnect') + sleep(10) self.send_msg(target, string) def on_invite(self, prefix, command, params, rest): -- cgit v1.2.3 From f39adfd9f57cff86813b4be4c503dda5055f02a1 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 16 Mar 2014 22:16:56 +0100 Subject: newsbot.py: url_shortener better abstraction --- news/newsbot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'news') diff --git a/news/newsbot.py b/news/newsbot.py index 19ca3647..4e07d622 100644 --- a/news/newsbot.py +++ b/news/newsbot.py @@ -17,7 +17,7 @@ from time import sleep ## Newsbot Controller Class class NewsBot(asybot): - def __init__(self, name, channels=['#test'], server='ire', port=6667, timeout=60, loglevel=logging.ERROR, url_shortener='http://wall'): + def __init__(self, name, channels=['#test'], server='ire', port=6667, timeout=60, loglevel=logging.ERROR, url_shortener='http://localhost'): asybot.__init__(self, server, port, name, channels, loglevel=loglevel) self.to = timeout self.url_shortener = url_shortener @@ -223,12 +223,16 @@ class RssBot(asybot): self.push('JOIN ' + chan) self.channels.append(chan) + def on_welcome(self, prefix, command, params, rest): + asybot.on_welcome(self, prefix, command, params, rest) + self.push('MODE ' + self.nickname + ' +D') + feedfile = 'new_feeds' -url_shortener = 'http://wall' +url_shortener = 'http://go' init_channels = ['#news'] bots = {} -knews = NewsBot('knews', init_channels) +knews = NewsBot('knews', init_channels, url_shortener=url_shortener) #config file reading F = open(feedfile, "r") -- cgit v1.2.3 From 10a5a94176b21e54d743be2d1a7a3898ed5916b4 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 16 Mar 2014 22:17:16 +0100 Subject: newsbot.py: dummy nickinuse fix --- news/newsbot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'news') diff --git a/news/newsbot.py b/news/newsbot.py index 4e07d622..2f8bf635 100644 --- a/news/newsbot.py +++ b/news/newsbot.py @@ -140,7 +140,9 @@ class RssBot(asybot): self.lastnew = datetime.now() self.url_shortener = url_shortener self.retry = True - self.on_nickinuse = lambda: None + + def on_nickinuse(*bla): + pass def start_rss(self): self.upd_loop = threading.Thread(target=self.updateloop) -- cgit v1.2.3 From 9f5a2061c693e032ee7ac50741e95afd8a7b53df Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 00:41:33 +0100 Subject: newsbot.js: function_parser, now live --- news/newsbot.js | 92 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 14 deletions(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 62609f00..ba3dfde3 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -1,31 +1,40 @@ var IRC = require('irc') var FeedParser = require('feedparser') var Request = require('request') +var Parse = require('shell-quote').parse +var FS = require('fs') var irc_server = 'ire.retiolum' var master_nick = 'knews' -var news_channel = '&testing' +var news_channel = '#news' var feeds_file = 'new_feeds' var feedbot_loop_delay = 60 * 1000 // [ms] +var slaves = {} + function main () { - // XXX mangle nick to not clash with newsbot.py - var master = new IRC.Client(irc_server, master_nick + '_2', { + var master = new IRC.Client(irc_server, master_nick, { channels: [ news_channel ], }) master.on('message' + news_channel, function (nick, text, message) { if (is_talking_to(master_nick, text)) { - var parse = /^[^:]*:\s*(\S*\S)\s*$/.exec(text) - if (parse) { - client.say(to, nick + ': ' + parse[1] + '?') + var request = parse_request(text) + if (request) { + return run_command(request.method, request.params, function (error, result) { + if (error) { + return master.say(news_channel, '4' + error) + } else { + return master.say(news_channel, result) + } + }) } } }) master.once('registered', function () { // read feeds file and create a feedbot for each entry - require('fs') + FS .readFileSync(feeds_file) .toString() .split('\n') @@ -45,16 +54,10 @@ function main () { return } - // XXX mangle nick to not clash with newsbot.py - var nick = parts[0] + '_2' + var nick = parts[0] var uri = parts[1] var channels = parts[2].split(' ') - // XXX mangle channel to not clash with newsbot.py - channels = channels.map(function (channel) { - return channel === '#news' ? news_channel : channel - }) - return create_feedbot(nick, uri, channels) }) }) @@ -65,6 +68,13 @@ function create_feedbot (nick, uri, channels) { channels: channels, }) + slaves[nick] = { + client: client, + nick: nick, + uri: uri, + channels: channels, + } + // say text in every joined channel function broadcast (text) { Object.keys(client.chans).forEach(function (channel) { @@ -150,6 +160,60 @@ function is_talking_to (my_nick, text) { return text.slice(0, my_nick.length) === my_nick && text[my_nick.length] === ':' } + +function parse_request (text) { + var parse = Parse(text) + return { + method: parse[1], + params: parse.slice(2), + } +} + +function run_command (methodname, params, callback) { + var method = methods[methodname] + if (method) { + return method(params, callback) + } else { + return callback(new Error('dunno what ' + methodname + ' is')); + } +} + +var methods = {} +methods.add = function (params, callback) { + create_feedbot(params[0], params[1], [news_channel]) + return callback(null) +} +methods.del = function (params, callback) { + var slave = slaves[params[0]] + if (slave) { + slave.client.disconnect() + delete slaves[params[0]] + return callback(null) + } else { + return callback(new Error('botname not found')) + } +} +methods.save = function (params, callback) { + var feeds = Object.keys(slaves) + .map(function (nick) { + return slaves[nick] + }) + .map(function (slave) { + return [ + slave.nick, + slave.uri, + slave.channels.join(' '), + ].join('|') + }).join('\n') + '\n' + return FS.writeFile(feeds_file, feeds, function (error) { + if (error) { + return callback(error) + } else { + return callback(null, 'Feeds saved') + } + }) +} + if (require.main === module) { main() -- cgit v1.2.3 From 4474143648f2b16448b49bf748e20f783b35347a Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 00:45:24 +0100 Subject: new_feeds cleanup --- news/new_feeds | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'news') diff --git a/news/new_feeds b/news/new_feeds index f6025f7e..61e6330e 100644 --- a/news/new_feeds +++ b/news/new_feeds @@ -18,7 +18,6 @@ bdt_pressemitteilungen|http://bundestag.de/service/rss/Bundestag_Presse.rss|#new bdt_wd|http://bundestag.de/service/rss/Bundestag_WD.rss|#news #bundestag bitcoinboard|http://bitcoinboard.net/feed/|#news #financial bitcoinpakistan|https://bitcoinspakistan.com/feed/|#news #financial -bmj|http://www.bmj.com/rss|#news businessweek|http://www.businessweek.com/feeds/homepage.rss|#news cancer|http://feeds.feedburner.com/ncinewsreleases?format=xml|#news carta|http://feeds2.feedburner.com/carta-standard-rss|#news @@ -44,7 +43,6 @@ csm|http://rss.csmonitor.com/feeds/csm|#news csm_world|http://rss.csmonitor.com/feeds/world|#news cyberguerrilla|https://www.cyberguerrilla.org/a/2012/?feed=rss2|#news danisch|http://www.danisch.de/blog/feed/|#news -dod|http://www.defense.gov/news/rss/|#news dwn|http://deutsche-wirtschafts-nachrichten.de/feed/customfeed/|#news ecat|http://ecat.com/feed|#news eia_press|http://www.eia.gov/rss/press_rss.xml|#news @@ -60,7 +58,6 @@ faz_feui|http://www.faz.net/rss/aktuell/feuilleton/|#news faz_politik|http://www.faz.net/rss/aktuell/politik/|#news faz_wirtschaft|http://www.faz.net/rss/aktuell/wirtschaft/|#news #financial fbi|http://www.fbi.gov/homepage/RSS|#news #bullerei -fbi_nat_press|http://www.fbi.gov/news/rss|#news #bullerei fbi_news|http://www.fbi.gov/news/news_blog/rss.xml|#news fbi_press|http://www.fbi.gov/news/current/rss.xml|#news #bullerei fbi_stories|http://www.fbi.gov/news/stories/all-stories/rss.xml|#news #bullerei @@ -75,7 +72,6 @@ GerForPol|http://www.german-foreign-policy.com/de/news/rss-2.0|#news gmanet|http://www.gmanetwork.com/news/rss/news|#news golem|http://www.golem.de/rss.php?feed=RSS1.0|#news google|http://news.google.com/?output=rss|#news -greenpeace|http://www.greenpeace.de/nachrichten/feed/rss2/|#news guardian_uk|http://feeds.theguardian.com/theguardian/uk-news/rss|#news gulli|http://ticker.gulli.com/rss/|#news handelsblatt|http://www.handelsblatt.com/contentexport/feed/schlagzeilen|#news #financial @@ -98,8 +94,6 @@ LtU|http://lambda-the-ultimate.org/rss.xml|#news lukepalmer|http://lukepalmer.wordpress.com/feed/|#news mit|http://web.mit.edu/newsoffice/rss-feeds.feed?type=rss|#news mongrel2_master|https://github.com/zedshaw/mongrel2/commits/master.atom|#news -nasa_iotd|http://www.nasa-usa.de/rss/dyn/lg_image_of_the_day.rss|#news -nasa_news|http://www.nasa-usa.de/rss/dyn/breaking_news.rss|#news nds|http://www.nachdenkseiten.de/?feed=atom|#news netzpolitik|https://netzpolitik.org/feed/|#news newsbtc|http://newsbtc.com/feed/|#news #financial @@ -122,7 +116,6 @@ reddit_4chan|http://www.reddit.com/r/4chan/new/.rss|#news #brainfuck reddit_anticonsum|http://www.reddit.com/r/Anticonsumption/new/.rss|#news reddit_btc|http://www.reddit.com/r/Bitcoin/new/.rss|#news #financial reddit_consp|http://reddit.com/r/conspiracy/.rss|#news -reddit_prog|http://reddit.com/r/programming/|#news reddit_sci|http://www.reddit.com/r/science/.rss|#news reddit_tech|http://www.reddit.com/r/technology/.rss|#news reddit_tpp|http://www.reddit.com/r/twitchplayspokemon/.rss|#news #tpp @@ -182,5 +175,8 @@ weechat|http://dev.weechat.org/feed/atom|#news wp_world|http://feeds.washingtonpost.com/rss/rss_blogpost|#news xkcd|https://xkcd.com/rss.xml|#news yahoo|http://news.yahoo.com/rss/|#news -z0r|https://www.facebook.com/feeds/page.php?format=atom10&id=278857186139|#news zdnet|http://www.zdnet.com/news/rss.xml|#news +reddit_prog|http://www.reddit.com/r/programming/new/.rss|#news +bmj|[object Object]|#news +dod|http://www.defense.gov/news/afps2.xml|#news +greenpeace|http://feeds.feedburner.com/GreenpeaceNews|#news -- cgit v1.2.3 From e13c7bcd25311ce7b446074343bf733322edc992 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 17 Mar 2014 00:58:26 +0100 Subject: newsbot.js: handle gzip/deflate content-encoding --- news/newsbot.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 62609f00..4171e968 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -95,6 +95,17 @@ function create_feedbot (nick, uri, channels) { if (response.statusCode !== 200) { return this.emit('error', new Error('Bad status code')) } + var output = res + switch (res.headers['content-encoding']) { + case 'gzip': + output = zlib.createGunzip() + res.pipe(output) + break + case 'deflate': + output = zlib.createInflate() + res.pipe(output) + break + } this.pipe(feedparser) }) -- cgit v1.2.3 From a1980d18e89cc8f8d6b2598df55a888429bb7f06 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 00:59:57 +0100 Subject: newsbot.js: url_shortener dummy --- news/newsbot.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index ba3dfde3..35587d39 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -140,7 +140,9 @@ function create_feedbot (nick, uri, channels) { // (i.e. we already have a lastTitle) if (client.lastTitle) { newitems.forEach(function (item) { - broadcast(item.title + ' ' + item.link) + return getShortLink(item.link, function (error, shortlink) { + return broadcast(item.title + ' ' + shortlink) + }) }) } @@ -178,6 +180,10 @@ function run_command (methodname, params, callback) { } } +function getShortLink (link, callback) { + return callback(null, link) +} + var methods = {} methods.add = function (params, callback) { create_feedbot(params[0], params[1], [news_channel]) -- cgit v1.2.3 From 0e6a8d12f55f5e8c1c5afb8f91ebcb5564590830 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 01:00:22 +0100 Subject: newsbot.js: check if name taken --- news/newsbot.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 35587d39..73a6111b 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -186,8 +186,12 @@ function getShortLink (link, callback) { var methods = {} methods.add = function (params, callback) { - create_feedbot(params[0], params[1], [news_channel]) - return callback(null) + if (slaves.hasOwnProperty(params[0])) { + return callback(new Error('name already taken')) + } else { + create_feedbot(params[0], params[1], [news_channel]) + return callback(null) + } } methods.del = function (params, callback) { var slave = slaves[params[0]] -- cgit v1.2.3 From a857b628b5a6d9e4e6e5d0f0192ab6f657afaffb Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 17 Mar 2014 01:01:22 +0100 Subject: newsbot.js: s/res/response/ --- news/newsbot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 683bf39a..998482cd 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -105,15 +105,15 @@ function create_feedbot (nick, uri, channels) { if (response.statusCode !== 200) { return this.emit('error', new Error('Bad status code')) } - var output = res - switch (res.headers['content-encoding']) { + var output = response + switch (response.headers['content-encoding']) { case 'gzip': output = zlib.createGunzip() - res.pipe(output) + response.pipe(output) break case 'deflate': output = zlib.createInflate() - res.pipe(output) + response.pipe(output) break } this.pipe(feedparser) -- cgit v1.2.3 From 45dae6eb0ac52a2eee2e24b0bfb553a0d7371a2e Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 17 Mar 2014 01:05:55 +0100 Subject: newsbot.js: use guid to identify articles --- news/newsbot.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 998482cd..18a7fb07 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -134,22 +134,22 @@ function create_feedbot (nick, uri, channels) { return a.date - b.date }) - var indexOfLastTitle = items - .map(function (x) { return x.title }) - .indexOf(client.lastTitle) + var indexOfLastGuid = items + .map(function (x) { return x.guid }) + .indexOf(client.lastGuid) var newitems = items var olditems = [] - // if items contain lastTitle, then only items after that are news - if (!!~indexOfLastTitle) { - olditems = newitems.splice(0, indexOfLastTitle + 1) + // if items contain lastGuid, then only items after that are news + if (!!~indexOfLastGuid) { + olditems = newitems.splice(0, indexOfLastGuid + 1) } if (newitems.length > 0) { // only broadcast news if we're not starting up - // (i.e. we already have a lastTitle) - if (client.lastTitle) { + // (i.e. we already have a lastGuid) + if (client.lastGuid) { newitems.forEach(function (item) { return getShortLink(item.link, function (error, shortlink) { return broadcast(item.title + ' ' + shortlink) @@ -157,7 +157,7 @@ function create_feedbot (nick, uri, channels) { }) } - client.lastTitle = newitems[newitems.length - 1].title + client.lastGuid = newitems[newitems.length - 1].guid } return setTimeout(loop_feedparser, feedbot_loop_delay) -- cgit v1.2.3 From e653d6c832f8fce5937fb782286fd5856e21b204 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 01:35:06 +0100 Subject: newsboss.js: url shortening ftw --- news/newsbot.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 18a7fb07..499f595a 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -3,12 +3,16 @@ var FeedParser = require('feedparser') var Request = require('request') var Parse = require('shell-quote').parse var FS = require('fs') +var HTTP = require('http') +var FormData = require('form-data') +var URL = require('url') var irc_server = 'ire.retiolum' var master_nick = 'knews' var news_channel = '#news' var feeds_file = 'new_feeds' var feedbot_loop_delay = 60 * 1000 // [ms] +var url_shortener_host = 'go' var slaves = {} @@ -192,7 +196,26 @@ function run_command (methodname, params, callback) { } function getShortLink (link, callback) { - return callback(null, link) + var form = new FormData() + form.append('uri', link) + + var request = HTTP.request({ + method: 'post', + host: url_shortener_host, + path: '/', + headers: form.getHeaders(), + }) + form.pipe(request) + + request.on('response', function (response) { + var data = '' + response.on('data', function (chunk) { + data += chunk + }) + response.on('end', function () { + callback(null, data.replace(/\r\n$/,'') + '#' + URL.parse(link).host) + }) + }) } var methods = {} -- cgit v1.2.3 From e8292ba803596a2605d0ff8a94f51eb8707c115a Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 01:51:26 +0100 Subject: newsbot.js: only delete real slaves --- news/newsbot.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 499f595a..55564f0f 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -228,10 +228,11 @@ methods.add = function (params, callback) { } } methods.del = function (params, callback) { - var slave = slaves[params[0]] - if (slave) { + var nick = params[0] + if (slaves.hasOwnProperty(nick)) { + var slave = slaves[nick] slave.client.disconnect() - delete slaves[params[0]] + delete slaves[nick] return callback(null) } else { return callback(new Error('botname not found')) -- cgit v1.2.3 From 3f2320f85e6bd19bf3b4f6bbd4f07b5ae1e731c8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 02:10:39 +0100 Subject: newsbot.js: save really connected channels --- news/newsbot.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 55564f0f..28ab52ea 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -76,7 +76,6 @@ function create_feedbot (nick, uri, channels) { client: client, nick: nick, uri: uri, - channels: channels, } // say text in every joined channel @@ -247,7 +246,7 @@ methods.save = function (params, callback) { return [ slave.nick, slave.uri, - slave.channels.join(' '), + Object.keys(client.chans).join(' '), ].join('|') }).join('\n') + '\n' return FS.writeFile(feeds_file, feeds, function (error) { -- cgit v1.2.3 From adb33710bf3b9c3c1634d13125f39a7697294b1a Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 02:36:38 +0100 Subject: newsbot.js: join after invite --- news/newsbot.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 28ab52ea..35e99c59 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -88,6 +88,10 @@ function create_feedbot (nick, uri, channels) { client.once('registered', loop_feedparser) client.once('registered', deaf_myself) + client.on('invite', function (channel, from, message) { + client.join(channel, null) + }) + client.on('error', function (error) { console.log('Error:', error) }) -- cgit v1.2.3 From 44c648c68cdb58662f9e2d7232d26e59f5ddf662 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 02:37:09 +0100 Subject: newsbot.js: fix save --- news/newsbot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 35e99c59..f01f1c59 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -250,7 +250,7 @@ methods.save = function (params, callback) { return [ slave.nick, slave.uri, - Object.keys(client.chans).join(' '), + Object.keys(slave.client.chans).join(' '), ].join('|') }).join('\n') + '\n' return FS.writeFile(feeds_file, feeds, function (error) { -- cgit v1.2.3 From 43764e34447da5abf8da71c0e795ce07d20dc1c7 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 02:41:57 +0100 Subject: newsbot.js: stay kicked --- news/newsbot.js | 1 + 1 file changed, 1 insertion(+) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index f01f1c59..c1d36f9b 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -70,6 +70,7 @@ function main () { function create_feedbot (nick, uri, channels) { var client = new IRC.Client(irc_server, nick, { channels: channels, + autoRejoin: false, }) slaves[nick] = { -- cgit v1.2.3 From ac8e7d1197d6c6466980fdf82ed8536c81cb612e Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 17 Mar 2014 03:54:49 +0100 Subject: newsbot.js: remember last feed to not doublepost --- news/newsbot.js | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 55564f0f..a598f118 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -85,6 +85,12 @@ function create_feedbot (nick, uri, channels) { client.say(channel, text) }) } + + function broadcast_new_item (item) { + return getShortLink(item.link, function (error, shortlink) { + return broadcast(item.title + ' ' + shortlink) + }) + } client.once('registered', loop_feedparser) client.once('registered', deaf_myself) @@ -134,35 +140,19 @@ function create_feedbot (nick, uri, channels) { } }) feedparser.on('end', function () { - items = items.sort(function (a, b) { - return a.date - b.date - }) - - var indexOfLastGuid = items - .map(function (x) { return x.guid }) - .indexOf(client.lastGuid) - - var newitems = items - var olditems = [] - // if items contain lastGuid, then only items after that are news - if (!!~indexOfLastGuid) { - olditems = newitems.splice(0, indexOfLastGuid + 1) + if (client.lastItems) { + items.forEach(function (item)) { + if (!client.lastItems.hasOwnProperty(item.title)) { + broadcast_new_item(item) + } + }) } - if (newitems.length > 0) { - // only broadcast news if we're not starting up - // (i.e. we already have a lastGuid) - if (client.lastGuid) { - newitems.forEach(function (item) { - return getShortLink(item.link, function (error, shortlink) { - return broadcast(item.title + ' ' + shortlink) - }) - }) - } - - client.lastGuid = newitems[newitems.length - 1].guid - } + client.lastItems = {} + items.forEach(function (item) { + client.lastItems[item.title] = true + }) return setTimeout(loop_feedparser, feedbot_loop_delay) }) -- cgit v1.2.3 From d8623e1d59c20b0640550f885e9cd30e7624f6e7 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 04:01:17 +0100 Subject: newsbot.js: typo fix --- news/newsbot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 73441ad0..a422d867 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -146,7 +146,7 @@ function create_feedbot (nick, uri, channels) { feedparser.on('end', function () { if (client.lastItems) { - items.forEach(function (item)) { + items.forEach(function (item) { if (!client.lastItems.hasOwnProperty(item.title)) { broadcast_new_item(item) } -- cgit v1.2.3 From 056e4fa611a780caddc0b3a61d0de587f6d5cb79 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 17 Mar 2014 04:04:45 +0100 Subject: news: npm init --- news/package.json | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 news/package.json (limited to 'news') diff --git a/news/package.json b/news/package.json new file mode 100644 index 00000000..52c19177 --- /dev/null +++ b/news/package.json @@ -0,0 +1,32 @@ +{ + "name": "news", + "version": "0.0.0", + "description": "", + "main": "newsbot.js", + "dependencies": { + "feedparser": "*", + "form-data": "*", + "irc": "*", + "request": "*", + "shell-quote": "*" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/krebscode/painload" + }, + "keywords": [ + "irc", + "news", + "feed" + ], + "author": "krebs", + "license": "WTFPLv2", + "bugs": { + "url": "https://github.com/krebscode/painload/issues" + }, + "homepage": "https://github.com/krebscode/painload" +} -- cgit v1.2.3 From 5fbf714096ef65c98cabb54cbc08641f37ffa462 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 04:23:24 +0100 Subject: newsboss.js: fancy create delay --- news/newsbot.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index a422d867..80bb95b1 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -12,6 +12,7 @@ var master_nick = 'knews' var news_channel = '#news' var feeds_file = 'new_feeds' var feedbot_loop_delay = 60 * 1000 // [ms] +var feedbot_create_delay = 200 // [ms] var url_shortener_host = 'go' var slaves = {} @@ -51,7 +52,7 @@ function main () { .filter(function (line) { return line.length > 0 }) - .forEach(function (line) { + .forEach(function (line, i) { var parts = line.split('|') if (parts.length !== 3) { console.log('bad new_feeds line ' + lines + ': ' + line) @@ -62,7 +63,9 @@ function main () { var uri = parts[1] var channels = parts[2].split(' ') - return create_feedbot(nick, uri, channels) + setTimeout(function () { + return create_feedbot(nick, uri, channels) + }, i*feedbot_create_delay) }) }) } -- cgit v1.2.3 From ea2d35149e8e168c3610919c202d6f8c281f146a Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Mar 2014 04:47:49 +0100 Subject: news-feeds: the awesome painload --- news/new_feeds | 1 + 1 file changed, 1 insertion(+) (limited to 'news') diff --git a/news/new_feeds b/news/new_feeds index 61e6330e..a5de8d72 100644 --- a/news/new_feeds +++ b/news/new_feeds @@ -180,3 +180,4 @@ reddit_prog|http://www.reddit.com/r/programming/new/.rss|#news bmj|[object Object]|#news dod|http://www.defense.gov/news/afps2.xml|#news greenpeace|http://feeds.feedburner.com/GreenpeaceNews|#news +painload|https://github.com/krebscode/painload/commits/master.atom|#news -- cgit v1.2.3 From 23e4a479b1da9b2923c4b98e0651722a8535f669 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 18 Mar 2014 13:40:57 +0100 Subject: newsbot.js: continue loop on error --- news/newsbot.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 80bb95b1..2d8b68f5 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -140,6 +140,7 @@ function create_feedbot (nick, uri, channels) { feedparser.on('error', function (error) { broadcast('4feedparser ' + error) + return continue_loop() }) feedparser.on('readable', function () { for (var item; item = this.read(); ) { @@ -161,8 +162,12 @@ function create_feedbot (nick, uri, channels) { client.lastItems[item.title] = true }) - return setTimeout(loop_feedparser, feedbot_loop_delay) + return continue_loop() }) + + function continue_loop () { + setTimeout(loop_feedparser, feedbot_loop_delay) + } } function deaf_myself () { client.send('mode', nick, '+D') -- cgit v1.2.3 From 8a40327409632f0de7a3167a1f935d1345725522 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 18 Mar 2014 21:47:13 +0100 Subject: newsbot.js: debug failed link --- news/newsbot.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 2d8b68f5..18b5f780 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -199,7 +199,12 @@ function run_command (methodname, params, callback) { function getShortLink (link, callback) { var form = new FormData() - form.append('uri', link) + try { + form.append('uri', link) + } catch (err) { + console.log('link:', link) + throw err + } var request = HTTP.request({ method: 'post', -- cgit v1.2.3