[55600] contrib/mpbot/port.rb
snc at macports.org
snc at macports.org
Fri Aug 14 05:55:24 PDT 2009
Revision: 55600
http://trac.macports.org/changeset/55600
Author: snc at macports.org
Date: 2009-08-14 05:55:24 -0700 (Fri, 14 Aug 2009)
Log Message:
-----------
add name functionality
Modified Paths:
--------------
contrib/mpbot/port.rb
Modified: contrib/mpbot/port.rb
===================================================================
--- contrib/mpbot/port.rb 2009-08-14 12:53:36 UTC (rev 55599)
+++ contrib/mpbot/port.rb 2009-08-14 12:55:24 UTC (rev 55600)
@@ -51,12 +51,14 @@
when "remember"
return "remember <nick> email <address> => remember what port maintainer email <nick> belongs to; " +
"remember <nick> timezone <timezone> => remember the local timezone for <nick>; " +
- "remember <nick> location <location> => remember the physical location for <nick>"
+ "remember <nick> location <location> => remember the physical location for <nick>; " +
+ "remember <nick> name <name> => remember the name for <nick>"
when "forget"
return "forget <nick> => forget all information for <nick>; " +
"forget email <nick> => forget email correspondance for <nick>; " +
"forget timezone <nick> => forget local timezone for <nick>; " +
- "forget location <nick> => forget physical location for <nick>"
+ "forget location <nick> => forget physical location for <nick>; " +
+ "forget name <nick> => forget name for <nick>"
when "whois"
return "whois <nick> => give a summary of information for <nick>"
when "whereis"
@@ -199,12 +201,20 @@
@registry["location_#{nick}"] = location
m.reply "okay, #{nick} is in #{location}"
end
+
+ def rememberName(m, params)
+ nick = params[:nick]
+ name = params[:name].join(' ')
+ @registry["name_#{nick}"] = name
+ m.reply "okay, #{nick} is #{name}"
+ end
def forget(m, params)
nick = params[:nick]
@registry.delete("email_#{nick}")
@registry.delete("timezone_#{nick}")
@registry.delete("location_#{nick}")
+ @registry.delete("name_#{nick}")
m.okay
end
@@ -226,6 +236,12 @@
m.okay
end
+ def forgetName(m, params)
+ nick = params[:nick]
+ @registry.delete("name_#{nick}")
+ m.okay
+ end
+
def whois(m, params)
nick = params[:nick]
email = @registry["email_#{nick}"]
@@ -268,10 +284,15 @@
def whereis(m, params)
nick = params[:nick]
+ name = @registry["name_#{nick}"]
where = whereisNick(nick)
- if where
+ if where && name
+ m.reply "#{name} #{where}"
+ elsif where
m.reply "#{nick} #{where}"
+ elsif name
+ m.reply "I don't know where #{name} is"
else
m.reply "I don't know where #{nick} is"
end
@@ -295,6 +316,7 @@
Thread.new do
email = @registry["email_#{nick}"]
if email
+ name = @registry["name_#{nick}"]
text = callPort("echo", "maintainer:#{email}")
ports = text.split(/\s+/)
portCount = ports.size
@@ -303,11 +325,20 @@
msg = nil;
- if (portCount == 0)
+ if (portCount == 0) && name
+ msg = "#{nick} is #{name} (#{email})"
+ elsif (portCount == 0)
msg = "#{nick} is #{email}"
+ elsif (portCount <= showMax) && name
+ msg = "#{nick} is #{name} (#{email}) and maintainer of " +
+ textEnumeration(somePorts)
elsif (portCount <= showMax)
msg = "#{nick} is #{email} and maintainer of " +
textEnumeration(somePorts)
+ elsif name
+ msg = "#{nick} is #{name} (#{email}) and maintainer of " +
+ textEnumeration(somePorts) +
+ " (of #{portCount} total)"
else
msg = "#{nick} is #{email} and maintainer of " +
textEnumeration(somePorts) +
@@ -318,7 +349,7 @@
if whereis
msg = msg + " and #{whereis}"
end
-
+
@bot.say where, msg
end
end
@@ -374,9 +405,11 @@
plugin.map 'port remember :nick timezone :timezone', :action => 'rememberTimeZone'
plugin.map 'port remember :nick email :email', :action => 'rememberEmail'
plugin.map 'port remember :nick location *location', :action => 'rememberLocation'
+plugin.map 'port remember :nick name *name', :action => 'rememberName'
plugin.map 'port forget :nick', :action => 'forget'
plugin.map 'port forget :nick email', :action => 'forgetEmail'
plugin.map 'port forget :nick timezone', :action => 'forgetTimeZone'
plugin.map 'port forget :nick location', :action => 'forgetLocation'
+plugin.map 'port forget :nick name', :action => 'forgetName'
plugin.map 'port whois :nick', :action => 'whois'
plugin.map 'port whereis :nick', :action => 'whereis'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090814/363ba099/attachment.html>
More information about the macports-changes
mailing list