• Welcome to Valhalla Legends Archive.
 

away idle timers

Started by Crim-Training, October 30, 2003, 04:38 PM

Previous topic - Next topic

Crim-Training

most can do it, now to teach me..

ive got my timer inplace (idleAway)

and this is as much as ive done

Private Sub IdleAway_Timer()
idleAway.Interval = 30000
Dim Mins As Integer
Mins = Mins + 1
CleanSlateBot1.Send "/away Has been idle for " & Mins & " Seconds."
End Sub


am i missing anything? can someone help me plz

iago

Did you set the initial interval?
Did you set it to enabled?

You aren't initializing Mins
You aren't remembering Mins
You're adding one to Mins every 30 seconds
You called Seconds Mins
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


MyndFyre

Trying to remember as much VB as I can...

Once you're connected, you start by initializing your Timer (assuming that it's called IdleTimer elsewhere):



' This code MUST go somewhere else in your code that makes it global
' for example, a module
Dim Mins As Integer
Dim Away As Boolean

' Start your timer upon connection to BNCS
Private Sub CleanSlateBot1_Connect ()
   ' .... other init stuff here
   IdleTimer.Interval = 60000
   Mins = 0
   Away = False
   IdleTimer.Start
End Sub

Private Sub IdleTimer_Tick()
   Mins = Mins + 1
   If Away Then
       CleanSlateBot1.Send "/away"
       Away = False
   End If
   CleanSlateBot1.Send "/away Has been idle for " & Mins & " minutes."
   Away = True
End Sub


Now, if you wanted to do something so that you would reset the timer whenever typing happened:


Private Sub TextBox1_TextChanged()
   Mins = 0
   If (Away) Then
       CleanSlateBot1.Send("/away")
       Away = False
   End If
   IdleTimer.Stop
   IdleTimer.Start
End Sub


Now, I'm not sure if my code works or not, because I'm not a VB6 programmer.  What I want you to understand is why I did what I did.

Your Mins variable is going to be available throughout your code.  It needs to be accessible at a global level.  That's why we declared it in a module.

You want your timer to update your away message each minute.  Thus, you set your interval to 60 seconds (or 60,000 milliseconds) so that its event handler is called every 60 seconds.  You also want to initialize your minutes count to zero, so that the first time your away message is set, it sets to 1 minute.

Each time your timer ticks, it increments your minutes count, and sends two messages over CSB: the first is a standard "/away" to clear your previous away message, and the second sets your new away status.  If you weren't previously marked away (this is where the Boolean value Away comes in), then it doesn't send the first one.  That way your away states are kept straight (assuming B.net responds as it should).  

I'm not sure how CSB works, but I assumed that you need to have a textbox in the form to enter your chat text.  I just called it "TextBox1" and wired up to the TextChanged event.  Since you're no longer idle when you are typing something at the console, it clears your away status and restarts your timers.  The .Stop then .Start commands effectively reset your timer's count to zero.

Hope this helps - and works!

--Rob
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

warz

You're sending your idle message every 30 seconds?

iago

Ugh, you really ought to let him figure stuff out for himself; he won't learn anything if you copy/paste!!
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Kp

Quote from: Myndfyre on October 30, 2003, 05:40 PM
Private Sub IdleTimer_Tick()
   Mins = Mins + 1
   If Away Then
       CleanSlateBot1.Send "/away"
       Away = False
   End If
   CleanSlateBot1.Send "/away Has been idle for " & Mins & " minutes."
   Away = True
End Sub


Each time your timer ticks, it increments your minutes count, and sends two messages over CSB: the first is a standard "/away" to clear your previous away message, and the second sets your new away status.  If you weren't previously marked away (this is where the Boolean value Away comes in), then it doesn't send the first one.  That way your away states are kept straight (assuming B.net responds as it should).
It's actually not necessary to send the first /away.  Attempting to set one away message while you already have another in place immediately overwrites the old one.  You don't need to explicitly clear it first.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Crim-Training

#6
thx mate

and iago, i do like to learn its just it kept me up til 3am working on it and i needed help.

oh and i only named it "Mins" cuz its old names was "Fuckers"

EDIT: wont compile, "IdleTimer.Start"

iago

Figure it out! That's the only way to learn.  :P
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Crim-Training

#8
as much as i hate spamming, the timer wont change from 1min

Private Sub CleanSlateBot1_Connect()
   IdleTimer.Interval = 60000
   Mins = 0
   Away = False
   IdleTimer.Start
End Sub

Private Sub IdleTimer_Tick()
   Mins = Mins + 1
   If Away Then
       CleanSlateBot1.Send "/away"
       Away = False
   End If
   CleanSlateBot1.Send "/away Has been idle for " & Mins & " minutes."
   Away = True
End Sub

Private Sub Info_TextChanged()
   Mins = 0
   If (Away) Then
       CleanSlateBot1.Send ("/away")
       Away = False
   End If
   IdleTimer.Stop
   IdleTimer.Start
End Sub


anyone know why ?

warz

Because, you're incrimenting Mins but not doing anything with it. I suggest setting the idle interval to 1 second, and checking the value of Mins before sending the idle message. Something like...


if mins >= 120 then
        send "/message"
        mins = 0
end if

Grok

+1 to warz because ... well because he only had  +8.

Dyndrilliac

Hm, whats wrong with just:

Dim varIdle As String

Private Sub IdleMsg_Timer()
varIdle = GetStuff("Config", "Main", "IdleMessage")
Send varIdle '<-- This is how mines setup, I'm not using CSB
End Sub


And on connect have it...

IdleMsg.Enabled = True
IdleMsg.Interval = varIdleTick * 100 '(Sets it up for seconds instead of the normal milliseconds)


And last but not least, on disconnect:

IdleMsg.Enabled = False

That works for me and it's incredibly simple.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Crim-Training

cuz thats not what i was after.. Anyway the problem has been resolved, if anyone would like to know how feel free to pm me or aim me or trick (ps. thx for the help trick)

iago

Quote from: Crim-Training on November 03, 2003, 03:05 AM
cuz thats not what i was after.. Anyway the problem has been resolved, if anyone would like to know how feel free to pm me or aim me or trick (ps. thx for the help trick)

Why wouldn't you just post it here?
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Crim-Training

Quote from: iago on November 03, 2003, 03:13 AM
Why wouldn't you just post it here?

i dont want you to laugh and make a fool out of myself

well.. if u must ill upload
http://zonebot.ath.cx/users/crim/awayidle.zip