Valhalla Legends Forums Archive | Battle.net Bot Development | away idle timers

AuthorMessageTime
Crim-Training
most can do it, now to teach me..

ive got my timer inplace (idleAway)

and this is as much as ive done

[code] 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 [/code]

am i missing anything? can someone help me plz
October 30, 2003, 10:38 PM
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
October 30, 2003, 11:16 PM
Myndfyr
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):

[code]

' 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
[/code]

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

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

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
October 30, 2003, 11:40 PM
warz
You're sending your idle message every 30 seconds?
October 30, 2003, 11:41 PM
iago
Ugh, you really ought to let him figure stuff out for himself; he won't learn anything if you copy/paste!!
October 30, 2003, 11:58 PM
Kp
[quote author=Myndfyre link=board=17;threadid=3340;start=0#msg26577 date=1067557212]
[code]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
[/code]

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).[/quote]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.
October 31, 2003, 5:11 AM
Crim-Training
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"
October 31, 2003, 7:26 AM
iago
Figure it out! That's the only way to learn. :P
October 31, 2003, 7:37 AM
Crim-Training
as much as i hate spamming, the timer wont change from 1min

[code] 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 [/code]

anyone know why ?
October 31, 2003, 7:41 AM
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...

[code]
if mins >= 120 then
send "/message"
mins = 0
end if
[/code]
October 31, 2003, 1:37 PM
Grok
+1 to warz because ... well because he only had +8.
October 31, 2003, 2:21 PM
Dyndrilliac
Hm, whats wrong with just:

[code]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[/code]

And on connect have it...

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

And last but not least, on disconnect:

[code]IdleMsg.Enabled = False[/code]

That works for me and it's incredibly simple.
November 2, 2003, 8:05 PM
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)
November 3, 2003, 9:05 AM
iago
[quote author=Crim-Training link=board=17;threadid=3340;start=0#msg27181 date=1067850344]
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)
[/quote]

Why wouldn't you just post it here?
November 3, 2003, 9:13 AM
Crim-Training
[quote author=iago link=board=17;threadid=3340;start=0#msg27182 date=1067850789]
Why wouldn't you just post it here?
[/quote]

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
November 3, 2003, 12:09 PM
hismajesty
[quote author=Crim-Training link=board=17;threadid=3340;start=0#msg27187 date=1067861392]
[quote author=iago link=board=17;threadid=3340;start=0#msg27182 date=1067850789]
Why wouldn't you just post it here?
[/quote]

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
[/quote]

Why would they laugh? As long as your code works I see no reason to laugh. (Except for the fact that you spelled 'milliseconds' wrong :P)
November 3, 2003, 4:23 PM
Crim-Training
[quote author=Crim-Training link=board=17;threadid=3340;start=0#msg27187 date=1067861392]
[quote author=iago link=board=17;threadid=3340;start=0#msg27182 date=1067850789]
Why wouldn't you just post it here?
[/quote]

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
[/quote]



sorry to bring this back up, but did anyone download that file ? i lost it when i had to format
January 11, 2004, 5:55 PM
Stealth
[quote author=Dyndrilliac link=board=17;threadid=3340;start=0#msg27068 date=1067803503]
[code]IdleMsg.Enabled = True
IdleMsg.Interval = varIdleTick * 100 '(Sets it up for seconds instead of the normal milliseconds)
[/code]
[/quote]

Seconds = Milliseconds * 1000 (not 100) :)
January 11, 2004, 9:50 PM

Search