O.P. My first script.
This is a dead simple script. All it does is it reads a text file every 10 minutes, picks out a random non-blank line from that file and then sets that as your Personal Message on Messenger. You could use this script with IRC logs, a list of quotes, etc. It didn't take long to make.
Source Code
function updateMessage() { FileSystem = new ActiveXObject("Scripting.FileSystemObject"); file = FileSystem.OpenTextFile("E:/Documents/testfile.txt", 1); i = 0; lines = new Array(); while(!file.AtEndOfStream) { line = file.ReadLine(); if (line != '') { lines[i] = line; } i++; } file.Close(); linenum = Math.floor(Math.random()*lines.length)-1; Messenger.MyPersonalMessage = lines[linenum];}function OnEvent_Initialize(MessengerExit) { }function OnEvent_Uninitialize(MessengerExit) { }function OnEvent_Signin(email) { if (email == Messenger.MyEmail) { updateMessage(); MsgPlus.AddTimer('randomtext', 600000); }}function OnEvent_Timer(timerId) { if (timerId == 'randomtext') { updateMessage(); MsgPlus.AddTimer('randomtext', 600000); }}
Hopefully most of this script should be fairly self-explanatory. OnEvent_Signin is called when a user signs in. This function checks that it is the current user who has just signed in, and if so calls updateMessage() and schedules the next call for in 10 minutes time.
OnEvent_Timer gets called when a timer is triggered - in this case it'll get called after 10 minutes. The function calls updateMessage() and schedules the next call for in another 10 minutes time. updateMessage() opens a text file, reads the whole file putting it into an array and then selects a random line and sets it as the personal message.
Usage
To use it, go to Plus > Scripts and select "Create New". Enter a name for the script and paste the contents of the script above into it and save it. You'll have to sign out/sign in or restart Messenger to make it work. Make sure you've also changed the path to the text file which is E:/Documents/testfile.txt by default.
It'll overwrite your whole personal message. If you want it to appear as part of your personal message, concatenate the random line with something else. For example, you could change:
Messenger.MyPersonalMessage = lines[linenum];To:
Messenger.MyPersonalMessage = 'My Personal Message | '+lines[linenum]; If you want to change the update interval, change the value of 600000 (600000ms is 10 minutes).
"The World At Peace? I'd Rather See The World In Pieces."
|