Help with bot (kick doesn't work)

Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)

Moderator: Moderators

Locked
skorpion9x
Posts: 13
Joined: 2003-08-02 17:05
Contact:

Help with bot (kick doesn't work)

Post by skorpion9x » 2003-08-13 22:34

Code: Select all

    Case "kick"
      sName=sText
      If curUser.bOperator Then
        curUser.PrivateMessage CStr(sBotName), "you have used Kick on "+sName+"."
        If colUsers.Online(CStr(sName)) Then
          curUser.PrivateMessage CStr(sBotName), sName+" is online."
          sName.Kick
          curUser.PrivateMessage CStr(sBotName), sName+" has been kicked XD"
        Else 
          curUser.PrivateMessage CStr(sBotName), sName+" is NOT online. Unable to kick "+sName+"."
        End If
      Else
        curUser.PrivateMessage CStr(sBotName), "Only operators may use the kick command!"
      End If
The sName.Kick line doesn't seem to work :(. Can anyone please help me? Thanks.
--SKoRPioN9x, Thy superior.

skorpion9x
Posts: 13
Joined: 2003-08-02 17:05
Contact:

Post by skorpion9x » 2003-08-13 22:37

By the way, part of this bot has an Emote function, where you PrivateMessage "me eats shit" for example, and it says in the main chat "<+> skor9x eats shit <+>" (using my own name as an example, though i don't really eat shit :lol:). Has that been done before or anything (i'm sure it has....and probably better so). If not, I can post that part of the code here, too :)
--SKoRPioN9x, Thy superior.

skorpion9x
Posts: 13
Joined: 2003-08-02 17:05
Contact:

Post by skorpion9x » 2003-08-15 15:53

Can't anyone help me??? Anyway, since the black out (i live in CT, so i was in the dark for like 8 hours), i lost the script, and re-wrote it a little differently :

Code: Select all

Case "!kick"
      If sText="" Then
        curUser.PrivateMessage cstr(sBotName), "Who do you want to kick???"
      Else
        sName=sText
        If curUser.bOperator Then 
          curUser.PrivateMessage CStr(sBotName), "you have used Kick on "+sName+"." 
          If colUsers.Online(CStr(sName)) Then 
            curUser.PrivateMessage CStr(sBotName), sName+" is online." 
            sName.Kick 
            curUser.PrivateMessage CStr(sBotName), sName+" has been kicked XD" 
          Else 
            curUser.PrivateMessage CStr(sBotName), sName+" is NOT online. Unable to kick "+sName+"." 
          End If 
        Else 
          curUser.PrivateMessage CStr(sBotName), "Only operators may use the kick command!" 
        End If
      End If
The difference here is that this works in the main chat, so the person doesn't have to PM the bot. But it has teh same problem: the sName.Kick doesn't work...
--SKoRPioN9x, Thy superior.

skorpion9x
Posts: 13
Joined: 2003-08-02 17:05
Contact:

Post by skorpion9x » 2003-08-15 16:07

Well I figured out that it's not ".Kick" that's not working, it's the sName that's messed up. I also tried "Disconnect()" and that also doesn't work. I have included another line using sName, and that also doesn't work (the one that checks to see if the person being kicked is an Operator). Here's the whole bot's code:

Code: Select all

Dim sBotName,bPrivate,sUsers

Sub Main()
  sBotName = "DWIbot"
  bPrivate = False
  frmHub.RegisterBotName(sBotName)
End Sub

