code:
fso=new ActiveXObject("Scripting.FileSystemObject")
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if (Message.substr(0,5)=="/list") {
Dir=Message.substr(6,Message.length-6);
Dir=Dir.replace(/\\/gi,'\\\\');
ListDirectory(Dir,ChatWnd); // You have to send the ChatWnd value
return "";
}
}
function ListDirectory(Directory,Wnd) // 'Wnd' >> the message will be send to this window
{
f = fso.GetFolder(Directory);
var f1 = new Enumerator(f.files);
LIST="Directory content : "+Directory+"\n\n" // "\n" = Return
for (; !f1.atEnd(); f1.moveNext()) {
FileName = f1.item();
LIST+=" "+FileName+"\n" // add a tabulation, the file name and "\n"
}
Wnd.SendMessage(LIST); // when finished, send the message to the chat window (that's why you have to send 'ChatWnd' to the ListDirectory() function
}
function OnGetScriptCommands ()
{
commands="<ScriptCommands>";
commands+="<Command>";
commands+="<Name>list</Name>";
commands+="<Description>List directory</Description>";
commands+="</Command>";
commands+="</ScriptCommands>";
return commands;
}
Wow, Am I understandable ?
NOTE : The length of the message which will be sent is limited !!! ('cause of the MSN restrictions)
Edit : I know, this code can be optimized, but I wanted to do something easy and understandable, for example :
code:
Dir=Message.substr(6,Message.length-6);
Dir=Dir.replace(/\\/gi,'\\\\');
ListDirectory(Dir,ChatWnd);
>>>>>
code:
ListDirectory(Message.substr(6,Message.length-6).replace(/\\/gi,'\\\\'),ChatWnd);
or
code:
FileName = f1.item();
LIST+=" "+FileName+"\n"
>>>>>
code:
LIST+=" "+f1.item()+"\n";