• Welcome to Valhalla Legends Archive.
 

Adding Commands to my Bot

Started by CrAzY, December 12, 2002, 05:17 PM

Previous topic - Next topic

CrAzY

#15
I all ready made a timer... :)
CrAzY

erase

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

Wolf

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)
Seen as +i!+Wolf+i!+, (i!)~Wolf~(i!)

WinSocks

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