From Cyborg Anthropology
Jump to: navigation, search

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.


Loqi is built around the MediaWiki Recent Changes bot. This is a small Perl script that uses POE::Component::IRC to speak the IRC protocol.

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-iphone: I WANT A PONY
* Loqi gives tyler-iphone A PONY
tyler-iphone: yay!
* Loqi giggles
tyler-iphone: i never know if its the loqi AI or aaron
* Loqi grins profusely
caseorganic: haha - it's all loqi ai
Loqi: awesome


You can find Loqi in these channels on irc.freenode.net.

  • #geoloqi
  • #cyborganthropology
  • #microformats
  • #indiewebcamp
  • #pdxwebdev

Some fun conversations Loqi has been a part of are documented on his Tumblr account: http://loqisaur.tumblr.com

Related Reading


Originally posted on http://cyborganthropology.com/Loqi