• Welcome to Valhalla Legends Archive.
 

CSB - Sending things with "/"

Started by dodge, April 28, 2004, 11:53 AM

Previous topic - Next topic

dodge

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*

MyndFyre


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


I think that's right.  I'm not a VB programmer.
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.

iago

This is extremely simple programming.  If you don't know how to do this, go learn the language.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Dyndrilliac

#3
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.
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.

iago

When you have 7 consecutive "end if"'s, you might want to consider changing to a different data structure :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*


Eli_1

I thought doing something like, Me.Somethin (ooga) would raise an error -- IIRC, expected '='?

synth


Eli_1

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.

Dyndrilliac

#8
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.
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.

dodge

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.

Dyndrilliac

#10
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.
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.

Adron

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.

iago

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 :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Adron

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

Dyndrilliac

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.
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.