return _("user topics: show, enable|disable, add|rm netmask, set, reset, tell, create, list, destroy")\r
end\r
when "auth"\r
- return _("auth <masterpassword>: log in as the bot owner; other commands: login, whoami, permission syntax, permissions [re]set, permissions view, user")\r
+ return _("auth <masterpassword>: log in as the bot owner; other commands: login, whoami, permission syntax, permissions [re]set, permissions view, user, meet, hello")\r
+ when "meet"\r
+ return _("meet <nick> [as <user>]: creates a bot user for nick, calling it user (defaults to the nick itself)")\r
+ when "hello"\r
+ return _("hello: creates a bot user for the person issuing the command")\r
else\r
- return _("auth commands: auth, login, whoami, who, permission[s], user")\r
+ return _("auth commands: auth, login, whoami, who, permission[s], user, meet, hello")\r
end\r
end\r
\r
end\r
end\r
\r
+ def auth_meet(m, params)\r
+ nick = params[:nick]\r
+ if !nick\r
+ # we are actually responding to a 'hello' command\r
+ unless m.botuser.transient?\r
+ m.reply @bot.lang.get('hello_X') % m.botuser\r
+ return\r
+ end\r
+ nick = m.sourcenick\r
+ irc_user = m.source\r
+ else\r
+ # m.channel is always an Irc::Channel because the command is either\r
+ # public-only 'meet' or private/public 'hello' which was handled by\r
+ # the !nick case, so this shouldn't fail\r
+ irc_user = m.channel.users[nick]\r
+ return m.reply("I don't see anyone named '#{nick}' here") unless irc_user\r
+ end\r
+ # BotUser name\r
+ buname = params[:user] || nick\r
+ begin\r
+ met = @bot.auth.make_permanent(irc_user, buname)\r
+ @bot.auth.set_changed\r
+ m.reply @bot.lang.get('hello_X') % met\r
+ @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" % {\r
+ :buname => buname,\r
+ :pass => met.password\r
+ })\r
+ rescue RuntimeError\r
+ # or can this happen for other cases too?\r
+ # TODO autologin if forced\r
+ m.reply _("but I already know %{buname}" % {:buname => buname})\r
+ rescue => e\r
+ m.reply _("I had problems meeting %{nick}: %{e}" % { :nick => nick, :e => e })\r
+ end\r
+ end\r
+\r
def auth_tell_password(m, params)\r
user = params[:user]\r
begin\r
:action => 'auth_copy_ren_user',\r
:auth_path => ':manage:'\r
\r
+auth.map "meet :nick [as :user]",\r
+ :action => 'auth_meet',\r
+ :auth_path => 'user::manage', :private => false\r
+\r
+auth.map "hello",\r
+ :action => 'auth_meet',\r
+ :auth_path => 'user::manage::meet'\r
+\r
auth.default_auth("user::manage", false)\r
+auth.default_auth("user::manage::meet::hello", true)\r
\r
auth.map "user tell :user the password for :botuser",\r
:action => 'auth_tell_password',\r