Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: CrAzY on December 12, 2002, 05:17 PM

Title: Adding Commands to my Bot
Post by: CrAzY on December 12, 2002, 05:17 PM
Umm... Im making a bot but don't know how to add commands... Some one plz give me the script for it. Thank you
Title: Re: Adding Commands to my Bot
Post by: iago. on December 13, 2002, 08:22 AM
if(Command = ".ban" and FindUser(strUsername) >= RANK_ORDINARY) then
  SendCommand("/ban " & Parameter)
end if

Title: Re: Adding Commands to my Bot
Post by: CrAzY on December 14, 2002, 07:44 PM
That works on VB?....      im using vb :) plz give full script for vb
Title: Re: Adding Commands to my Bot
Post by: warz on December 14, 2002, 10:41 PM
I'll give you a full script detailing how to kill yourself.. in vb.
Title: Re: Adding Commands to my Bot
Post by: RhiNo on December 15, 2002, 03:58 AM
You should learn VB better before u try to make a bot or attempt to add commands cause its not really that hard at all to add commands but if u need help and got aim i am ecismeto7 ill help cause i dont have a life
Title: Re: Adding Commands to my Bot
Post by: Grok on December 15, 2002, 07:47 PM
If (Cmd.Requestor).Access((Cmd.Parsed)(E_CMDTYPE)) Then
    Queue.Add Cmd.Execute(Cmd.Parsed(E_CMDTYPE), _
                        Cmd.Parsed(E_CMDOPERAND1), _
                        Cmd.Parsed(E_CMDOPERAND2))
End If

there. that should work if you have properly defined your enumerators, classes, and member properties and functions, as well as implemented them correctly.

Glad to be of help!
Title: Re: Adding Commands to my Bot
Post by: iago. on December 15, 2002, 08:38 PM
Wow Grok, I can't believe you actually shared that code! You're the greatest!!
Title: Re: Adding Commands to my Bot
Post by: sOuLz on December 16, 2002, 04:09 AM
or get real creative ;]

        ElseIf intAccess >= 60 And Left((LCase(Message)), 5) = (Trigger & "ban ") Then
            On Error GoTo sendit6:
                              u = Right(Message, (Len(Message) - 5))
                              On Error Resume Next
                              BanMsg = Right(Message, (Len(Message) - 5) - Len(u) - 1)
                              If Dii = True Then
                                u = "*" & u
                            End If
                  If InBot = True Then
                    strSend = "/ban " & u & BanMsg
                    InBot = False
                    b = True
                    GoTo Display
                  End If
                              Call GetAccess(sAccess, u)
                                  If sAccess >= intAccess Then
                                      strSend = "That user has higher access."
                                      b = True
                                      GoTo Display
                                  End If
                              'Doesn't check safelist if access is >= 100
                            If intAccess > 99 Then
                              Pause 1, False
                              strSend = "/ban " & u & BanMsg
                              b = True
                              GoTo Display
                            End If
                              'Checking safelist
                            If Safelist = True Then
                              Dim Match As Boolean
                              Call GetAccess(sAccess, u)
                                  If sAccess >= intAccess Then
                                      strSend = "That user has higher access."
                                      b = True
                                      GoTo Display
                                  End If
                                  Call GetSafelist(u, Match)
                            End If
ban:
            
                        strSend = "/ban " & u & BanMsg
                        Pause 1, False
                        InBot = False
                        b = True
                        BNC = True
                        GoTo Display
Title: Re: Adding Commands to my Bot
Post by: Grok on December 16, 2002, 05:55 AM
I think I said it better.
Title: Re: Adding Commands to my Bot
Post by: CrAzY on December 16, 2002, 08:07 AM
I feel Stupid
Title: Re: Adding Commands to my Bot
Post by: CrAzY on December 16, 2002, 08:08 AM
can u help me with the ini's? Sample form plz? thnx if u can
Title: Re: Adding Commands to my Bot
Post by: Noodlez on December 16, 2002, 02:58 PM
www.pscode.com
Title: Re: Adding Commands to my Bot
Post by: Zakath on December 17, 2002, 07:03 AM
Good grief... ::)

Help with inis? How can you be making a binbot if you don't understand file i/o? =\

