Skip to Content
IRC Hacks
book

IRC Hacks

by Paul Mutton
July 2004
Intermediate to advanced
432 pages
11h 15m
English
O'Reilly Media, Inc.
Content preview from IRC Hacks

Chapter 6. Logging Bots

Introduction: Hacks #40-43

Logging is a natural function for bots and clients alike. Many IRC clients offer the ability to append messages to log files, and it is trivial to add such features to a bot. The secret of effective logging is to work out what you want to log and how people can access the information. This provides some quite creative ideas that go beyond the simple task of merely logging every message to a file.

A bot that monitors all messages sent to a channel is effectively monitoring the activity of all users in that channel. By providing an interface that lets people talk to the bot, you can let them find out when a particular user was last seen and what that user said in the channel. This chapter shows you how to implement such a bot using the PircBot package covered in Chapter 5.

It is perhaps surprising to learn that bots can even be written in shell scripts. This chapter shows you how to write a basic bot that uses bash to connect to IRC and log all URLs that it sees. Another bot written in Java can tell you what people were talking about before you joined a channel, so you will never feel as if you’ve blindly wandered into the middle of a conversation.

A more complicated example uses a Java bot to run a group blog, logging URLs to a MySQL database. A web-based frontend then lets people view the logged URLs.

Keep Tabs on People

Keep track of when visitors to a channel last spoke and what they said.

People aren’t always online and, even if ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Wireless Hacks

Wireless Hacks

Rob Flickenger
The Spotify Play

The Spotify Play

Sven Carlsson, Jonas Leijonhufvud

Publisher Resources

ISBN: 059600687XErrata Page