X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fcore%2Fauth.rb;h=eee500456c241e135fb919018c572d98bc359cd8;hb=12906a51f698aebe1c9a5e19b15555ebbbcc4368;hp=1fec6e4b4530e0862ce476a472367fccb7efaf65;hpb=570d8535619cf3a9d20ca3d72e5176db2c4c8223;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/core/auth.rb b/lib/rbot/core/auth.rb index 1fec6e4b..eee50045 100644 --- a/lib/rbot/core/auth.rb +++ b/lib/rbot/core/auth.rb @@ -1,6 +1,11 @@ #-- vim:sw=2:et #++ - +# +# :title: rbot auth management from IRC +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2006,2007 Giuseppe Bilotta +# License:: GPL v2 class AuthModule < CoreBotModule @@ -89,7 +94,7 @@ class AuthModule < CoreBotModule splits = params[:args] has_for = splits[-2] == "for" - return usage unless has_for + return usage(m) unless has_for begin user = @bot.auth.get_botuser(splits[-1].sub(/^all$/,"everyone")) @@ -140,7 +145,13 @@ class AuthModule < CoreBotModule def auth_view_perm(m, params) begin - user = @bot.auth.get_botuser(params[:user].sub(/^all$/,"everyone")) + if params[:user].nil? + user = get_botusername_for(m.source) + return m.reply("you are owner, you can do anything") if user == @bot.auth.botwoner + else + user = @bot.auth.get_botuser(params[:user].sub(/^all$/,"everyone")) + return m.reply("owner can do anything") if user.username == "owner" + end rescue return m.reply("couldn't find botuser #{params[:user]}") end @@ -182,6 +193,11 @@ class AuthModule < CoreBotModule "welcome, #{get_botusername_for(user)}" end + def auth_auth(m, params) + params[:botuser] = 'owner' + auth_login(m,params) + end + def auth_login(m, params) begin case @bot.auth.login(m.source, params[:botuser], params[:password]) @@ -231,8 +247,12 @@ class AuthModule < CoreBotModule case topic when "syntax" return "a permission is specified as module::path::to::cmd; when you want to enable it, prefix it with +; when you want to disable it, prefix it with -; when using the +reset+ command, do not use any prefix" + when "set", "reset", "[re]set", "(re)set" + return "permissions [re]set [in ] for : sets or resets the permissions for botuser in channel (use ? to change the permissions for private addressing)" + when "view" + return "permissions view [for ]: display the permissions for user " else - return "permissions (re)set [in ] for : sets or resets the permissions for botuser in channel (use ? to change the permissions for private addressing)" + return "topics: syntax, (re)set, view" end when "user" case topic @@ -258,7 +278,7 @@ class AuthModule < CoreBotModule return "user show, enable|disable, add|rm netmask, set, reset, tell, create, list, destroy" end else - return "#{name}: login, whoami, permission syntax, permissions, user" + return "#{name}: login, whoami, permission syntax, permissions [re]set, permissions view, user" end end @@ -738,21 +758,16 @@ auth.map "user create :name :password", :defaults => {:password => nil}, :auth_path => ':manage:' -auth.map "user cancel destroy :name :password", +auth.map "user [cancel] destroy :name :password", :action => 'auth_destroy_user', :defaults => { :password => nil }, :auth_path => ':manage::destroy:' -auth.map "user destroy :name :password", - :action => 'auth_destroy_user', - :defaults => { :password => nil }, - :auth_path => ':manage:' - -auth.map "user copy :source :dest", +auth.map "user copy :source [to] :dest", :action => 'auth_copy_ren_user', :auth_path => ':manage:' -auth.map "user rename :source :dest", +auth.map "user rename :source [to] :dest", :action => 'auth_copy_ren_user', :auth_path => ':manage:' @@ -776,6 +791,11 @@ auth.map "whoami", :action => 'auth_whoami', :auth_path => '!*!' +auth.map "auth :password", + :action => 'auth_auth', + :public => false, + :auth_path => '!login!' + auth.map "login :botuser :password", :action => 'auth_login', :public => false, @@ -798,7 +818,7 @@ auth.map "permissions reset *args", :action => 'auth_edit_perm', :auth_path => ':edit::reset:' -auth.map "permissions view for :user", +auth.map "permissions view [for :user]", :action => 'auth_view_perm', :auth_path => '::'