Loqi is an IRC bot that lurks in several channels on irc.freenode.net. He is mostly a utility bot, but occasionally enjoys a bit of playful conversation.
What Loqi Does
Loqi started out as a way to alert us of recent changes in MediaWiki instances. When a UDP packet is received from a MediaWiki instance, a message is printed in the corresponding channel. This mechanism has allowed Loqi to be extended to many other purposes. I can easily send messages to Loqi from other scripts and other servers by simply sending a UDP packet. This has allowed me to use Loqi for debugging and logging of websites, as an easy way to get notifications of unusual activity in the system without checking log files.
How Loqi Works
- The MediaWiki Perl script is the core of Loqi. This is the IRC client and UDP server which listens for incoming packets and routes them to IRC.
- When a message is received in the IRC channel, the Perl script launches a PHP script using
open()and pipes the IRC line to stdin of the PHP script.
- PHP takes over reading the input from stdin. The first thing the script does is spawn a new process, thereby freeing up the Perl script that launched it. This allows the PHP script to take an indefinite amount of time to handle the message without hanging the main bot.
- With this mechanism in place, Loqi can be programmed to respond to various trigger words by writing new handlers in PHP. The response can come in a long time later, whether it's seconds or minutes, which helps make Loqi feel less like a bot and more like a real person.
What Loqi is Not
Loqi is not a chatbot like ALICE or Eliza. He will respond to various trigger words, but don't expect to have a full conversation with him. As a consequence, his responses seem less scripted, and you may not even notice he is a bot at first, such as in this exchange from #pdxwebdev:
donpdonp: i might have to just pony up the dough tyler: I WANT A PONY * Loqi gives tyler-iphone A PONY tyler: yay! * Loqi giggles tyler: i never know if its the loqi AI or aaron * Loqi grins profusely caseorganic: haha - it's all loqi ai Loqi: awesome
- !calc 12 ounces to cups - Loqi can do most any unit conversions and calculations that you can type.
- !date 1301943765 - Loqi can convert between unix timestamps and readable dates. Try giving him other date formats too.
- !dns 220.127.116.11 - Loqi can do forward and reverse DNS lookups
- !weather or !weather 97214 - Loqi can get a 2-day weather forecast for a given zipcode
- !temperature or !temperature 97214 - Loqi can get the current temperature for a given zipcode
- !digits 503-346-RIDE - Convert text to the numeric equivalent on a phone keypad
You can find Loqi in these channels on irc.freenode.net.
Some fun conversations Loqi has been a part of are documented on his Tumblr account: loqisaur.tumblr.com