• Welcome to Valhalla Legends Archive.
 

Commands

Started by David, March 23, 2004, 11:14 AM

Previous topic - Next topic

David

I just started programming and im getting the basics down with my bot, im using (CSB) and im not getting the whole commands concept down, any help or examples or anything would be nice

           - David / JeLLo @ USWest
           - Inside @ USEast
Quote from: l]ante on March 15, 2004, 11:40 AM
You learned 8 languages in 8 months?
Geez, go code a life.

SNiFFeR

#1
I would recommend implementing the commands on the ontalk sub. Have it check your database, if it finds the user (create a sub), goto the command sub. If it doesn't find the user, exit sub.

Eli_1

#2
As someone allready said, it would go in your CSB_OnTalk or UserTalk event, whichever it is...

Anyway, you would first check to see if the leftmost amount of the data is your trigger.

e.g.:

if left(lcase(message), len(trigger)) = trigger and len(message) > len(trigger) then
   message = right(message, len(message) - len(trigger)
end if

That would check to see if for, example, the left 2 characters of the string is your trigger (1!).

if so -- remove those chars.
if not - well, don't do anything.

then you would check to see if the user is trying to run a command, which can be done many ways, but the easiest seems to be:


if left(message, 4) = "say " and len(message) > 4 then
   CSB.send right(message, len(message) - len(trigger) - 4)
elseif ...
elseif ...
end if

ect....


Btw, the "and len(message) > 4 then" is to stop the user from typing something like this:
Quote
"1!say "
Which would make your bot send nothing...

Also you would need to see if the user has access to your bot, which again can be done many ways.