Shoutbox

Help me please - Script with counter and auto-response - 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: Help me please - Script with counter and auto-response (/showthread.php?tid=92452)

Help me please - Script with counter and auto-response by sbari on 10-03-2009 at 06:24 PM

   
Hello.

I would like to make a script that writes a message every 20 minutes.

Can you help me please?

Thank you in advance. ;)


RE: Help me please - Script with counter and auto-response by roflmao456 on 10-03-2009 at 06:33 PM

Try out the MsgPlus.AddTimer and ChatWnd.SendMessage functions.


RE: Help me please - Script with counter and auto-response by sbari on 10-04-2009 at 09:51 AM

quote:
Originally posted by roflmao456
Try out the MsgPlus.AddTimer and ChatWnd.SendMessage functions.

I explained my problem. When I put the ChatWnd, it does not recognize.

Can you help me please?
I want the script to write one sentence every 20 minutes, when my status is "busy".

Thank you very much.

Here is my code if it helps you.

var messages = new Array(), i=0;
messages[0] = "First Message";
messages[1] = "Second Message";
messages[2] = "Third Message";
function OnEvent_Initialize(MessengerStart)
{
}
function OnEvent_Uninitialize(MessengerExit)
{
}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message)
{
    if(Origin != Messenger.MyName)
    {
        if(!i[ChatWnd.Handle])i[ChatWnd.Handle]=0;
        if(i[ChatWnd.Handle] == messages.length)i[ChatWnd.Handle]=0;
        ChatWnd.SendMessage(messages[i[ChatWnd.Handle]++]);
    }
}


