diff options
Diffstat (limited to 'ExportBot/Commands/ExportOutfitCommand.cs')
-rw-r--r-- | ExportBot/Commands/ExportOutfitCommand.cs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/ExportBot/Commands/ExportOutfitCommand.cs b/ExportBot/Commands/ExportOutfitCommand.cs new file mode 100644 index 0000000..6ec2776 --- /dev/null +++ b/ExportBot/Commands/ExportOutfitCommand.cs | |||
@@ -0,0 +1,66 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Xml; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | |||
8 | namespace libsecondlife.TestClient | ||
9 | { | ||
10 | public class ExportOutfitCommand : Command | ||
11 | { | ||
12 | public ExportOutfitCommand(TestClient testClient) | ||
13 | { | ||
14 | Name = "exportoutfit"; | ||
15 | Description = "Exports an avatars outfit to an xml file. Usage: exportoutfit avataruuid outputfile.xml"; | ||
16 | } | ||
17 | |||
18 | public override string Execute(string[] args, LLUUID fromAgentID) | ||
19 | { | ||
20 | if (args.Length != 2) | ||
21 | return "Usage: exportoutfit avataruuid outputfile.xml"; | ||
22 | |||
23 | LLUUID id; | ||
24 | |||
25 | try | ||
26 | { | ||
27 | id = new LLUUID(args[0]); | ||
28 | } | ||
29 | catch (Exception) | ||
30 | { | ||
31 | return "Usage: exportoutfit avataruuid outputfile.xml"; | ||
32 | } | ||
33 | |||
34 | lock (Client.Appearances) | ||
35 | { | ||
36 | if (Client.Appearances.ContainsKey(id)) | ||
37 | { | ||
38 | try | ||
39 | { | ||
40 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
41 | settings.Indent = true; | ||
42 | XmlWriter writer = XmlWriter.Create(args[1], settings); | ||
43 | try | ||
44 | { | ||
45 | Client.Appearances[id].ToXml(writer); | ||
46 | } | ||
47 | finally | ||
48 | { | ||
49 | writer.Close(); | ||
50 | } | ||
51 | } | ||
52 | catch (Exception e) | ||
53 | { | ||
54 | return e.ToString(); | ||
55 | } | ||
56 | |||
57 | return "Exported appearance for avatar " + id.ToString() + " to " + args[1]; | ||
58 | } | ||
59 | else | ||
60 | { | ||
61 | return "Couldn't find an appearance for avatar " + id.ToString(); | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | } \ No newline at end of file | ||