Request for Random Phrase Generator - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Request for Random Phrase Generator (/showthread.php?tid=76352)
Request for Random Phrase Generator by FaLCo on 07-27-2007 at 02:35 AM
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!
RE: Request for Random Phrase Generator by matty on 07-27-2007 at 04:03 AM
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();
}
RE: Request for Random Phrase Generator by stu on 07-27-2007 at 03:27 PM
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
RE: Request for Random Phrase Generator by Nathan on 07-27-2007 at 03:35 PM
http://www.msgpluslive.net/scripts/view/210-Insulter/
That's an insulter, however you can edit the javascript to echo whatever you want
RE: Request for Random Phrase Generator by Ezra on 07-27-2007 at 06:46 PM
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.
RE: Request for Random Phrase Generator by matty on 07-28-2007 at 03:03 PM
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;
}
}
}
}
}
|