I have made a few simple example PircBot bots based upon some of the common questions that get asked.
They are targetted at other PircBot developers as examples and starting points. The source code is provided which can be compiled and run as it is. Each example comes with a properties config file - both for easy configuration and also as an example itself on one possible way to make the bots configurable. You will need to download the PircBot API if you don't have it already. These examples were compiled against PircBot 1.4.4. The ChatBackBot also requires the JMegaHal library
Feel free to makes comments or even requests for other examples in the forums - just don't expect bots to be written for you upon request (unless you want to open your wallet :D ).
So, this is what is available so far ...
Simple PircBot bot to demonstrate how to authenticate with it so that only an authed user can use certain commands.
This shows a very simple way to allow one user to be considered controller of the bot. It also doesn't bother tracking name changes or quits, etc.
Run the bot and type "!public", anyone can type this and it will respond. Also try "!controller". Nothing will happen when you first type that. Now you will auth with the bot by sending it a private message "auth letmein". Try "!controller" now.
Simple PircBot bot to demonstrate how to authenticate with a network service.
The authentication settings are in the pbdemo_auth.properties file. Here are some example settings for various networks ...
nickserv (eg: Freenode)
authbot = nickserv
authmessage = identify password
authserv (eg: GameSurge)
authbot = authserv
authmessage = auth botname password
maskhost = MODE botname +x
authbot = Q@CServe.quakenet.org
authmessage = AUTH botname password
maskhost = MODE botname +x
Simple PircBot bot to demonstrate how to use the JMegaHal package to create a bot that will randomly chat back when its name is used.
It will only learn from messages that do not have its name in.
Run the bot and type its name in the channel to see it respond.
Simple PircBot bot to demonstrate how to use the Colors class.
Run the bot and type "show" in the channel to see the output.
A simple PircBot bot to show a quick and easy way to add multiple commands to a bot. This allows the main bot class to stay clutter free and each command has a private space to store information.
Run the bot and type "!time" in the channel to see the output. Then "!quit" to run the other supplied command which will stop the bot.
Simple PircBot bot to set your own internal bot name, whois info, etc.
Run the bot and look at:
- whois info (host mask and version info)
- CTCP version
- CTCP finger
Simple PircBot bot to demonstrate how to use the DCC features.
Run the bot and type "!chat" in the channel to get the bot to request a DCC chat session with you. Type "!send" to get it to send you the pbdemo.properties file.
Start a DCC chat with the bot and it will accept and reply.
DCC send a file to the bot and it will accept the file.
Simple PircBot bot to demonstrate how to get the host mask of a user. This also shows a way to keep track of where the whois was made from and which user the info was asked for so that appropriate action can be taken later on (when whois is received).
Run the bot and type "!hostmask user" where user is the nick of any user on the network. When the response is received a message will be sent to the channel.
Simple PircBot bot to demonstrate how to get your nick back.
This example uses the Timer and TimerTask classes and sends a WHOIS to watch for certain returned information.
Run some client with a nick. Configure this bot to use the same nick and start it. It will join with the wanted nick plus a number after it. Then quit the client so that the nick becomes available and within 30 seconds this bot will take the nick that was wanted in the first place.
Simple PircBot bot to demonstrate how to run things in a Thread from the bot.
Run the bot and type "!start" in the channel to see the output coming from the thread. Type "!stop" to tell the thread to stop it's current activity.
Simple PircBot bot to demonstrate a simple way to throttle user input.
Run the bot and repeatadly type "!throttleme" in the channel. You will be given a response but then blocked if going too fast.
Simple PircBot bot to demonstrate how to create a Timed message.
This example uses the Timer and TimerTask classes.
Run the bot and wait to see the timed messages appear.
The source code and properties file(s) for all demos are available from the Downloads section.