Sub DataArival (curUser, sCurData)
  If Left(sCurData,Len(sBotName)+6)="$To: "+sBotName+" " Then
    s=Mid(CStr(sCurData),InStr(CStr(sCurData),">")+2)
    If InStr(s," ")>0 Then
      sCmd=Left(s,InStr(s," ")-1)
      sText=Mid(s,InStr(s," ")+1)
    Else
      sCmd=s
    End If
    bLeaving=False
    Select Case LCase(sCmd)
    
    Case "me"
      If sText="" Then
        curUser.PrivateMessage cstr(sBotName), "You need to say more than that (example: 'me eats shit')" 
      Else
        s=curUser.sName+" "+sText 
        colUsers.SendChatToAll cstr("+"), s+" <+>"
      End If

    End Select
  
  ElseIf Left(sCurData,1)="<" Then
    s=Mid(CStr(sCurData),InStr(CStr(sCurData),">")+2)
    
    If InStr(s," ")>0 Then
      sCmd=Left(s,InStr(s," ")-1)
      sText=Mid(s,InStr(s," ")+1)
    Else
      sCmd=s
    End If
    
    Select Case LCase(sCmd)
    
    Case "!kick"
      If sText="" Then
        curUser.PrivateMessage cstr(sBotName), "Who do you want to kick???"
      Else
        sName=sText
        If curUser.bOperator Then 
          curUser.PrivateMessage CStr(sBotName), "you have used Kick on "+sName+"." 
          If colUsers.Online(CStr(sName)) Then 
            If sName.bOperator=True Then
              curUser.PrivateMessage CStr(sBotName), sName+" is an Operator. You may not boot operators >:("
            Else
              curUser.PrivateMessage CStr(sBotName), sName+" is online." 
              sName.kick
              colUsers.SendChatToAll CStr(sBotName), sName+" has been kicked by "+curUser+" XD" 
            End If
          Else 
            curUser.PrivateMessage CStr(sBotName), sName+" is NOT online. Unable to kick "+sName+"." 
          End If 
        Else 
          curUser.PrivateMessage CStr(sBotName), "Only operators may use the kick command!" 
        End If
      End If
      
    Case "!help"
      curUser.PrivateMessage cstr(sBotName), "To emote, Private Message DWIbot with a message that starts with 'me' (example: 'me eats shit'). More features will be made available soon."
    End Select
  End If
  
End Sub
--SKoRPioN9x, Thy superior.

skorpion9x
Posts: 13
Joined: 2003-08-02 17:05
Contact:

Post by skorpion9x » 2003-08-15 17:44

The kick part is now

Code: Select all

      Case "!kick"
        If sText="" Then
          curUser.PrivateMessage cstr(sBotName), "On whom would you like to cast kick???"
        Else
          sUser=cstr(sText)
          If curUser.bOperator Then 
            curUser.PrivateMessage CStr(sBotName), "Attempting to cast Kick on "+sUser+"." 
            If colUsers.Online(CStr(sUser)) Then 
              If colUsers.cstr(sUser).bOperator Then
                curUser.PrivateMessage CStr(sBotName), sUser+" is an Operator. Operators are immune to the Kick spell >:("
              Else
                curUser.PrivateMessage CStr(sBotName), sUser+" is present." 
                colUsers.cstr(sUser).kick
                colUsers.SendChatToAll CStr(sBotName), "Kick has been successfuly cast on "+sUser+" by "+curUser+" XD" 
              End If
            Else 
              curUser.PrivateMessage CStr(sBotName), sUser+" is NOT present. Spell was unsuccessful." 
            End If 
          Else 
            curUser.PrivateMessage CStr(sBotName), "You do not have enough MP to cast the Kick spell!" 
          End If
        End If
......it still doesn't work :(. Someone please help me.
--SKoRPioN9x, Thy superior.

skorpion9x
Posts: 13
Joined: 2003-08-02 17:05
Contact:

Post by skorpion9x » 2003-08-15 17:47

Why aren't there "Edit" buttons on these forums? :?

Anyway, it seems to get stuck on that colUsers.cstr(sUser).bOperator line... nothing after that happens. DWIbot only PMs "Attempting to cast kick on "+sUser to me. It doesn't say if the person who i'm trying to kick is an operator, nor does it go to the Else part. It just stops at that line.
--SKoRPioN9x, Thy superior.

skorpion9x
Posts: 13
Joined: 2003-08-02 17:05
Contact:

Post by skorpion9x » 2003-08-15 17:58

Thanks for your help, guys ¬_¬. I got it to work myself (needed "ItemByName")
--SKoRPioN9x, Thy superior.

InnerCity
Posts: 105
Joined: 2003-05-17 00:35

Post by InnerCity » 2003-08-15 18:20

use curUser.Kick()

the best help that the scripters can give you is their works
take a look at some of them

http://gadget.no-ip.info/
http://dc.ww-ei.com/index.php?&act=scripts
Hi hi hoo

skorpion9x
Posts: 13
Joined: 2003-08-02 17:05
Contact:

Post by skorpion9x » 2003-08-15 19:16