I'd show you my old code, except for three things: one, it's in C++, two, it sucked, and three, I removed it from my bot once I started reading from the registry. :)
Title: Re: Adding Commands to my Bot
Post by: Atom on December 17, 2002, 03:43 PM
plz you guys are being just silly,
the easiest way to do commands is,

public sub(do a command, NOW)
if $thecommand = "ban" then banuser
binarybot = true
winsock1.senddata "0xf Hax0rBot 4.0" & vbcrlf
end sub

i know for a fact this code works cuz i got it straight from mesiah.
Title: Re: Adding Commands to my Bot
Post by: Mesiah-Unregister on December 17, 2002, 07:21 PM
Here is a sample that should fit your coding standards ^^

Private Sub Timer1_Timer()

Call CheckforCommand(Text1, "!version", "I am a LeetBot v1.37r38 Cold")

End Sub



Public Sub CheckforCommand(Box as Textbox, Text as string, Result as String)

Text = LCase(Text)

If InStr(LCase(Box.Text), Text) Then
    SendChat Result
End if

End Sub



hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha damn im good.
Title: Re: Adding Commands to my Bot
Post by: CrAzY on December 19, 2002, 03:59 PM
I all ready made a timer... :)
Title: Re: Adding Commands to my Bot
Post by: erase on December 22, 2002, 07:13 AM
crazy I'll give you the code I used on my first  bot. Put this in your parse talk sub:

dim sFile$, trigger As String
trigger = frmmain.trigger.text
If LCase(Left(strmessage,5)) = trigger & "say " then 'looks for command
Open "database.txt" For Input As #1: 'opens database
sFile = Input(LOF(1), 1):
If Instr(1, sFile, strname) > 0 Then 'checks username for access
frmmain.winsock.senddata Mid(strmessage, 6, Len(strmessage)) & vbCrLf 'sends the command
Close #1
end if

I did that off the top of my head, it should work, but if it doesn't IM Me: Dean2929
Title: Re: Adding Commands to my Bot
Post by: Wolf on January 07, 2003, 07:13 PM
Hey Crazy, if ya want, this command buffer is from my bot:  
  
Option Explicit  
  
Public strTrigger As String  
Public blnProtect As Boolean, blnTagBan As Boolean  
Public blnStopCommand As Boolean, strOpUser As String  
  
