Valhalla Legends Forums Archive | Battle.net Bot Development | Command Bug

AuthorMessageTime
JaMi
[code]
 If InStr(LCase(Data), "/join") Then
               pA = Split(Data, " ", 2)
               With PacketBuf
                   .InsertDWORD &H2
                   .InsertNTString pA(1)
                   .SendPacket sckBnet, &HC
               End With
           End If
           If InStr(LCase(Data), "/rejoin") Then
               RejoinChannel
           End If
[/code]
If in the Send bar i have the words /join or /rejoin anywhere within the statement it joins whats after the /join ie "rejoin = /join the void" if i were to say that through the bot i would join the void ...Help plz?
December 27, 2002, 1:49 PM
warz
using instr to detect /commands isn't a very good idea. that'd allow you to send something like "blahblahimstupid/join whatever".
December 27, 2002, 1:52 PM
JaMi
heh well i knew that it did that :|
would something like this be a better solution then?
[code]
If txtSend.text = "/join" Then
     pA = Split(Data, " ", 2)
     With PacketBuf
    .InsertDWORD &H2
    .InsertNTString pA(1)
    .SendPacket sckBnet, &HC
     End With
 End If
[/code]
December 27, 2002, 1:57 PM
warz
No because then you'll have no channel to join. You might want to check out http://tks.slacktech.com -- there's plenty of visual basic resources there to help you.
December 27, 2002, 2:11 PM
JaMi
hrm you know if i'd though 30 seconds before posting that reply i probally would have realized that >sigh< (see what drugs do to you?) thanks anyway though :p
December 27, 2002, 2:21 PM
erase
ewwy
[code]
If LCase(Left(Txtsend.text, 6)) = "/join " Then
joinblahblahblah Mid(Message, 6, Len(Message))

ElseIf LCase(Left(Txtsend.text, 7)) = "/rejoin" Then
rejoinblahblahblah

end if
[/code]
or if you wanna spice things up a little, do Select Case instead
December 27, 2002, 4:54 PM
JaMi
Thank You  :)
December 27, 2002, 4:58 PM
Grok
This about 'short-circuiting' your code.  Check for '/' as first character before making CPU check all your commands.  If first character is not '/', no need to check for commands.  Example:

[code]
   If Left(Data, 1) = "/" Then          'search for commands
       Data = Mid(Data, 2)              'get rid of /
       Select Case True
       Case StrComp(Left(Data, 5), "join ", vbTextCompare) = 0
           'do join stuff
       Case StrComp(Left(Data, 6), "leave ", vbTextCompare) = 0
           'do leave stuff
       Case StrComp(Left(Data, 4), "say ", vbTextCompare) = 0
           'do say stuff
       Case StrComp(Data, "shutdown", vbTextCompare) = 0
           'do shutdown stuff
       Case Else
           'do something for invalid command
       End Select
   Else                                 'process it as outgoing speech
       Bot.Talk Data
   End If
[/code]

Hope this helps.
Grok
December 27, 2002, 6:24 PM
JaMi
Instead of cluttering up the board i figured id try and post next question on same string, and hope someone answers it =X, with the "ip ban" umm i need a lil help making it so it doesnt just send /ban (name) 8 times in quick succession :| when a floodbot mass rejoins :| i umm put a pause  in it but that makes my channel list back up. Heres what i have in my Event_join sub
[code]
If Icon = ICON_SQUELCH Then
Send "/ban " & strAccount & " Ip Banned"
Pause (20)
End If
[/code]  
and just incase clarification is needed on pause its
[code]
Sub Pause(hInterval As Long)
   Dim hCurrent As Long
   hInterval = hInterval * 100
   hCurrent = GetTickCount
   Do While GetTickCount - hCurrent < Val(hInterval)
       DoEvents
   Loop
End Sub
[/code]
December 30, 2002, 11:21 AM
Celica
you can always do...
[Code]
if mid(data, 1, 5) = "/join" then
[/code]
December 30, 2002, 4:02 PM
RhiNo
Use skywings anti flood algorithm so that way the bot wont flood off atleast.
December 31, 2002, 4:02 PM
Zakath
I think implementing anti-flood protection is a little beyond someone who can't yet figure out how to detect '/commands' properly, you know.

Besides, anti-flood is only essential if the bot is going to be executing lots of remotely accessed commands. I haven't bothered with it yet for ZakBot, and in fact it's extremely low on my list of new features...
December 31, 2002, 8:42 PM
Etheran
Zakath = lazy  :P
January 1, 2003, 4:21 AM
JaMi
umm well see the whole point is to keep it from flooding off when being floodbotted, when it mass rejoins the channel, and bot sees the squelched icon join channel 10 times it doesnt send /ban (name) 10 times in quick succession and flood off... i have a queue set, and i assumed it would be something as simple as lstQueue.additem "/ban " & straccount but of course that doesnt work, so someone wanna help me out plz?
January 1, 2003, 2:26 PM

Search