tilde_utils: Add set_programmer
This commit is contained in:
		
							parent
							
								
									3a170716a7
								
							
						
					
					
						commit
						9ff42a234f
					
				| @ -2,7 +2,7 @@ | ||||
| @property #0.tilde_utils #170 | ||||
| 
 | ||||
| @describe $tilde_utils as "This is the Tilde Utilities utility package.  See `help $tilde_utils' for more details." | ||||
| @set $tilde_utils.help_msg to {"Mirrored functions:", "  curl (STR <url> [, INT <include_headers>, INT timeout]) -- See `help curl()`", "  exec (LIST command[, STR input][, LIST environment variables]) -- See `help eval()`"} | ||||
| @set $tilde_utils.help_msg to {"Mirrored functions:", "  curl (STR <url> [, INT <include_headers>, INT timeout]) -- See `help curl()`", "  exec (LIST command[, STR input][, LIST environment variables]) -- See `help eval()`", "", "$wiz_utils:", "", ":set_programmer(object)             object.programmer = 1;","    chparent object to $prog", "    send mail to $prog_log"} | ||||
| 
 | ||||
| @verb $tilde_utils:exec tnt | ||||
| @program $tilde_utils:exec | ||||
| @ -27,3 +27,38 @@ else | ||||
|     return curl (url); | ||||
| endif | ||||
| . | ||||
| 
 | ||||
| @verb $tilde_utils:set_programmer tnt | ||||
| @program $tilde_utils:set_programmer | ||||
| "This code is taken from $wiz_utils:set_programmer, but has the wiz check removed, and a guest check added."; | ||||
| ":set_programmer(victim[,mail from])  => 1 or error."; | ||||
| "Sets victim.programmer, chparents victim to $prog if necessary, and sends mail to $new_prog_log, mail is from optional second arg or caller_perms()."; | ||||
| whodunnit = caller_perms(); | ||||
| {victim, ?mailfrom = whodunnit} = args; | ||||
| if (!(valid(victim) && (is_player(victim) && $object_utils:isa(victim, $player)))) | ||||
|   return E_INVARG; | ||||
| elseif ($object_utils:isa(victim, $guest)) | ||||
|   return E_INVARG; | ||||
| elseif (victim.programmer) | ||||
|   return E_NONE; | ||||
| elseif ($wiz_utils:check_prog_restricted(victim)) | ||||
|   return E_INVARG; | ||||
| elseif (typeof(e = `victim.programmer = 1 ! ANY') == ERR) | ||||
|   return e; | ||||
| else | ||||
|   $quota_utils:adjust_quota_for_programmer(victim); | ||||
|   if (!$object_utils:isa(victim, $prog)) | ||||
|     if (typeof(e = `chparent(victim, $prog) ! ANY') == ERR) | ||||
|       "...this isn't really supposed to happen but it could..."; | ||||
|       player:notify(tostr("chparent(", victim, ",", $prog, ") failed:  ", e)); | ||||
|       player:notify("Check for common properties."); | ||||
|     endif | ||||
|   else | ||||
|     player:notify(tostr(victim.name, " was already a child of ", parent(victim).name, " (", parent(victim), ")")); | ||||
|   endif | ||||
|   if (!$mail_agent:send_message(mailfrom, {$new_prog_log, victim}, tostr("@programmer ", victim.name, " (", victim, ")"), tostr("I just gave ", victim.name, " a programmer bit."))[1]) | ||||
|     $mail_agent:send_message(mailfrom, {$new_prog_log}, tostr("@programmer ", victim.name, " (", victim, ")"), tostr("I just gave ", victim.name, " a programmer bit.")); | ||||
|   endif | ||||
|   return 1; | ||||
| endif | ||||
| . | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user