class yourclass extends ziggi
If your class extends ziggi, what you'll ultimately gain are methods that control some of botzilla. Ziggis have free reign to do whatever you make them do, but there are two guiding pricipals that you should follow to make a good plugin (for the repo; on your own, you can do whatever you want):
- ziggis shouldn't require anything more from botzilla that it doesn't already give.
- ziggis should not be dependent on other ziggis for their basic function. Using other common classes outside of botzilla is fine (but might not get published on this site)
function parseBuffer() {}
Whatever your class does could queue up and send messages to channels or nicknames, or queue up or cancel a timed event. All you need to do is use the methods inherited from ziggi, the rest should take care of itself.
Whenever botzilla "hears" something, it will call parseBuffer() on your class, so you'll want to write your own business code there.
say something
- void pm($what [,$at_who]) // will recurse on arrays
The method to have botzilla speak.
Getting stuff from the buffer
- string getArg($index)
- probably the most common. If you're listening for 'dot commands', getArg(0) is that first word.
user said : ".doSomething foo bar baz"
getArg(0) == '.doSomething'
getArg(1) == 'foo' // etc
- probably the most common. If you're listening for 'dot commands', getArg(0) is that first word.
- array getArgs() // return the args array
- string getText() // returns the user input, or piped in text if present
- string getInput() // returns the user input, avoids the piped in
user said : "lol, awesome".
getText() == "lol, awesome"
- string getArgText() // returns the user input minus the command word
user said : ".doSomething foo bar baz".
getArgText() == "foo bar baz"
- string getUser()
["username"]=>
string(7) "bibuntu"
- string getUserHost()
["user_host"]=>
string(51) "bibuntu!n=bibby@c-65-96-127-253.hsd1.ma.comcast.net"
- string getHostName()
["hostname"]=>
string(35) "c-65-96-127-253.hsd1.ma.comcast.net"
- string getIdent()
["ident"]=>
string(7) "n=bibby"
- string getOrigin()
["channel"]=>
string(3) "#bz"
- string getCommand() // IRC command.
PRIVMSG, MODE, JOIN, KICK, QUIT, etc
These aren't "controls", but things heard in the channel. This allows your class to respond to kicks, or auto-op on join, etc)["command"]=>
string(7) "PRIVMSG"
Events
- mixed getEvent()
If a timed event is sent, it is picked up separately from the normal buffer parsing. Still use it in parseBuffer() though. - int addTimedEvent($what,$timeTilNext)
$what can be any data structure. Check for this handle when using getEvent(). - void clearTimedEvent($index)
Give the index received from addEvent
basic example
Here's a little ziggi that gives back some server info, and also your name.