Пример #1
0
 public string Execute(NetUser from, NetObject source, string[] args)
 {
     if(args.Length == 0) {
         return ListVariants();
     }
     else {
         return GetDescription(args[0]);
     }
 }
Пример #2
0
        internal virtual void HandleCommand(NetObject source, NetUser from, CommandParser parser)
        {
            foreach(ICommand command in this.commands.FindAll(c => c.Name.ToLower() == parser.Command.ToLower())) {
                Log.Debug("Command ##" + parser.Command + " from " + from.Name + " >> " + command.GetType().FullName);
                if (command.AllowedInPublic || !(this is NetChannel)) {
                    string result = null;
                    try {
                        result = command.Execute(from, source, parser.Args);
                    }
                    catch(MafiaException ex) {
                        result = ex.Message;
                    }
                    catch(Exception ex) {
                        result = "Error: " + ex.ToString();
                        Log.Warn("Error executing command: " + ex.ToString() + " (" + ex.StackTrace + ")");
                    }
                    if (!String.IsNullOrEmpty(result)) {
                        source.SendMessage(result);
                    }

                    break;
                }
            }
        }