| Path: | server/shellCommands/snoop.cmd (CVS) |
| Last Update: | Sat Aug 18 22:54:10 -0700 2007 |
# -*- default-generic -*- # # The snoop MUES::CommandShell command. # Time-stamp: <12-Nov-2002 05:04:28 deveiant> # $Id: snoop.cmd,v 1.2 2002/11/12 12:05:08 deveiant Exp $ # # == Authors: # * Michael Granger <ged@FaerieMUD.org> #
View (and control) another user‘s stream.
When this command is invoked, all of the specified user‘s IO will be visible to you, prefixed with an ’@’ character and their login. In addition, you will be able to enter commands into their stream by typing an ’@’ character followed by their login and the command.
Unless the ’-s’ option is given (available to admin-level users only), the snooped user will be apprised of your action.
snoop [OPTIONS] <user>
implementor
silent = false
options = argString.split(/\s+/)
username = options.pop
# Handle options
options.each {|opt|
case opt
when '-s'
raise CommandError, "Only admin users can snoop silently." unless
context.user.isAdmin?
silent = true
else
raise CommandError, "Unknown option '%s'" % opt
end
}
# Fetch the corresponding user from the Engine
user = MUES::ServerFunctions::getUserByName( username ) or
raise CommandError, "No such user '#{username}'"
raise CommandError, "User is not logged in." unless user.activated?
raise CommandError, "You cannot snoop an admin." if
( ! context.user.isAdmin? && user.isAdmin? )
raise CommandError, "Are you mad?!? You can't snoop yourself." if
( context.user == user )
snoopFilter = MUES::SnoopFilter::new( user, context.user, silent )
msg = OutputEvent.new "Snooping %s.\n\n" % user.to_s
return [ snoopFilter, msg ]
Stop viewing another user‘s stream.
When this command is invoked, a previous snoop for the specified user is cancelled. If no user is specified, all snoops currently in effect are cancelled.
unsnoop [<user>]
implementor
username = (argString =~ /(\S+)/) ? $1 : nil
stream = context.user.ioEventStream
targetFilters = stream.findFiltersOfType( MUES::SnoopFilter )
if username
targetFilters.reject! {|filt| filt.targetUser.username != username}
end
msg = ''
stream.stopFilters( *targetFilters ) {|filt|
msg << "Stopping snoop on '%s'\n" % filt.targetUser.username
}
msg << "\n"
return [ MUES::OutputEvent::new(msg) ]