Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: dodge on April 28, 2004, 11:53 AM

Title: CSB - Sending things with "/"
Post by: dodge on April 28, 2004, 11:53 AM
I remember when I made my bot using CSB I was depressed (no not literally) when yuo type "/w <username> Hye blah blah blah" it prints it to the screen then sebnd it threw bnet, is there anyway so it wont show up on the screen twice?

*opens up VB and works on bot*
Title: Re:CSB - Sending things with "/"
Post by: MyndFyre on April 28, 2004, 11:56 AM

If Left(strSend, 1) <> "/" Then
AddChat(strSend, vbBlue)
End If


I think that's right.  I'm not a VB programmer.
Title: Re:CSB - Sending things with "/"
Post by: iago on April 28, 2004, 12:41 PM
This is extremely simple programming.  If you don't know how to do this, go learn the language.
Title: Re:CSB - Sending things with "/"
Post by: Dyndrilliac on April 28, 2004, 01:50 PM
Private Sub Send_KeyPress(KeyAscii As Integer)

   If Not iNum <= 0 Then
       Pause iNum, True
   End If

   Dim strMessage As String
   strMessage = Me.Send.Text
   Dim strUsername As String
   strUsername = Me.C.UserName
   Dim sChar As String
   sChar = Left$(strMessage, 1)
   
   Dim CurrChannel As String
   CurrChannel = Me.ChannelName.Text
   
   If Me.C.Connected = True Then
       If KeyAscii = vbKeyReturn Then
           If Not strMessage = vbNullString Then
               If strMessage = "/mp3" Then
                   Num = 0
                   Me.C.Send "Current Song: " & Title & " (" & mdlWinamp.GetBitrate & " kbits) :: " & Version & " ::"
                   iNum = 0.5
                   Me.AntiFlood.Enabled = True
                   AddC Me.Chat, vbYellow, "<Song Display> ", vbGreen, Title & " (" & mdlWinamp.GetBitrate & " kbits) :: " & Version & " ::"
                   Me.Send.Text = vbNullString
               Else
                   If strMessage = "/ver" Then
                       Num = 0
                       Me.C.Send "/ me is a " & Version[/me][/me]
                       iNum = 0.5
                       Me.AntiFlood.Enabled = True
                       Me.Send.Text = vbNullString
                   Else
                       If sChar <> "/" Then
                           Num = 0
                           Me.C.Send strMessage
                           iNum = 0.5
                           Me.AntiFlood.Enabled = True
                           Me.Send.AddItem SpellCheck(strMessage)
                           AddC Me.Chat, vbBlue, "<" & strUsername & "> ", vbWhite, SpellCheck(strMessage)
                           Me.Send.Text = vbNullString
                       Else
                           If strMessage = "/rejoin" Then
                               Num = 0
                               Me.C.BinaryRejoin (CurrChannel)
                               iNum = 0.5
                               Me.AntiFlood.Enabled = True
                               Me.Send.AddItem strMessage
                               Me.Send.Text = vbNullString
                           Else
                               Num = 0
                               Me.C.Send strMessage
                               iNum = 0.5
                               Me.AntiFlood.Enabled = True
                               Me.Send.AddItem strMessage
                               Me.Send.Text = vbNullString
                           End If
                       End If
                   End If
               End If
           End If
       End If
   End If
End Sub


That's coming directly from my old CSB Bot. You may have to remove some pieces to make it work for you.

edit: I had to put in an extra space between the "/" and "me" on the internal "/ver" command, because of the fact this forum couldn't display "/me" in the code without changing it for some odd reason. remove it to make it work, but you must make the Version string variable.
Title: Re:CSB - Sending things with "/"
Post by: iago on April 28, 2004, 02:05 PM
When you have 7 consecutive "end if"'s, you might want to consider changing to a different data structure :P
Title: Re:CSB - Sending things with "/"
Post by: Eli_1 on April 28, 2004, 02:06 PM
I thought doing something like, Me.Somethin (ooga) would raise an error -- IIRC, expected '='?
Title: Re:CSB - Sending things with "/"
Post by: synth on April 28, 2004, 02:07 PM
 Try "Call <function>"?
Title: Re:CSB - Sending things with "/"
Post by: Eli_1 on April 28, 2004, 02:10 PM
Or "Function Parametes". I know how to do it, I was just pointing it out because the code he submitted used "Function (Parameters)" a numerous amount of times.
Title: Re:CSB - Sending things with "/"
Post by: Dyndrilliac on April 28, 2004, 02:10 PM
Quote from: iago on April 28, 2004, 02:05 PM
When you have 7 consecutive "end if"'s, you might want to consider changing to a different data structure :P

