Shoutbox

Block MSN Contact on a Schedule Basis - 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: Block MSN Contact on a Schedule Basis (/showthread.php?tid=76955)

Block MSN Contact on a Schedule Basis by ~*McoreD*~ on 08-23-2007 at 10:21 AM

Hi Guys,

I was wondering how I could use MsgPlus to block a certain contact or (contacts) on a scheduled basis.

Say I wanna block AnnoyingGuy123 everyday from 0900 to 1300 and 1400 to 2100. How could I do such thing? Is it possible?

Thanks in advance,
McoreD


RE: Block MSN Contact on a Schedule Basis by Spunky on 08-23-2007 at 02:19 PM

Use a script...

code:
var email = "AnnoyingGuy123@hotmail.com"; //Their Email
var start_hour = 9; //Time to block contact
var start_minutes = 0; //Time to block contact
var stop_hour = 13; //Time to unblock contact
var stop_minutes= 0; //Time to unblock contact

function OnEvent_Timer(tID){
var d = new Date();
var hour = d.getHour();
var minutes = d.getMinutes();
if(hour>=start_hour&&minutes>=start_minutes&&hour<=stop_hour&&minutes<=stop_minutes){
var Contact = Contacts.GetContact(email);
Contact.Blocked = true
}else{
var Contact = Contacts.GetContact(email);
Contact.Blocked = false;
}
}

function OnEvent_SigninReady(){
MsgPlus.AddTimer("block",10000);
}

That should work... I'm actually gonna develop this later with support for multiple users/times

RE: Block MSN Contact on a Schedule Basis by ~*McoreD*~ on 08-23-2007 at 11:45 PM

Hi Spunky, that's a great way to do it.

Got a small prob.

Function called: OnEvent_SigninReady
Error: Object doesn't support this property or method (code: -2146827850)
       File: ScheduleBlock.js. Line: 10.
Function OnEvent_Timer returned an error. Code: -2147352567

Line 10 turns out to be

    var hour = d.getHour();

Fingers crossed.

Thanks,
McoreD

P.S: This got me an idea that we can actually change our status on the same schedule basis too! I guess that is not implemented anywhere either. Hopefully you can add that feature too? :D


RE: Block MSN Contact on a Schedule Basis by vikke on 08-23-2007 at 11:57 PM

Change line 10 to:

code:
var hour = d.getHours();

Just a typo. :)
RE: Block MSN Contact on a Schedule Basis by ~*McoreD*~ on 08-24-2007 at 12:02 AM

Thanks!

Now this is really weird yeah?

Script is now loaded and ready
Function called: OnEvent_SigninReady
Error: 'Contacts' is undefined (code: -2146823279)
       File: ScheduleBlock.js. Line: 17.
Function OnEvent_Timer returned an error. Code: -2147352567

Line 17 is

        var Contact = Contacts.GetContact(email);

but it didn't complain line 13 which is also

        var Contact = Contacts.GetContact(email);

in the code:


if(hour>=start_hour&&minutes>=start_minutes&&hour<=stop_hour&&minutes<=stop_minutes){
        var Contact = Contacts.GetContact(email);
        Debug.Trace(email + " is blocked");
        Contact.Blocked = true
    } else {
        var Contact = Contacts.GetContact(email);
        Debug.Trace(email + " is unblocked");
        Contact.Blocked = false;
    }


RE: Block MSN Contact on a Schedule Basis by Spunky on 08-24-2007 at 01:03 AM

Noticed some problems... I'm back from work now so I can actually test as I go through this time ;)



Re-structured code below. start_hour, start_minute, stop_hour and stop_minute represent a 24 hour clock (ie. 1 = 1AM, 13 = 1PM)

I forgot to define a couple of things and forgot the OnEvent_Initialize function... Works fine for me atm, just gonna make interface and add support for multiple schedules.

code:
var email = "nospam@hotmail.co.uk"; //Their Email
var start_hour = 1; //Time to block contact
var start_minutes = 57; //Time to block contact
var stop_hour = 1; //Time to unblock contact
var stop_minutes= 58; //Time to unblock contact

function OnEvent_Timer(tID){
    var d = new Date();
    var hour = d.getHours(); //fixed typo ;)
    var minutes = d.getMinutes();
    var Contacts = Messenger.MyContacts; //Forgot to define it :p
    if(hour>=start_hour&&minutes>=start_minutes){
            var Contact = Contacts.GetContact(email);
            if(hour<=stop_hour&&minutes<stop_minutes){
                Contact.Blocked = true
                Debug.Trace("Blocked: "+email);
            }else{
                Contact.Blocked = false;
                Debug.Trace("Un-Blocked: "+email);
            }       
    }
    MsgPlus.AddTimer(tID, 10000);
}

function OnEvent_SigninReady(){
    MsgPlus.AddTimer("block",1000);
}

function OnEvent_Initialize(){
    if(Messenger.MyStatus > 1){
        OnEvent_SigninReady();
    }
}




Been working on the interface and so on. I've made the script multi-user (using UserIDs to distinguish between users) and all emails stored in the registry are converted to their userIDs.

[Image: attachment.php?pid=844525]
RE: Block MSN Contact on a Schedule Basis by ~*McoreD*~ on 08-24-2007 at 10:06 AM

Sweet Jesus, that's great work Spunky! :O :D


RE: Block MSN Contact on a Schedule Basis by aNILEator on 08-24-2007 at 12:06 PM

nice one spunky :)

my friend always talks to me when she's at work and she's annoying then so this'd be handy


RE: Block MSN Contact on a Schedule Basis by ~*McoreD*~ on 09-05-2007 at 11:01 AM

Hi Punky, Just wondering if you haven't forgotten this. No pressure if you haven't. :D


RE: Block MSN Contact on a Schedule Basis by Spunky on 09-05-2007 at 11:20 AM

quote:
Originally posted by ~*McoreD*~
Hi Punky, Just wondering if you haven't forgotten this. No pressure if you haven't. :D

Should have a working version posted soon... it works atm, but I don't want to release an unfinished script. Just adding options and finishing touches atm