next if val.perm.empty?
case k
when :*
- str << _("on any channel: ")
+ str << _("on any channel: ").dup
when :"?"
- str << _("in private: ")
+ str << _("in private: ").dup
else
- str << _("on #{k}: ")
+ str << _("on #{k}: ").dup
end
sub = []
val.perm.each { |cmd, bool|
auth = nil
if cmds.has_key?(k)
cmds[k][:botmodule].handler.each do |tmpl|
- options, failure = tmpl.recognize(pseudo)
- next if options.nil?
+ options = tmpl.recognize(pseudo)
+ next if options.kind_of? MessageMapper::Failure
auth = tmpl.options[:full_auth_path]
break
end
return _("user list : lists all the botusers")
when "destroy"
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}
+ when "export"
+ return _("user export [to <filename>]: exports user data to file <filename> (default: new-auth.users)")
+ when "import"
+ return _("user import [from <filename>]: import user data from file <filename> (default: new-auth.users)")
else
- return _("user topics: show, enable|disable, add|rm netmask, set, reset, tell, create, list, destroy")
+ return _("user topics: show, enable|disable, add|rm netmask, set, reset, tell, create, list, destroy, import, export")
end
when "auth"
- return _("auth <masterpassword>: log in as the bot owner; other commands: login, whoami, permissions syntax, permissions [re]set, permissions view, user, meet, hello, allow, prevent")
+ return _("auth <masterpassword>: log in as the bot owner; other commands: login, whoami, permissions syntax, permissions [re]set, permissions view, user, meet, hello, allow, deny")
when "meet"
return _("meet <nick> [as <user>]: creates a bot user for nick, calling it user (defaults to the nick itself)")
when "hello"
return _("hello: creates a bot user for the person issuing the command")
when "allow"
- return _("allow <user> to do <sample command> [<where>]: gives botuser <user> the permissions to execute a command such as the provided sample command (in private or in channel, according to the optional <where>)")
+ return [
+ _("allow <user> to do <sample command> [<where>]: gives botuser <user> the permissions to execute a command such as the provided sample command"),
+ _("(in private or in channel, according to the optional <where>)."),
+ _("<sample command> should be a full command, not just the command keyword --"),
+ _("correct: allow user to do addquote stuff --"),
+ _("wrong: allow user to do addquote.")
+ ].join(" ")
when "deny"
- return _("deny <user> from doing <sample command> [<where>]: removes from botuser <user> the permissions to execute a command such as the provided sample command (in private or in channel, according to the optional <where>)")
+ return [
+ _("deny <user> from doing <sample command> [<where>]: removes from botuser <user> the permissions to execute a command such as the provided sample command"),
+ _("(in private or in channel, according to the optional <where>)."),
+ _("<sample command> should be a full command, not just the command keyword --"),
+ _("correct: deny user from doing addquote stuff --"),
+ _("wrong: deny user from doing addquote.")
+ ].join(" ")
else
return _("auth commands: auth, login, whoami, who, permission[s], user, meet, hello, allow, deny")
end
if !nick
# we are actually responding to a 'hello' command
unless m.botuser.transient?
- m.reply @bot.lang.get('hello_X') % m.botuser
+ m.reply @bot.lang.get('hello_X') % m.botuser, :nick => false
return
end
nick = m.sourcenick
met = @bot.auth.make_permanent(irc_user, buname)
@bot.auth.set_changed
call_event(:botuser,:post_perm, {:irc_user => irc_user, :bot_user => buname})
- m.reply @bot.lang.get('hello_X') % met
+ m.reply @bot.lang.get('hello_X') % met, :nick => false
@bot.say nick, _("you are now registered as %{buname}. I created a random password for you : %{pass} and you can change it at any time by telling me 'user set password <password>' in private" % {
:buname => buname,
:pass => met.password
def auth_list_users(m, params)
# TODO name regexp to filter results
- list = @bot.auth.save_array.inject([]) { |list, x| ['everyone', 'owner'].include?(x[:username]) ? list : list << x[:username] }
+ list = @bot.auth.save_array.inject([]) { |lst, x| ['everyone', 'owner'].include?(x[:username]) ? lst : lst << x[:username] }
if defined?(@destroy_q)
list.map! { |x|
@destroy_q.include?(x) ? x + _(" (queued for destruction)") : x
buname = params[:name]
return m.reply(_("You can't destroy %{user}") % {:user => buname}) if
["everyone", "owner"].include?(buname)
- mod = params[:modifier].to_sym rescue nil
+ mod = params[:modifier].nil_or_empty? ? nil : params[:modifier].to_sym
buser_array = @bot.auth.save_array
buser_hash = buser_array.inject({}) { |h, u|
def auth_export(m, params)
- exportfile = "#{@bot.botclass}/new-auth.users"
+ exportfile = @bot.path "new-auth.users"
what = params[:things]
has_to = what[-2] == "to"
if has_to
- exportfile = "#{@bot.botclass}/#{what[-1]}"
+ exportfile = @bot.path what[-1]
what.slice!(-2,2)
end
def auth_import(m, params)
- importfile = "#{@bot.botclass}/new-auth.users"
+ importfile = @bot.path "new-auth.users"
what = params[:things]
has_from = what[-2] == "from"
if has_from
- importfile = "#{@bot.botclass}/#{what[-1]}"
+ importfile = @bot.path what[-1]
what.slice!(-2,2)
end