• Welcome to Valhalla Legends Archive.
 

Command Bug

Started by JaMi, December 27, 2002, 07:49 AM

Previous topic - Next topic

JaMi

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

warz

#1
using instr to detect /commands isn't a very good idea. that'd allow you to send something like "blahblahimstupid/join whatever".

JaMi

#2
heh well i knew that it did that :|
would something like this be a better solution then?
If txtSend.text = "/join" Then
      pA = Split(Data, " ", 2)
      With PacketBuf
     .InsertDWORD &H2
     .InsertNTString pA(1)
     .SendPacket sckBnet, &HC
      End With
  End If

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.

JaMi

#4
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

erase

#5
ewwy
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
or if you wanna spice things up a little, do Select Case instead

JaMi

#6
Thank You  :)

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:

   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

Hope this helps.
Grok

JaMi

#8
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
If Icon = ICON_SQUELCH Then
Send "/ban " & strAccount & " Ip Banned"
Pause (20)
End If
 
and just incase clarification is needed on pause its
Sub Pause(hInterval As Long)
    Dim hCurrent As Long
    hInterval = hInterval * 100
    hCurrent = GetTickCount
    Do While GetTickCount - hCurrent < Val(hInterval)
        DoEvents
    Loop
End Sub

Celica

#9
you can always do...
if mid(data, 1, 5) = "/join" then

RhiNo

#10
Use skywings anti flood algorithm so that way the bot wont flood off atleast.

Zakath

#11
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...
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

Etheran

#12
Zakath = lazy  :P

JaMi

#13
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?