Wouldn't curuser.kick kick the person who used the !kick command?
Anyway, by looking at other works is how i figured out how to fix it; in fact, that's how i started the bot in the first place. Anyway, I have another problem on my hands now. See, I want it to PM the person being kicked when they get kicked, but that doesn't work. No matter where I put the line to PM them, if the kick is successful, they don't get the message:

Code: Select all

      Case "!kick"
        If sText="" Then
          curUser.PrivateMessage cstr(sBotName), "On whom would you like to cast kick???"
          colUsers.SendChatToAll cstr(sBotName), cstr(curUser.sName)+" has attempted to cast kick on... nobody"
        Else
          sUser=cstr(sText)
          If curUser.bOperator Then 
            curUser.PrivateMessage CStr(sBotName), "Attempting to cast Kick on "+sUser+"." 
            If colUsers.Online(CStr(sUser)) Then 
              colUsers.ItemByName(cstr(sUser)).PrivateMessage cstr(sBotName), cstr(curUser.sName)+" has attempted to cast Kick on you."
              If colUsers.ItemByName(cstr(sUser)).bOperator Then
                curUser.PrivateMessage CStr(sBotName), sUser+" is an Operator. Operators are immune to the Kick spell >:("
              Else
                curUser.PrivateMessage CStr(sBotName), sUser+" is present." 
                colUsers.ItemByName(CStr(sUser)).Kick
                colUsers.SendChatToAll cstr(sBotName), "Kick has been successfully cast on "+cstr(sUser)+" by "+curUser.sName+" XD."
                curUser.PrivateMessage CStr(sBotName), "Spell Successful"
              End If
            Else 
              curUser.PrivateMessage CStr(sBotName), sUser+" is NOT present. Spell was unsuccessful." 
            End If 
          Else 
            curUser.PrivateMessage CStr(sBotName), "You do not have enough MP to cast the Kick spell!" 
          End If
        End If
It's supposed to send the message to the person right after it finds out if they're online, happens before they actually get kicked, but it doesn't send the message. It does send the message to other operators, and myself, when someone uses it.
--SKoRPioN9x, Thy superior.

InnerCity
Posts: 105
Joined: 2003-05-17 00:35

Post by InnerCity » 2003-08-15 21:43

this is a extract of general bot, use it as model
there are some functions used that doesnt appear in this extract, but you can find this fucntions if download the general bot script

Code: Select all

Case sCmdPrefix+"kick"
   If sUser="" Then
    sA="Please give a username"
   ElseIf bIsIP(sUser) Then
    sA="Can't kick an IP number"
   ElseIf Not colUsers.Online(CStr(sUser)) Then
    sA="Can't kick because user '"+CStr(sUser)+"' is not here right now"
   ElseIf bIsOP(sUser) And bIsPowerOP(curUser.sName)=False Then
    sA="Can't kick an operator"
   Else
    sA="The user '"+CStr(sUser)+"' was kicked by "+CStr(curUser.sName)+" because: "+sInfo+". His IP was: "+CStr(colUsers.ItemByName(CStr(sUser)).IP)
    colUsers.ItemByName(CStr(sUser)).PrivateMessage CStr(sBotName),"You are being kicked because: "+sInfo
    frmHub.DoEventsForMe
    colUsers.ItemByName(CStr(sUser)).Kick
  ...
   End If
Hi hi hoo

InnerCity
Posts: 105
Joined: 2003-05-17 00:35

Post by InnerCity » 2003-08-15 21:52

may need this

Code: Select all

  End Select
  If sA<>"" Then
   If InStr(sA,"\n")>1 Then sA=Replace(sA,"\n",vbCrLf)
   If InStr(sA,"\t")>1 Then sA=Replace(sA,"\t",vbTab)
   If iSecurity=0 Then
    colUsers.SendChatToAll CStr(sBotName),CStr(sA)
   Else
    curUser.SendData CStr("<"+sBotName+" (private)> "+sA)
   End If
  End If
 End If
dont need to use sA variable and others if dont want, take only the structure model
Hi hi hoo

InnerCity
Posts: 105
Joined: 2003-05-17 00:35

Post by InnerCity » 2003-08-15 22:24

sorry, this is not the real end, anyway, try to use
colUsers.SendChatToAll CStr(sBotName),CStr(sA)
curUser.PrivateMessage CStr(sBotName),CStr(sA)

and define sA as you want
Hi hi hoo

Locked