Simple IRC bot for D&D and some various minor things.
- Configure the connection details etc. from main.py & git.py according to your needs
- Run LegatoBot.py
- Python 2.7/3.5.1
You probably only need to write handlers or pumis.
If you want to create a new handler, check out handlers/example.py The best way to create a new handler is to copy example.py to "my_own_handler.py" and start from there.
- function
canHandle(self, msg)
must return True if handler can handle the response, in that case handling is dedicated to this handler and other handlers won't be executed. - function
handle(self, msg, resp)
is where the fun part is stored. This function is dedicated to actually handling user input and outputing response withresp.send("your message here")
orresp.sendCommand("your command here")
, you can addsg.re()
to parameters if you want the bot to respond to the correct channel, othervise it will respond tobrain.channel
If you want your handler to have higher priority, you can set it to have a higher priority property.
Pumis are regularly executed tasks, executing each interval
seconds until the pumi dies (isLithoku() return true
).
talk(self, resp)
is the only important function where all the handling should be implemented. A pumi is free to change it's interval or lithoku anytime it wishes, just be careful not to spam the server every second with your boring bloging!
Please check out pumis/example.py for a fast dying pumi example.
talk()
is executed before isLithoku()
, therefore each Pumi has a chance to say at least something before death.
talk()
for the first time is called only after interval
of seconds, so that pumis wouldn't spam the tread.
Since testing pumis by simply running LegatoBot is time consuming, a helper file was created. Here's how to use it:
- open your python console
import pumiTest
import pumis.your_pumi_name
p = pumis.your_pumi_name.Pumi(pumiTest.brain)
p.talk(pumiTest.r)
p
is your pumi, you can check variables of your pumi by typeing p.variable_name
, i.e. p.interval
or p.isLithoku()
.
You can execute p.talk(pumiTest.r)
multiple times if necessary.