I thought about doing a Select Case on strMessage, but I thought the nested if ladder would be better, as a last minute self opinion. I may redesign it, but this is from an old bot source, my current one is much more modular.

Quote from: Eli_1 on April 28, 2004, 02:10 PM
Or "Function Parametes". I know how to do it, I was just pointing it out because the code he submitted used "Function (Parameters)" a numerous amount of times.

Well, it works so that's all that really matters. My understanding has been you use paranthese(sp?) when the function/sub is being displayed in a string(using assignment or string concatenation), or you can just do:<Function Name> <Parameter 1>, <Parameter2>, <etc>
For it to be standalone.
Title: Re:CSB - Sending things with "/"
Post by: dodge on April 28, 2004, 02:51 PM
Quote from: iago on April 28, 2004, 12:41 PM
This is extremely simple programming.  If you don't know how to do this, go learn the language.

yeah... ouch my bad when i was reading other posts i thought there posts were more 'newish' then mine, anyways... thanks Dyndrilliac not everyday someone just posts the code you were lookin for  ;D see what i can do using your send function.
Title: Re:CSB - Sending things with "/"
Post by: Dyndrilliac on April 28, 2004, 04:08 PM
Just to note, keep in mind Send is a combo box, and not all the variables used are declared there.

Also it shows slightly how I did my old AntiFlood and AntiIdle, for my CSB Bot.

Private Sub AntiFlood_Timer()
   If iNum = 0 Then
       Exit Sub
   Else
       iNum = iNum - 0.25
   End If
End Sub

Private Sub AntiIdle_Timer()
   Dim CurrChannel As String
   CurrChannel = Me.ChannelName.Text

   If Me.C.Connected = True Then
       Num = Num + 1
       If Not Num < 3600 Then
           Me.C.BinaryRejoin (CurrChannel)
           Num = 0
       End If
   Else
       Exit Sub
   End If
End Sub


Notice how in the Send procedure, everytime you send a message it reduces Num(The amound of seconds you've been idle) to 0, so instead of having the Anti-Idle fire when you are actively doing things, it fires when you really are idle. Also, note the crude Anti-Flood(You should use a queue for this, this was a crappy method I used out of lazyness for a while), and how it stops you from sending message righ after another, almost creating an extra 500ms of client side lag to slow down constant messages. It allows activity so you can still type while the 500ms winds out.

Note: For the timer doing the anti-idle, use a 1000ms interval so it counts Num + 1 per second.
Title: Re:CSB - Sending things with "/"
Post by: Adron on April 28, 2004, 04:15 PM
Quote from: iago on April 28, 2004, 02:05 PM
When you have 7 consecutive "end if"'s, you might want to consider changing to a different data structure :P

VB tends to promote that. It doesn't have short-circuit boolean evaluation, so if you don't want all expressions evaluated always, you have to put them in separate if statements.
Title: Re:CSB - Sending things with "/"
Post by: iago on April 28, 2004, 04:24 PM
Quote from: Adron on April 28, 2004, 04:15 PM
Quote from: iago on April 28, 2004, 02:05 PM
When you have 7 consecutive "end if"'s, you might want to consider changing to a different data structure :P

VB tends to promote that. It doesn't have short-circuit boolean evaluation, so if you don't want all expressions evaluated always, you have to put them in separate if statements.

I was thinking some elseif's or something.  I didn't look at the code, but it seems to me, from my brief glance, he was trying to do this:
if(command = "command1")
 do this
else
 if (command = "command2")
   do this
 else
    ..etc.


That might not even be right, but that's the impression I got :)
Title: Re:CSB - Sending things with "/"
Post by: Adron on April 28, 2004, 04:27 PM
Ah, ok. I was looking at the chain

   If Me.C.Connected = True Then
       If KeyAscii = vbKeyReturn Then
           If Not strMessage = vbNullString Then
               If strMessage = "/mp3" Then
Title: Re:CSB - Sending things with "/"
Post by: Dyndrilliac on April 28, 2004, 04:30 PM
Yes, as I said earlier, I could have probably if not definitely have made it more modular and overall better using Select Case, which is what i'm currently using to help interpret commands, both internally and remotely.