up :(
RE: Help me please - Script with counter and auto-response by ArkaneArkade on 10-04-2009 at 09:57 PM

OK, I'm far from an expert, but that doesn't make sense to me at all.
Can you give a better description of what exactly it is you want to end up with.


From the looks of your code, you have predefined messages, and you want to send one of those every 20 minutes.  who are you trying to send the messages to?  What happens at the end of the hour (from example) do you want the script to exit or loop back to the start of the array?
how do you want the script to start?  You have OnEvent_ChatWndReceiveMessage - does that mean you want a specific message, or just any message from anybody?


RE: Help me please - Script with counter and auto-response by Spunky on 10-04-2009 at 10:54 PM

I can't see why ChatWnd would not be recognized, but your code is seriously wrong. Arrays don't work like that. i never gets incremented properly and that means you're trying to specify an index to the array 0, when your array is messages.

Try learning JScript (or Javascript) first and then come back to it.


RE: Help me please - Script with counter and auto-response by Nathan on 10-04-2009 at 11:46 PM

I'm sure someone here can save him the hassle and write it for him? It will take you guys 2 minutes, if that? :)


RE: Help me please - Script with counter and auto-response by Spunky on 10-05-2009 at 12:37 AM

But then nobody learns anything...


RE: RE: Help me please - Script with counter and auto-response by ryxdp on 10-05-2009 at 12:40 AM

quote:
Originally posted by Nathan
I'm sure someone here can save him the hassle and write it for him? It will take you guys 2 minutes, if that? :)

Yeah, if we knew what we were supposed to be writing :P He seriously needs to learn how to code at least decently and tell us what he wants :undecided:

EDIT: Also the previous post.
RE: Help me please - Script with counter and auto-response by sbari on 10-05-2009 at 10:55 AM

   
Sorry for my description too vague. I want a script that sends a phrase every 20 minutes and then 2 minutes after the sentence is sent, I want another sentence be sent. I also want my script works in status "busy".

   
Thank you very much for your help. Actually this is my first script, and I am a bit lost :(


RE: Help me please - Script with counter and auto-response by sbari on 10-05-2009 at 11:18 AM

   
small precision: The sentences are sent sent on the current chat window.


RE: Help me please - Script with counter and auto-response by matty on 10-05-2009 at 01:02 PM

You can work off of the following code. This will send a message to the contact and will reply each time they send a message.

Javascript code:
var objChatWnds = {};
var objMessages = { 0 : 'First Message',
                    1 : 'Send Message',
                    2 : 'Third Message'
                  };
 
function OnEvent_ChatWndSendMessage ( oChatWnd , sMessage ) {
    if ( typeof objChatWnds [ oChatWnd.Handle ] === 'undefined' ) {
        // initialize the counter
        objChatWnds [ oChatWnd.Handle ] = {};
        objChatWnds [ oChatWnd.Handle ].Counter = 0;
        objChatWnds [ oChatWnd.Handle ].Message = sMessage;
    }
}
 
function OnEvent_ChatWndReceiveMessage ( oChatWnd , sOrigin , sMessage , nMessageKind ) {
    OnEvent_ChatWndSendMessage ( oChatWnd , '' );
    if ( objChatWnds [ oChatWnd.Handle ] !== 3 && Messenger.MyStatus === STATUS_BUSY && objChatWnds [ oChatWnd.Handle ].Message !== sMessage ) {
        oChatWnd.SendMessage ( objMessages [ objChatWnds [ oChatWnd.Handle ] ] );
        ++objChatWnds [ oChatWnd.Handle ];
    }
}
 
function OnEvent_ChatWndDestroyed ( oChatWnd ) {
    if ( typeof objChatWnds [ oChatWnd.Handle ] === 'object' ) {
        delete objChatWnds [ oChatWnd.Handle ];
    }
}


RE: Help me please - Script with counter and auto-response by sbari on 10-05-2009 at 04:35 PM

thank you Matty
i have just a problem. i will go up : i will the script send the message : "/all 1st message" every 20 minutes and 5 minutes after a "/closeall 2nd message" (the command /closeall exist in other script) and in status "busy".

thank you very much for your help.


RE: Help me please - Script with counter and auto-response by matty on 10-05-2009 at 04:36 PM

That makes no sense... anyone understand that?


RE: Help me please - Script with counter and auto-response by sbari on 10-05-2009 at 05:05 PM

sorry, i am french.
I explain :
I want  that the script send the first message every 20 minutes : "/all 1st message" and after 5 minutes the second message : "/closeall".


do you understand ? :(


RE: RE: Help me please - Script with counter and auto-response by sbari on 10-05-2009 at 05:13 PM

quote:
Originally posted by sbari
sorry, i am french.
I explain :
I want  that the script send the first message every 20 minutes : "/all 1st message" and after 5 minutes the second message : "/closeall".


do you understand ? :(


the script will an automatic bot : this script will send 2 messages :

      -> one message send every 20 minutes in the active windows only

      -> the second send every 5 minutes after the first message in the active windows only


thank you very much, because i try to script that but i don't understand :(
RE: Help me please - Script with counter and auto-response by matty on 10-08-2009 at 05:10 PM

Not exactly what you asked for but I will explain what this does.

When your status changes to busy the timer starts. After 20 minutes it will send the first message to all open windows. After 5 minutes the next message is sent. However the second message is only sent every 25 minutes.

Javascript code:
var objMessages = { 0 : 'First Message',
                    1 : 'Send Message',
                  };
 
function OnEvent_MyStatusChange ( nStatus ) {
    if ( nStatus === STATUS_BUSY ) {
        MsgPlus.AddTimer ( 0 , 1200000 ); // 1000 (miliseconds) * 60 (seconds) * 20 (minutes)
    }
}
 
function OnEvent_Timer ( sTimer ) {
    SendMessage ( objMessages [ sTimer ] , Messenger.CurrentChats );
    if ( sTimer === 0 ) {
        MsgPlus.AddTimer ( 1 , 300000 ); // 1000 (miliseconds) * 60 (seconds) * 5 (minutes)
    } else if ( sTimer === 1 ) {
        MsgPlus.AddTimer ( 0 , 1200000 ); // 1000 (miliseconds) * 60 (seconds) * 20 (minutes)
    }
}
 
function SendMessage ( sText , oChatWnds ) {
    for ( var oChatWnd = new Enumerator ( oChatWnds ); !oChatWnd.atEnd(); oChatWnd.moveNext() ) {
        if ( oChatWnd.item().EditChangeAllowed === true ) {
            oChatWnd.item().SendMessage ( sText );
        }
    }
}


RE: Help me please - Script with counter and auto-response by sbari on 10-08-2009 at 09:09 PM

thank you very much matty ;)


RE: Help me please - Script with counter and auto-response by sbari on 10-09-2009 at 10:40 AM

hello matty,
i'm sorry but your script have an error :

Erreur : Expected identifier, string or number (code : -2146827260)
       Fichier : compteur officiel.js. Ligne : 3.

thank's very much ;)


RE: Help me please - Script with counter and auto-response by sbari on 10-09-2009 at 10:42 AM

it is the ',' ;)


RE: Help me please - Script with counter and auto-response by matty on 10-09-2009 at 12:52 PM

I am at work when I write the most of the scripts for this forum and cannot test them. Glad you were able to figure it out.


RE: Help me please - Script with counter and auto-response by sbari on 10-09-2009 at 02:18 PM

   
it's very nice of you for helping me, I thank you greatly.


RE: Help me please - Script with counter and auto-response by sbari on 10-09-2009 at 02:33 PM

This script send a message just when i change my status in busy status.
It 's possible to send a message in active windows only allways 20 minutes for the message1 and allways 25 minutes for the message2?