Valhalla Legends Forums Archive | Battle.net Bot Development | CSB - Sending things with "/"

AuthorMessageTime
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*
April 28, 2004, 4:53 PM
Myndfyr
[code]
If Left(strSend, 1) <> "/" Then
AddChat(strSend, vbBlue)
End If
[/code]

I think that's right. I'm not a VB programmer.
April 28, 2004, 4:56 PM
iago
This is extremely simple programming. If you don't know how to do this, go learn the language.
April 28, 2004, 5:41 PM
Dyndrilliac
[code]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[/code]

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.
April 28, 2004, 6:50 PM
iago
When you have 7 consecutive "end if"'s, you might want to consider changing to a different data structure :P
April 28, 2004, 7:05 PM
Eli_1
I thought doing something like, Me.Somethin (ooga) would raise an error -- IIRC, expected '='?
April 28, 2004, 7:06 PM
synth
Try "Call <function>"?
April 28, 2004, 7:07 PM
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.
April 28, 2004, 7:10 PM
Dyndrilliac
[quote author=iago link=board=17;threadid=6520;start=0#msg57294 date=1083179101]
When you have 7 consecutive "end if"'s, you might want to consider changing to a different data structure :P
[/quote]

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 author=Eli_1 link=board=17;threadid=6520;start=0#msg57301 date=1083179419]
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.
[/quote]

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:[code]<Function Name> <Parameter 1>, <Parameter2>, <etc>[/code]
For it to be standalone.
April 28, 2004, 7:10 PM
dodge
[quote author=iago link=board=17;threadid=6520;start=0#msg57276 date=1083174089]
This is extremely simple programming. If you don't know how to do this, go learn the language.
[/quote]

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.
April 28, 2004, 7:51 PM
Dyndrilliac
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.

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

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.
April 28, 2004, 9:08 PM
Adron
[quote author=iago link=board=17;threadid=6520;start=0#msg57294 date=1083179101]
When you have 7 consecutive "end if"'s, you might want to consider changing to a different data structure :P
[/quote]

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.
April 28, 2004, 9:15 PM
iago
[quote author=Adron link=board=17;threadid=6520;start=0#msg57353 date=1083186949]
[quote author=iago link=board=17;threadid=6520;start=0#msg57294 date=1083179101]
When you have 7 consecutive "end if"'s, you might want to consider changing to a different data structure :P
[/quote]

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

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:
[code]if(command = "command1")
do this
else
if (command = "command2")
do this
else
..etc.[/code]

That might not even be right, but that's the impression I got :)
April 28, 2004, 9:24 PM
Adron
Ah, ok. I was looking at the chain
[code]
If Me.C.Connected = True Then
If KeyAscii = vbKeyReturn Then
If Not strMessage = vbNullString Then
If strMessage = "/mp3" Then
[/code]
April 28, 2004, 9:27 PM
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.
April 28, 2004, 9:30 PM

Search