when "list"\r
return _("user list : lists all the botusers")\r
when "destroy"\r
- return _("user destroy <botuser> <password> : destroys <botuser>; this function %{highlight}must%{highlight} be called in two steps. On the first call, no password must be specified: <botuser> is then queued for destruction. On the second call, you must specify the correct password for <botuser>, and it will be destroyed. If you want to cancel the destruction, issue the command +user cancel destroy <botuser>+") % {:highlight => Bold}\r
+ return _("user destroy <botuser> : destroys <botuser>. This function %{highlight}must%{highlight} be called in two steps. On the first call <botuser> is queued for destruction. On the second call, which must be in the form 'user confirm destroy <botuser>', the botuser will be destroyed. If you want to cancel the destruction, issue the command 'user cancel destroy <botuser>'") % {:highlight => Bold}\r
else\r
return _("user topics: show, enable|disable, add|rm netmask, set, reset, tell, create, list, destroy")\r
end\r
buname = params[:name]\r
return m.reply(_("You can't destroy %{user}") % {:user => buname}) if\r
["everyone", "owner"].include?(buname)\r
- cancel = m.message.split[1] == 'cancel'\r
- password = params[:password]\r
+ mod = params[:modifier].to_sym rescue nil\r
\r
buser_array = @bot.auth.save_array\r
buser_hash = buser_array.inject({}) { |h, u|\r
return m.reply(_("no such botuser %{user}") % {:user=>buname}) unless\r
buser_hash.keys.include?(buname)\r
\r
- if cancel\r
+ case mod\r
+ when :cancel\r
if @destroy_q.include?(buname)\r
@destroy_q.delete(buname)\r
m.reply(_("%{user} removed from the destruction queue") % {:user=>buname})\r
m.reply(_("%{user} was not queued for destruction") % {:user=>buname})\r
end\r
return\r
- end\r
-\r
- if password.nil?\r
+ when nil\r
if @destroy_q.include?(buname)\r
- return m.reply(_("%{user} already queued for destruction, use %{highlight}user destroy %{user} <password>%{highlight} to destroy it") % {:user=>buname, :highlight=>Bold})\r
+ return m.reply(_("%{user} already queued for destruction, use %{highlight}user confirm destroy %{user}%{highlight} to destroy it") % {:user=>buname, :highlight=>Bold})\r
else\r
@destroy_q << buname\r
- return m.reply(_("%{user} queued for destruction, use %{highlight}user destroy %{user} <password>%{highlight} to destroy it") % {:user=>buname, :highlight=>Bold})\r
+ return m.reply(_("%{user} queued for destruction, use %{highlight}user confirm destroy %{user}%{highlight} to destroy it") % {:user=>buname, :highlight=>Bold})\r
end\r
- else\r
+ when :confirm\r
begin\r
return m.reply(_("%{user} is not queued for destruction yet") %\r
{:user=>buname}) unless @destroy_q.include?(buname)\r
- return m.reply(_("wrong password for %{user}") %\r
- {:user=>buname}) unless buser_hash[buname][:password] == password\r
buser_array.delete_if { |u|\r
u[:username] == buname\r
}\r
end\r
return m.reply(_("botuser %{user} destroyed") % {:user => buname})\r
end\r
-\r
end\r
\r
def auth_copy_ren_user(m, params)\r
:defaults => {:password => nil},\r
:auth_path => ':manage:'\r
\r
-auth.map "user [cancel] destroy :name :password",\r
+auth.map "user [:modifier] destroy :name",\r
:action => 'auth_destroy_user',\r
- :defaults => { :password => nil },\r
- :auth_path => ':manage::destroy:'\r
+ :requirements => { :modifier => /^(cancel|confirm)?$/ },\r
+ :defaults => { :modifier => '' },\r
+ :auth_path => ':manage::destroy!'\r
\r
auth.map "user copy :source [to] :dest",\r
:action => 'auth_copy_ren_user',\r