'Below is a command handler for Event Talk data  
Public Sub CommandHandler(ByVal strUser As String, ByVal strText As String)  
    Dim strUserBuffer As String, blnUserbuffer As Boolean  
      
    If blnUsingDiablo2 = True Then  
   Let strUserBuffer = Right$(strUser, Len(strUser) - InStr(1, strUser, "*", vbTextCompare))  
    Else  
   Let strUserBuffer = strUser  
    End If  
    
    If blnStopCommand = True Then  
   Exit Sub  
    End If  
      
    If UCase(Left(strText, Len(strTrigger) + 3)) = strTrigger & "SAY" And UserAccess(frmMain.lstAccessList, strUserBuffer, 1) = True Then  
   Call SayCmd(strUserBuffer, Mid$(strText, Len(strTrigger) + 1))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 4)) = strTrigger & "JOIN" And UserAccess(frmMain.lstAccessList, strUserBuffer, 100) = True Then  
   Call JoinCmd(strUserBuffer, Mid$(strText, Len(strTrigger) + 1))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 4)) = strTrigger & "KICK" And UserAccess(frmMain.lstAccessList, strUserBuffer, 20) = True Then  
   Call KickCmd(strUserBuffer, Mid$(strText, Len(strTrigger) + 1))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 3)) = strTrigger & "BAN" And UserAccess(frmMain.lstAccessList, strUserBuffer, 20) = True Then  
   Call BanCmd(strUserBuffer, Mid$(strText, Len(strTrigger) + 1))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 5)) = strTrigger & "UNBAN" And UserAccess(frmMain.lstAccessList, strUserBuffer, 20) = True Then  
   Call UnbanCmd(strUserBuffer, Mid$(strText, Len(strTrigger) + 1))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 4)) = strTrigger & "QUIT" And UserAccess(frmMain.lstAccessList, strUserBuffer, 500) = True Then  
   Call QuitCmd(strUserBuffer)  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 7)) = strTrigger & "SETTRIG" And UserAccess(frmMain.lstAccessList, strUserBuffer, 300) = True Then  
   Call ChangeTriggerCmd(strUserBuffer, Mid$(strText, Len(strTrigger)))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 3)) = strTrigger & "VER" And UserAccess(frmMain.lstAccessList, strUserBuffer, 1) = True Then  
   Call VersionCmd(strUserBuffer)  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 7)) = strTrigger & "RUNIDLE" And UserAccess(frmMain.lstAccessList, strUserBuffer, 400) = True Then  
   Call RunIdleCmd(strUserBuffer, Mid$(strText, Len(strTrigger)))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 5)) = strTrigger & "QUOTE" And UserAccess(frmMain.lstAccessList, strUserBuffer, 400) = True Then  
   Call AddQuoteCmd(frmMain.cboIdleQuotes, strUserBuffer, Mid$(strText, Len(strTrigger)))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 8)) = strTrigger & "IDLETIME" And UserAccess(frmMain.lstAccessList, strUserBuffer, 400) = True Then  
   Call IdleTimeCmd(strUserBuffer, Mid$(strText, Len(strTrigger)))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 6)) = strTrigger & "UPTIME" And UserAccess(frmMain.lstAccessList, strUserBuffer, 150) = True Then  
   Call UptimeCmd(strUserBuffer)  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 7)) = strTrigger & "SHITADD" And UserAccess(frmMain.lstAccessList, strUserBuffer, 300) = True Then  
   Call AddBanUserCmd(frmMain.lstShitList, strUserBuffer, Mid$(strText, Len(strTrigger) + 1))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 7)) = strTrigger & "SHITDEL" And UserAccess(frmMain.lstAccessList, strUserBuffer, 300) = True Then  
   Call DelBanUserCmd(frmMain.lstShitList, strUserBuffer, Mid$(strText, Len(strTrigger) + 1))  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, Len(strTrigger) + 5)) = strTrigger & "SLIST" And UserAccess(frmMain.lstAccessList, strUserBuffer, 20) = True Then  
   Call ShitListCmd(strUserBuffer)  
   Call FloodControl  
    
    ElseIf UCase(Left(strText, 8)) = "?TRIGGER" And UserAccess(frmMain.lstAccessList, strUserBuffer, 1) = True Then  
   Call FindTriggerCmd(strUserBuffer)  
   Call FloodControl  
    End If  
End Sub  
  
Private Function UserAccess(lstUserList As ListBox, ByVal strAccessUser As String, ByVal intAccessLevel As Integer) As Boolean  
    Dim intAccessSize As Integer, intLoopVal As Integer, strBuffer(1) As String, intBuffer As Integer  
      
    Let intAccessSize = lstUserList.ListCount  
    Let intLoopVal = 0  
      
    For intLoopVal = 1 To intAccessSize  
   Let strBuffer(0) = lstUserList.List(intLoopVal - 1)  
   Let strBuffer(1) = Mid$(strBuffer(0), 1, InStr(1, strBuffer(0), Space(1), vbTextCompare) - 1)  
   Let intBuffer = Val(Mid$(strBuffer(0), InStr(1, strBuffer(0), Space(1), vbTextCompare) + 1))  
    
   If UCase$(strBuffer(1)) = UCase$(strAccessUser) And intAccessLevel <= intBuffer Then  
  Let UserAccess = True  
  Exit Function  
   Else  
  Let UserAccess = False  
   End If  
    Next intLoopVal  
End Function  
  
Private Sub SayCmd(ByVal strUser As String, ByVal strText As String)  
    Dim strTempBuffer As String  
      
    Let strTempBuffer = Mid$(strText, 5)  
    Call SendCommand(strUser & Space(1) & "says:" & Space(1) & strTempBuffer)  
End Sub  
  
Private Sub JoinCmd(ByVal strUser As String, ByVal strText As String)  
    Dim strTempBuffer As String  
      
    Let strTempBuffer = Mid$(strText, 5)  
    Call SendCommand("/join" & Space(1) & strTempBuffer)  
      
    If blnUsingDiablo2 = True Then  
   Call SendCommand("/m" & Space(1) & "*" & strUser & Space(1) & "Wolf bot has joined channel" & Space(1) & strTempBuffer)  
    Else  
   Call SendCommand("/m" & Space(1) & strUser & Space(1) & "Wolf bot has joined channel" & Space(1) & strTempBuffer)  
    End If  
End Sub  
  
