What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Request for Random Phrase Generator

Request for Random Phrase Generator
Author: Message:
FaLCo
New Member
*


Posts: 1
Joined: Jul 2007
O.P. Request for Random Phrase Generator
Is there a script that allows me to do a command like /random and then it generates a random quote or phrase?

And then is there a way I can change what it randomly says?

Thanks!
07-27-2007 02:35 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Request for Random Phrase Generator
Oddly enough I just happen to write one, it was a quick hack job as I wanted something in my PSM every time I logged in.

The PSM will be reverted to the original when signing out, if the quote is too long it will wait 5 seconds before getting a new one (so it wont bog down messenger). like i said it is a quick hack job. Feel free to change it. I know this isn't what you wanted per say but meh.

code:
var oldPSM;

function OnEvent_Initialize(MessengerStart){
    try {
        oldPSM = Messenger.MyPersonalMessage;
        GetQuote();
    } catch (err) {}
}

function OnEvent_SigninReady(sEmail) {
    OnEvent_Initialize(true);
}

function OnEvent_Signout() {
    Messenger.MyPersonalMessage = oldPSM;
}

function OnEvent_Uninitialize() {
    OnEvent_Signout();
}

function GetQuote() {
    var sUrl = 'http://www.quotedb.com/quote/quote.php?action=random_quote_rss&=&=&';
    Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', sUrl);
   
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open('GET', sUrl, false);
    xmlhttp.send();
    var sString = xmlhttp.responseText;
   
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.loadXML(sString);
    var myNewPSM = xmlDoc.selectNodes('/rss/channel/item/description/text()')[0].text + ' - ' +xmlDoc.selectNodes('/rss/channel/item/title/text()')[0].text;
    Debug.Trace(myNewPSM);
    if (myNewPSM.length > 129) MsgPlus.AddTimer('x', 5000);
    else Messenger.MyPersonalMessage = myNewPSM;
}

function OnEvent_Timer(sTimerId) {
    GetQuote();
}
07-27-2007 04:03 AM
Profile E-Mail PM Find Quote Report
stu
Junior Member
**

Avatar
Stu

Posts: 82
Reputation: 1
38 / Male / Flag
Joined: Sep 2004
RE: Request for Random Phrase Generator
I have a script that uses random lyrics to change your PSM. You can set how often it changes, and how many lyrics you want to be used before a single lyric can be repeated. Would be very easy for you to change the source code to add/change to quotes if thats what you would like, you can find it attached to my post in this thread http://shoutbox.menthix.net/showthread.php?tid=75840&pid=833625#pid833625
07-27-2007 03:27 PM
Profile E-Mail PM Web Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: Request for Random Phrase Generator
http://www.msgpluslive.net/scripts/view/210-Insulter/
That's an insulter, however you can edit the javascript to echo whatever you want :)
Touch Innovation - touch friendly programs/applications for the windows mobile!


07-27-2007 03:35 PM
Profile E-Mail PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Request for Random Phrase Generator
Somehow
code:
var myNewPSM = xmlDoc.selectNodes('/rss/channel/item/description/text()')[0].text + ' - ' +xmlDoc.selectNodes('/rss/channel/item/title/text()')[0].text;
does not seem to work for me, it did at my work, but at home it does nothing, also no error message, but the script does stall here.
[Image: 1-0.png]
             
07-27-2007 06:46 PM
Profile PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Request for Random Phrase Generator
quote:
On Today at 02:07 AM, markee wrote:Sorry, but this is the one time where I think you need to REALLY fix up your code (especially if I'm fixing up your mistakes :\)

I don't see you publicly fixing anything but regardless here it is!

code:
/* define a variable for the original psm */
var oldPSM;

function OnEvent_Initialize(MessengerStart){
    try {
        /* try and record the old psm */
        oldPSM = Messenger.MyPersonalMessage;
        /* get a quote */
        GetQuote();
    /* an error will be caught likely because the user isn't signed in */
    } catch ( (err) {}
}

function OnEvent_SigninReady(sEmail) {
    /* call the initialize function once the user has signed in */
    OnEvent_Initialize(true);
}

function OnEvent_Signout() {
    /* try and set the original psm, if this fails we will catch it, likely because of an internet disconnect */
    try { Messenger.MyPersonalMessage = oldPSM; } catch ( (err) {}
}

function OnEvent_Uninitialize() {
    /* if the script is being uninitalized called the signout function to set the old psm */
    OnEvent_Signout();
}

function OnGetScriptMenu(nLocation){
    /* add a menu item in case the user wants to get another quote */
    return '<ScriptMenu><MenuEntry Id=\'Quote\'>Get new quote</MenuEntry></ScriptMenu>';
}

function OnEvent_MenuClicked(sMenuId, nLocation, oChatWnd){
    /* get a quote because the user wants one */
    GetQuote();
}

function GetQuote() {
    /* declare the url to get the quote from */
    var url = 'http://www.quotedb.com/quote/quote.php?action=random_quote_rss';
    /*
        clear the previous cache of the url
        better to not fill up the cache with useless entries markee
    */

    Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', url);
   
    /* create our xml object */
    var xml = new ActiveXObject('Microsoft.XMLDOM');
    /* set the async flag to true to prevent hanging messenger */
    xml.async = true;
    /* load the url */
    xml.load(url);
   
    /* define our callback function */
    xml.onreadystatechange=function() {
        /* if the xml is finished processing the request */
        if (xml.readyState === 4) {
            /* define a variable for our new psm with the quote - author */
            var xpath = '//rss/channel/item/';
            var myNewPSM = xml.selectSingleNode(xpath+'description').text+' - '+xml.selectSingleNode(xpath+'title').text;
            /* set our xml object to null */
            xml = null;
            /* if the psm is greater then 129 get a new one, messenger will only show 129 */
            if (myNewPSM.length > 129) GetQuote();
            else {
                /* display the new psm to the user and ask if they want to use it (Yes), get another (No) or stop the process (Cancel) */
                switch (Interop.Call('user32', 'MessageBoxW', 0, Messenger.MyEmail+':\n'+myNewPSM, 'Use this quote?', 35)){
                    /* MB_YES */
                    case 6: Messenger.MyPersonalMessage = myNewPSM; break;
                    /* MB_NO */
                    case 7: GetQuote(); break;
                }
            }
        }
    }
}


This post was edited on 07-28-2007 at 03:06 PM by matty.
07-28-2007 03:03 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On