From 7094c1c7c1899f56350d450c6b969e40d6696625 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Thu, 31 Jul 2008 00:31:28 +0000 Subject: Add support for not-a-herd thanks to kojiro. --- gentoo-data.rb | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'gentoo-data.rb') diff --git a/gentoo-data.rb b/gentoo-data.rb index de77267..bac0699 100644 --- a/gentoo-data.rb +++ b/gentoo-data.rb @@ -93,6 +93,7 @@ class GentooPlugin < Plugin @@cached['herds'] = [0, nil] @@cached['pkgindex'] = [0, nil] @@cached['alias'] = [0, nil] + @@cached['notherds'] = [0, nil] end def herd(m, params) @@ -107,6 +108,21 @@ class GentooPlugin < Plugin herds = @@cached['herds'][1] end + unless @@cached['notherds'] and @@cached['notherds'][0] > now-600 + notherds = {} + File.foreach("#{scriptdir}/not-a-herd.txt") { |line| + k,v = line.split(/\s+/, 2) + notherds[k] = v + } + if notherds.length > 0 + @@cached['notherds'] = [now, notherds] + else + @@cached['notherds'] = [0, nil] + end + else + notherds = @@cached['notherds'][1] + end + # Parse data # xpath queries with REXML appear to be extremely slow, which is why we took the approach below herd = nil @@ -115,10 +131,7 @@ class GentooPlugin < Plugin herd = elem break end } - if not herd - # TODO: Add in not-a-herd.txt - m.reply "Unable to find herd '#{params[:herd]}'" - else + if herd emails = [] for maintainer in herd.get_elements("maintainer") emails << maintainer.get_elements('email')[0].text.split('@')[0] @@ -131,6 +144,9 @@ class GentooPlugin < Plugin end end m.reply "(#{params[:herd]}) #{emails.sort.join(', ')}" + elsif notherds.has_key?(params[:herd]) + herddata = notherds[params[:herd]] + m.reply "(#{params[:herd]}) #{herddata}" end end -- cgit v1.2.3-65-gdbad