Author | Message | Time |
---|---|---|
pileofcrap | Hey can someone GET MY STARTED (thats all) on exactly how to execute and create commands? | February 28, 2003, 1:01 AM |
ILurker | [code] Private Sub CleanSlateBot1_UserTalk(ByVal username As String, ByVal flags As Long, ByVal message As String, ByVal Ping As Long, SimulatedEvent As Boolean) If username = setupform.botmaster.text then If message = setupform.bottrigger.text & "CommandHere" then cleanslatebot1.send "Command Action" end if end if [/code] 5 represents the number of characters in the command, including the trigger, and space after the command. So it basically represents that there is 5 characters in the command. "!SAY " [code] If Left((LCase(message)), 5) = (setupform.bottrigger.text & "say") Then dim saymessage as string saymessage = Right(message, (Len(message) - 5)) cleanslatebot1.send saymessage end if [/code] There's two good examples of commands ;) | February 28, 2003, 1:10 AM |
pileofcrap | WOW..... i was competly off..... thanx man ...i knew i loved these forums for a reason ;) | February 28, 2003, 1:19 AM |
St0rm.iD | Easier if you do this: [code] dim trigger as string 'bot trigger public sub onTextReceived(user as string, text as string) Dim cmd as string Dim args as string cmd = left(text,instr(text," ")-1) 'get the first word args = right(text, len(text) - instr(text," ") - 1) 'get the rest of the line if left(text,len(trigger)) <> lcase(trigger) then exit sub 'if it doesn't start with the trigger, quit text = right(len(text)-len(trigger)) select case cmd case "say" doSayCommand user, args end select end sub sub doSayCommand(user as string, args as string) botsay " " & user & " says " & chr(34) & args & chr(34) end sub [/code] | February 28, 2003, 7:05 PM |
pileofcrap | Ok kickass ........ they both make sense. How do I make commands that, like, read profiles, ping and shit like that? can I take the examples you guys have given me and implement them into what I need? | February 28, 2003, 7:49 PM |
St0rm.iD | Yeah, see the Select Case cmd? Add a Case for the command word, then call the subroutine. In the subroutine, put all the code you should execute for that command. | February 28, 2003, 8:52 PM |
pileofcrap | OHHHHHHHHH OK I GET IT NOW =D | February 28, 2003, 11:44 PM |
Fr0z3N | If username = setupform.botmaster.text then If message = setupform.bottrigger.text & "master" then cleanslatebot1.send setupform.botmaster.text end if end if If username = setupform.botmaster.text then If message = "?trigger" then cleanslatebot1.send setupform.bottrigger.text end if end if keke very common commands brought to you by Fr0z3N who is to lazy to login ::) | March 9, 2003, 4:02 PM |
tA-Kane | Can we autolock old topics ??? | March 9, 2003, 6:25 PM |
Camel | [quote]If username = setupform.botmaster.text then If message = setupform.bottrigger.text & "master" then cleanslatebot1.send setupform.botmaster.text end if end if If username = setupform.botmaster.text then If message = "?trigger" then cleanslatebot1.send setupform.bottrigger.text end if end if keke very common commands brought to you by Fr0z3N who is to lazy to login ::)[/quote] why check if it's the bot's master twice? | March 9, 2003, 6:27 PM |
pile@school | I was thinking the same thing. It wouldmake sense to check if they were in different moduals, but in your code it isnt. | March 10, 2003, 8:09 PM |
tA-Kane | [quote]It wouldmake sense to check if they were in different moduals, but in your code it isnt.[/quote] Better said... [QUOTE]It would make sense to check for the master if they were in different modules. But in your code, it doesn't appear to be.[/QUOTE] | March 11, 2003, 11:26 AM |
Grok | I'd suggest a function that verifies someone has the authority to perform a command. [code] Public Sub ProcessSingleCommand(ByVal Command As ENUM_COMMANDS, ByVal Performer As String) If IsPermitted(Command, Performer) = False Then Exit Sub 'do whatever it is Select Case Command Case CMD_BAN: 'do ban Case CMD_KICK 'do kick Case CMD_WHATEVER 'do whatever End Select End Sub Public Function IsPermitted(ByVal Command As ENUM_COMMANDS, ByVal UserName As String) As Boolean IsPermitted = False 'default to false 'get user rights from database (or user level) 'check command against user rights 'set to true if user's permission allows this command End Sub [/code] | March 11, 2003, 12:58 PM |
AnThRaX | [quote]I'd suggest a function that verifies someone has the authority to perform a command. [/quote] Hey Grok, I like that function, think you could do a demonstration on the "user access" stuffs? I'm kinda having some trouble with it. | March 12, 2003, 3:22 AM |
Kp | [quote]Hey Grok, I like that function, think you could do a demonstration on the "user access" stuffs? I'm kinda having some trouble with it.[/quote] Its implementation is going to depend on whether you use flags-based access control or level based access control. If you use flags control, then such a function would call a QueryUserFlags function, mask the result with the flags required for the command, and return true on nonzero or false on zero. If you prefer a level based access, then you should look up the user's level, and return true if it meets or exceeds the level required for the command. Storing what flag/level a command requires is both language and programmer dependent (there are several ways to do it in most languages, depending on speed/space requirements), so I'll leave that to you to decide. Also notice that again the hard work has been passed off to an undescribed subroutine. ;) | March 12, 2003, 3:48 AM |
AnThRaX | Well I am definetly going to be using a flags system, access levels with numbers from 1-100 kinda suck in my opinion but anyways, thanks for the info and everyone else feel free to add to what Kp said or give some other ideas! | March 12, 2003, 4:20 AM |
Grok | [quote] Hey Grok, I like that function, think you could do a demonstration on the "user access" stuffs? I'm kinda having some trouble with it.[/quote] [quote] Also notice that again the hard work has been passed off to an undescribed subroutine. ;)[/quote] Very undescribed. My purpose was to suggest a clean and layered way to handle permissions checking. Too often I see code (including in this thread) where large if-then or select-case structures exist for comparing commands to access levels or flags. My way offloads the labor into a function which can end up looking very pretty if done right, and would be implementation-specific. Someone else could simply replace IsPermitted() function with a new implementation, and just drop it into the bot. | March 12, 2003, 5:27 PM |
Kp | [quote]Very undescribed. My purpose was to suggest a clean and layered way to handle permissions checking. Too often I see code (including in this thread) where large if-then or select-case structures exist for comparing commands to access levels or flags. My way offloads the labor into a function which can end up looking very pretty if done right, and would be implementation-specific. Someone else could simply replace IsPermitted() function with a new implementation, and just drop it into the bot.[/quote] It's still entirely possible for this subroutine to be very clean. My preferred implementation would be to have an array of bitmasks, indexed by the command's ID. If the bitmask logical ANDed with the user's current flags yields nonzero, the command is permitted. Nicely compact, and quite clean. | March 12, 2003, 5:39 PM |
AnThRaX | Alright, I think I understand now, I'll try some stuff and see if I can get it to work. If I do, I'll post code to a fully working "commands" function with reading accesses and such if it's ok with the creators/writers of the above codes. Thanks guys! Also, I'm wanting some tests done on my bot for stability and such... If anyone here can do that for me and check for bad coding (not source code but just simple errors in the program) then please contact me at anthrax@seedsofinsanity.com Thanks again! | March 12, 2003, 6:38 PM |
pile@school | Im not going to use the 1-100 thing. I would prefer Character not Numeral system. I guess like Ultimate Bot. | March 12, 2003, 7:02 PM |
Grok | [quote]Alright, I think I understand now, I'll try some stuff and see if I can get it to work. If I do, I'll post code to a fully working "commands" function with reading accesses and such if it's ok with the creators/writers of the above codes. Thanks guys![/quote] Of course it's OK. Any source code posted on this forum is admitted into public domain by EULA. | March 12, 2003, 11:23 PM |