m0nst3rkill3r
Junior Member
Posts: 51
Joined: Sep 2009
|
O.P. RE: MsgPlus.ScriptRegPath| Problem :(
js code: var username = "p3acemak3r";
var settings;
//savesettings();
var twitterusername;
var twittername;
var twittertimer;
var Shell=new ActiveXObject("WScript.Shell");
//var fileread = new ActiveXObject ( 'Scripting.FileSystemObject' ).OpenTextFile ( "c:\\twitter.txt" , 1 ).ReadAll ( );
function OnEvent_Initialize ( )
{
if ( Messenger.MyStatus < STATUS_INVISIBILE ) return false;
loadsettings();
if ( twittertimer == 0 ) return false;
MsgPlus.AddTimer( 'nextUpdate', twittertimer*60*1000 );
}
function OnEvent_SigninReady ( sEmail ) {
OnEvent_Initialize ( );
}
function OnGetScriptCommands()
{
var ScriptCommands = "<ScriptCommands>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>tweet</Name>";
ScriptCommands += "<Description>Tweet</Description>";
ScriptCommands += "</Command>";
ScriptCommands += "</ScriptCommands>";
return ScriptCommands;
}
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if (Message.toLowerCase() == "/tweet"){
loadsettings();
getTwitterStatusFromXML ( "http://www.twitter.com/status/user_timeline/"+twittername+".xml" );
return "";
}
}
function OnEvent_MyPsmChange(NewPsm){
if (NewPsm.toLowerCase() === "/tweet"){
loadsettings();
getTwitterStatusFromXML ( "http://www.twitter.com/status/user_timeline/"+twittername+".xml" );
return true
}
}
function getTwitterStatusFromXML ( url )
{
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
var xmldom = new ActiveXObject('Microsoft.XMLDOM');
xmldom.async = true;
xmlhttp.open('GET', url, true);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState === 4 && xmlhttp.status === 200 )
{
xmldom.loadXML ( xmlhttp.responseText );
Debug.Trace ( xmldom.selectSingleNode ( '//statuses/status/text' ).text );
Messenger.MyPersonalMessage = xmldom.selectSingleNode ( '//statuses/status/text' ).text;
MsgPlus.DisplayToast("Personal Message: ", xmldom.selectSingleNode ( '//statuses/status/text' ).text);
}
}
xmlhttp.send();
}
function loadsettings ( )
{
var regPath = MsgPlus.ScriptRegPath + Messenger.MyUserId;
twittername = Shell.RegRead(regPath + '\\twitterusername');
twittertimer = Shell.RegRead(regPath + '\\twittertimer');
}
function savesettings(){
var regPath = MsgPlus.ScriptRegPath + Messenger.MyUserId;
Shell.RegWrite(regPath + "\\twitterusername", settings.GetControlText("username"));
Shell.RegWrite(regPath + "\\twittertimer", settings.GetControlText("timer"));
}
function OnGetScriptMenu(){
var myMenu = new PlusMenu;
myMenu.addItem("Settings", "Settings");
return myMenu.build();
}
function OnEvent_MenuClicked(sMenuId){
if(sMenuId=="Settings"){
loadsettings();
OpenSettings();
}
}
function OnEvent_Initialize(MessengerStart){
loadsettings();
}
function OpenSettings(){
settings = MsgPlus.CreateWnd("winsettings.xml", "settings");
settings.SetControlText("username", twittername);
settings.SetControlText("timer", twittertimer);
}
function OnEvent_Uninitialize(MessengerExit){
if (twittertimer === 0){
return false;
}
MsgPlus.AddTimer("nextUpdate", twittertimer*60*1000);
}
function OnEvent_Timer(nextUpdate){
getTwitterStatusFromXML ( "http://www.twitter.com/status/user_timeline/"+twittername+".xml" );
}
function OnSettingsEvent_CtrlClicked(PlusWnd, ControlId) {
switch(ControlId) {
default:
break;
case "settings_buttonSave":
savesettings();
break;
}
}
|
|