aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2008-07-31 00:31:28 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2008-07-31 00:31:28 +0000
commit7094c1c7c1899f56350d450c6b969e40d6696625 (patch)
treef1e37592475bbc1443cf48a11dd1894cef69259a /gentoo-data.rb
parentAdd the TODO list of stuff to fix still. (diff)
downloadrbot-gentoo-7094c1c7c1899f56350d450c6b969e40d6696625.tar.gz
rbot-gentoo-7094c1c7c1899f56350d450c6b969e40d6696625.tar.bz2
rbot-gentoo-7094c1c7c1899f56350d450c6b969e40d6696625.zip
Add support for not-a-herd thanks to kojiro.
Diffstat (limited to 'gentoo-data.rb')
-rw-r--r--gentoo-data.rb24
1 files changed, 20 insertions, 4 deletions
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