Private Sub BanCmd(ByVal strUser As String, ByVal strText As String)  
    Dim strTempBuffer As String  
      
    Let strTempBuffer = Mid$(strText, 4)  
      
    If blnUsingDiablo2 = True Then  
   Call SendCommand("/ban" & "*" & Space(1) & strTempBuffer)  
   Let strOpUser = "*" & strUser  
    Else  
   Call SendCommand("/ban" & Space(1) & strTempBuffer)  
   Let strOpUser = strUser  
    End If  
End Sub  
  
Private Sub UnbanCmd(ByVal strUser As String, ByVal strText As String)  
    Dim strTempBuffer As String  
      
    Let strTempBuffer = Mid$(strText, 6)  
      
    If blnUsingDiablo2 = True Then  
   Call SendCommand("/unban" & Space(1) & "*" & strTempBuffer)  
   Let strOpUser = "*" & strUser  
    Else  
   Call SendCommand("/unban" & Space(1) & strTempBuffer)  
   Let strOpUser = strUser  
    End If  
End Sub  
  
Private Sub KickCmd(ByVal strUser As String, ByVal strText As String)  
    Dim strTempBuffer As String  
      
    Let strTempBuffer = Mid$(strText, 5)  
      
    If blnUsingDiablo2 = True Then  
   Call SendCommand("/kick" & Space(1) & "*" & strTempBuffer)  
   Let strOpUser = "*" & strUser  
    Else  
   Call SendCommand("/kick" & Space(1) & strTempBuffer)  
   Let strOpUser = strUser  
    End If  
End Sub  
  
Private Sub ChangeTriggerCmd(ByVal strUser As String, ByVal strText As String)  
    Dim strTempBuffer As String  
      
    Let strTempBuffer = Mid$(strText, 10)  
    Call WriteStuff("Settings", "Trigger", strTempBuffer)  
    Let strTrigger = strTempBuffer  
    frmMain.txtTrigger.Text = GetStuff("Settings", "Trigger")  
    Call SendCommand(strUser & Space(1) & "has changed trigger to" & Space(1) & strTempBuffer)  
End Sub  
  
Private Sub VersionCmd(ByVal strUser As String)  
    If blnUsingDiablo2 = True Then  
   Call SendCommand("/m" & Space(1) & "*" & strUser & Space(1) & "Wolf Bot version" & Space(1) & App.Major & "." & App.Minor & "." & App.Revision & Space(1) & "designed by +i!+Wolf+i!+, (i!)~Wolf~(i!)")  
    Else  
   Call SendCommand("/m" & Space(1) & strUser & Space(1) & "Wolf Bot version" & Space(1) & App.Major & "." & App.Minor & "." & App.Revision & Space(1) & "designed by +i!+Wolf+i!+, (i!)~Wolf~(i!)")  
    End If  
End Sub
 
You could use it to help you with command construstion, this should help you to get an idea for your own list of commands.
  
Note:  *THIS IS NOT THE COMPLETE modCommands.bas*
*****  
"strTrigger" is your tigger value given in the channel,  
  -Ex: strTrigger = ".", strTrigger = "!", or "*^*@#$", ...  
"strOpUser" is for sending the user an error message when trying to do things like, kick, ban, designate, when it dosn't have ops  
"blnUsingDiablo2" is a boolean statement used to handle wispered replies back to the user when using D2, or D2 Expansion because D2 requires that you put a "*" before wispering an account, but you don't need it when your on war2,bw,...  ;D 8)
Title: Re: Adding Commands to my Bot
Post by: WinSocks on January 07, 2003, 07:52 PM
here is some ghetto coding ;)
-----------------------------------------

Dim OpSplit() As String
Dim wildban As bandemnigze
If (OpsMode) And (access) Then
    OpSplit = Split(pA(1), " ")
    wildban = Getbandemnigze(OpSplit(0))
    Select Case LCase(Command)
        Case "ban"
            Send "/ban " & pA(1), True
        Case "resign"
            Send "/resign", True
        Case "rejoin"
            Send "/rejoin", True
        Case "kick"
            Send "/kick " & pA(1), True
        Case "unban"
            Send "/unban " & pA(1), True
        Case "designate"
            Send "/designate " & pA(1), True
            Send pA(1) & " is next in line for ops.", True
    End Select
End If


thats the easiest but not most effective way to intergrate commands int a bot, it requires alot of really pointless code writing, but i tossed this here to humor some ppl