Author | Message | Time |
---|---|---|
MichaeL | Hey, I've spent hours, adding a flagging system to my bot. I didn't code it all, I actually used User Bot by UserLoser for a reference. Here are my flags D - Designated M - Master O - Operator S - Safelisted T - Talk B - Autobanned Now I have a commands module, and to test it, i just copied the code right from the bot. I also copied the correct funtions, like, Getflags and stuff. I'm just not sure on how to run the command function [code] Public Function StartCommands(Username As String, Text As String, Optional IsWhispered As Boolean) On Error Resume Next Dim Command As String Dim Flags As String Dim User As String Dim Access As String Dim HasAccess As Boolean Dim IsBanned As Boolean Dim IsMaster As Boolean Dim IsOperator As Boolean Dim IsSafeListed As Boolean Dim CanTalk As Boolean Dim Blah() As String Blah = Split(Text, " ") Command = Blah(0) For i = 1 To FrmDatabase.Users.ListItems.Count If LCase(Username) = LCase(FrmDatabase.Users.ListItems(i).Text) Then HasAccess = True Next i If HasAccess = True Then Access = FrmDatabase.Users.FindItem(Username).Tag Else Exit Function End If If LCase(Username) = "Hunting" Then IsMaster = True If InStr(1, Access, "O") Then IsOperator = True If InStr(1, Access, "M") Then IsMaster = True If InStr(1, Access, "T") Then CanTalk = True If InStr(1, Access, "S") Then IsSafeListed = True 'T Flag If (CanTalk) Or (IsMaster) = True Then Select Case LCase(Command) Case "say" If Left(Trim(Mid(Text, 4)), 1) = "/" Then SendStuff Mid(Text, 4) Else SendStuff Trim(Mid(Text, 4)) End If Case "version" SendStuff "/w " & Username & " UserBot " & App.Major & "." & App.Minor & "." & App.Revision & " by UserLoser. www.GosuGamers.com" Case "about" SendStuff "/w " & Username & " UserBot " & App.Major & "." & App.Minor & "." & App.Revision & " by UserLoser. www.GosuGamers.com" Case "vers" SendStuff "/w " & Username & " UserBot " & App.Major & "." & App.Minor & "." & App.Revision & " by UserLoser. www.GosuGamers.com" Case "whoami" For i = 1 To FrmDatabase.Users.ListItems.Count If LCase(Username) = LCase(FrmDatabase.Users.ListItems(i).Text) Then Found = True: Exit For Next i If Found = True Then SendStuff "/w " & Username & " " & Username & " => " & FrmDatabase.Users.FindItem(Username).Tag Else SendStuff "/w " & Username & " You were not found in the database." End If Case "whois" If Len(Text) = 4 Then SendStuff "/w " & Username & " " & Username & " => " & FrmDatabase.Users.FindItem(Username).Tag End If For i = 1 To FrmDatabase.Users.ListItems.Count If LCase(Blah(1)) = LCase(FrmDatabase.Users.ListItems(i).Text) Then Found = True: Exit For Next i If Found = True Then SendStuff "/w " & Username & " " & FrmDatabase.Users.FindItem(Blah(1)).Text & " => " & UCase(GetFlags(Blah(1))) Else SendStuff "/w " & Username & " User " & Blah(1) & " was not found in the database." End If Case "find" If Len(Text) = 4 Then SendStuff "/w " & Username & " " & Username & " => " & FrmDatabase.Users.FindItem(Username).Tag End If For i = 1 To FrmDatabase.Users.ListItems.Count If LCase(Blah(1)) = LCase(FrmDatabase.Users.ListItems(i).Text) Then Found = True: Exit For Next i If Found = True Then SendStuff "/w " & Username & " " & FrmDatabase.Users.FindItem(Blah(1)).Text & " => " & UCase(GetFlags(Blah(1))) Else SendStuff "/w " & Username & " User " & Blah(1) & " was not found in the database." End If End Select End If 'O Flag If (IsOperator) Or (IsMaster) = True Then Select Case LCase(Command) Case "kick" If Blah(1) = "*" Then For i = 1 To FrmMain.listchannel.ListItems.Count If GetSafeList(FrmMain.listchannel.ListItems(i).Text) = False Then SendStuff "/kick " & FrmMain.listchannel.ListItems(i).Text End If Next i Else SendStuff "/kick " & Mid(Text, 5) End If Case "ban" If Blah(1) = "*" Then For i = 1 To FrmMain.listchannel.ListItems.Count If GetSafeList(FrmMain.listchannel.ListItems(i).Text) = False Then SendStuff "/ban " & FrmMain.listchannel.ListItems(i).Text End If Next i Else SendStuff "/ban " & Mid(Text, 4) End If Case "designate" SendStuff "/designate " & Blah(1) Case "resign" SendStuff "/resign" Case "join" SendStuff "/join " & Mid(Text, 5) Case "unban" If Blah(1) = "*" Then For i = 1 To FrmMain.Banned.ListItems.Count SendStuff "/unban " & FrmMain.Banned.ListItems(i).Text Next i Else SendStuff "/unban " & Blah(1) End If Case "leaveban" Select Case LCase(Blah(1)) Case "on" If LeaveBan = True Then SendStuff "/w " & Username & " Leaveban is already enabled." Exit Function End If LeaveBan = True LeaveBanStart = GetTickCount() SendStuff "Leaveban enabled by " & Username & "." LeaveBanStatus = "Leaveban has been enabled by " & Username & "" Case "off" If LeaveBan = False Then SendStuff "/w " & Username & " Leaveban is already disabled." Exit Function End If LeaveBan = False SendStuff "Leaveban disabled by " & Username & "." LeaveBanStatus = "Leaveban is disabled." Case "status" If LeaveBan = True Then SendStuff "/w " & Username & " Leaveban has been enabled by " & Username & "" Else SendStuff "/w " & Username & " Leaveban is disabled." End If 'sendstuff "/w " & Username & " " & LeaveBanStatus End Select Case "protect" Select Case LCase(Blah(1)) Case "on" If Protect = True Then SendStuff "/w " & Username & " Protect is already enabled." Exit Function End If Protect = True ProtectStart = GetTickCount() SendStuff "Protect enabled by " & Username & "." ProtectStatus = "protect has been enabled by " & Username & "" Case "off" If Protect = False Then SendStuff "/w " & Username & " Protect is already disabled." Exit Function End If Protect = False SendStuff "Protect disabled by " & Username & "." ProtectStatus = "Protect is disabled." Case "status" If LeaveBan = True Then SendStuff "/w " & Username & " Protect has been enabled by " & Username & "" Else SendStuff "/w " & Username & " Protect is disabled." End If End Select Case "banned" SendStuff "/w " & Username & " " & FrmMain.Banned.ListItems.Count & " users are in the ban memory." 'Case "banlookup" ' Dim BI As Integer ' Dim BU As String ' BI = frmMain.Banned.FindItem(Blah(1)).Index ' BU = frmMain.Banned.ListItems.Item(BI).Text ' ' sendstuff "/w " & Username & " " & BU & " is banned user number " & Val(BI) + 1 & "." End Select End If 'M Flag If IsMaster = True Then Select Case LCase(Command) Case "settrigger" vTrigger = LCase(Left(Blah(1), 1)) SaveINI LoadINI SendStuff "/w " & Username & " Set trigger to " & vTrigger Case "setuser" If Blah(1) = "" Then Exit Function If Blah(2) = "" Then Exit Function AddToDBC Blah(1), Blah(2) SendStuff "/w " & Username & " " & LCase(Blah(1)) & " => " & UCase(GetFlags(Blah(1))) Case "deluser" If Blah(1) = "" Then Exit Function FrmDatabase.Users.ListItems.Remove FrmDatabase.Users.FindItem(Blah(1)).Index SendStuff "/w " & Username & " Removed " & Blah(1) & " from the database" Case "quit" End End Select End If End Function [/code] Thats my commands module [code] Public Function GetFlags(Username As String) As String With FrmDatabase GetFlags = .Users.FindItem(Username).Tag End With End Function [/code] Get flags function^ [code] Public Sub AddToDBC(Username As String, Flags As String) Dim CFlags As String Dim AFlags As String Dim NFlags As String With FrmDatabase If Flags = "" Then Exit Sub Dim Found As Boolean For i = 1 To .Users.ListItems.Count If LCase(.Users.ListItems(i).Text) = LCase(Username) Then Found = True Exit For Else Found = False End If Next i If Left(Flags, 1) = "+" Then CFlags = .Users.FindItem(Username).Tag AFlags = .GetDBFlagsC(CFlags & Flags) If Found = True Then .Users.ListItems.Remove (i) .Users.ListItems.Add , , Username .Users.FindItem(Username).ListSubItems.Add , , AFlags .Users.FindItem(Username).Tag = AFlags Exit Sub Else .Users.ListItems.Add , , Username .Users.FindItem(Username).ListSubItems.Add , , AFlags .Users.FindItem(Username).Tag = AFlags End If Exit Sub ElseIf Left(Flags, 1) = "-" Then CFlags = .Users.FindItem(Username).Tag AFlags = .GetDBFlagsC(Flags) If InStr(1, CFlags, AFlags) Then NFlags = Replace(CFlags, AFlags, "") If Found = True Then .Users.ListItems.Remove (i) .Users.ListItems.Add , , Username .Users.FindItem(Username).ListSubItems.Add , , NFlags .Users.FindItem(Username).Tag = NFlags Exit Sub Else .Users.ListItems.Add , , Username .Users.FindItem(Username).ListSubItems.Add , , NFlags .Users.FindItem(Username).Tag = NFlags End If End If If Found = True Then .Users.ListItems.Remove (i) .Users.ListItems.Add , , Username .Users.ListItems(.Users.ListItems.Count).ListSubItems.Add , , .GetDBFlagsC(UCase(Flags)) .Users.ListItems(.Users.ListItems.Count).Tag = .GetDBFlagsC(UCase(Flags)) Exit Sub Else .Users.ListItems.Add , , Username .Users.ListItems(.Users.ListItems.Count).ListSubItems.Add , , .GetDBFlagsC(UCase(Flags)) .Users.ListItems(.Users.ListItems.Count).Tag = .GetDBFlagsC(UCase(Flags)) End If End With SaveDB End Sub[/code] That adds a user to the database Now how can I just run the commands function, so i can i do... <trigger>ban Username <trigger>version ect.. | September 1, 2004, 4:56 PM |
Twix | can you please use code tags | September 1, 2004, 5:10 PM |
MichaeL | ehm, not working... | September 1, 2004, 5:12 PM |
hismajesty | lower case. | September 1, 2004, 5:32 PM |
MichaeL | There sexies | September 1, 2004, 5:45 PM |
Soul Taker | So, you copy/pasted code from someone else's bot, and want us to tell you what to do with it? I have a few ideas... | September 1, 2004, 6:08 PM |
MichaeL | as i said, thats not what im using, and thats not the point, but thank you so much for your help! | September 1, 2004, 6:47 PM |
Flame | I find that it's usually easier to understand, debug, and improve code that you actually wrote. If/When you write your own command function, you're going to want to call it from the part of the BNCS 0x0F Packet called EID_TALK. If you don't know how to handle the 0x0F packet, refer to The Botdev Site, and search for an 0x0F documentation if it's still there. I'm sure there's also some information about 0x0F in the Botdev Reference Forum. The best idea would be to call the StartCommands function with the proper arguements... and if you can't figure those out then I suggest you hit the books. | September 1, 2004, 6:51 PM |
MichaeL | Nevermind. I got it, when I actually took the time to look at some stuff. Now I'm going to code my own flagging system, and commands function, thank you. | September 3, 2004, 1:46 AM |
Eli_1 | [quote author=MichaeL link=board=31;threadid=8511;start=0#msg78833 date=1094175977] Nevermind. I got it, when I actually took the time to look at some stuff. Now I'm going to code my own flagging system, and commands function, thank you. [/quote] Oh, oh! Don't use InStr() when you do it! | September 3, 2004, 5:22 AM |
UserLoser. | Please don't say it's by me, that's not my bot. Although, in the past there was a time where i was helping someone with something, and my name was on it. But the name UserBot doesn't seem to be right | September 3, 2004, 9:03 PM |
Networks | [quote author=UserLoser. link=board=31;threadid=8511;start=0#msg78922 date=1094245438] Please don't say it's by me, that's not my bot. Although, in the past there was a time where i was helping someone with something, and my name was on it. But the name UserBot doesn't seem to be right [/quote] hm I always thought that was your bot.. | September 3, 2004, 10:52 PM |
UserLoser. | [quote author=Networks link=board=31;threadid=8511;start=0#msg78937 date=1094251943] [quote author=UserLoser. link=board=31;threadid=8511;start=0#msg78922 date=1094245438] Please don't say it's by me, that's not my bot. Although, in the past there was a time where i was helping someone with something, and my name was on it. But the name UserBot doesn't seem to be right [/quote] hm I always thought that was your bot.. [/quote] You'll know if it's mine if I sent it to you over MSN or AIM. The story is something like: this kid annoyed me, so I finally helped him a lot. He thought I 'worked' or 'developed' the whole bot with him, so my name was on there. IIRC, I also wrote a readme which comes with it (wherever that may be at) since I used it, and other people at that time wanted to use it (for whatever reason). I don't release source code to my projects at all (although a few times I tend to spam some functions here and there [people from what channels I hang out in may agree :p]) | September 4, 2004, 12:04 AM |
LivedKrad | Well at first you admitted to us that it was indeed not your function. Yet immediately after the posting of this function that you did not make, you said "That is my commands function." And to top it all off, you got sarcastic towards the person who pointed out that you did not code it believing that you were righteous in first saying the it wasn't yours but then going completely hypocritical? Hehe, I like your style. | September 12, 2004, 6:05 AM |
Grok | I don't understand this snippet: [code] Select Case LCase(Command) Case "say" If Left(Trim(Mid(Text, 4)), 1) = "/" Then SendStuff Mid(Text, 4) Else SendStuff Trim(Mid(Text, 4)) End If [/code] If the 4th character is a /, send the line starting at character 4, without trimming. If not, trim the line starting at character 4, then send it. Two things: 1. What is the purpose? It will say everything except the ending spaces. 2. People are probably going to put a space after "say", so starting at character 5 is better. | September 12, 2004, 1:52 PM |