• Welcome to Valhalla Legends Archive.
 

command help

Started by pileofcrap, February 27, 2003, 07:01 PM

Previous topic - Next topic

pileofcrap

Hey can someone GET MY STARTED (thats all) on exactly how to execute and create commands?

ILurker

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
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 "
  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

There's two good examples of commands ;)

pileofcrap

#2
WOW..... i was competly off..... thanx man ...i knew i loved these forums for a reason ;)

Banana fanna fo fanna

#3
Easier if you do this:

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

pileofcrap

#4
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?

Banana fanna fo fanna

#5
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.

pileofcrap

#6
OHHHHHHHHH OK I GET IT NOW =D

Fr0z3N

#7
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  ::)

tA-Kane

#8
Can we autolock old topics ???
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Camel

#9
QuoteIf 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  ::)
why check if it's the bot's master twice?

pile@school

#10
I was thinking the same thing. It wouldmake sense to check if they were in different moduals, but in your code it isnt.

tA-Kane

QuoteIt wouldmake sense to check if they were in different moduals, but in your code it isnt.
Better said...
QuoteIt would make sense to check for the master if they were in different modules. But in your code, it doesn't appear to be.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Grok

I'd suggest a function that verifies someone has the authority to perform a command.
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

AnThRaX

#13
QuoteI'd suggest a function that verifies someone has the authority to perform a command.

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.

Kp

#14
QuoteHey Grok, I like that function, think you could do a demonstration on the "user access" stuffs? I'm kinda having some trouble with it.

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. ;)
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!