Cover image for IRC Hacks

Book description

IRC (Internet Relay Chat) may very well turn out to be the world's most successful hack. In 1988, Jarkko Oikarinen wrote the original IRC program at the University of Oulu, Finland. As he says in his foreword, "IRC started as one summer trainee's programming exercise. A hack grew into a software development project that hundreds of people participated in, and then became a worldwide environment where tens of thousands of people now spend time with each other. I have found many of my friends through IRC and learnt a significant part of my present software engineering knowledge while using and working with IRC. That would not have been possible without learning from code examples and hacks from others". IRC has continued to grow in popularity since its inception. Millions of people from all over the world now use IRC to chat with friends, discuss projects and collaborate on research. With a simple, clearly defined protocol, IRC has become one of the most accessible chat environments, with clients written for a multitude of operating systems. And IRC is more than just a simple chat system it is a network of intercommunicating servers, allowing thousands of clients to connect from anywhere in the world using the IRC protocol. While IRC is easy to get into and many people are happy to use it without being aware of what's happening under the hood, there are those who hunger for more knowledge, and this book is for them. IRC Hacks is a collection of tips and tools that cover just about everything needed to become a true IRC master, featuring contributions from some of the most renowned IRC hackers, many of whom collaborated on IRC, grouping together to form the channel #irchacks on the freenode IRC network (irc.freenode.net). Like all of our Hacks books, there are many different ways to use IRC Hacks. You can read the book from cover to cover, but you might be better served by picking an interesting item from the table of contents and just diving in. If you're relatively new to IRC, you should considering starting with a few hacks from each progressive chapter. Chapter 1 starts you off by showing you how to connect to IRC, while Chapter 2 acquaints you with the everyday concepts you'll need to use IRC effectively. Chapter 3 is all about users and channels, and introduces the first pieces of code. Chapter 4 shows you how to make useful enhancements to IRC clients. Chapter 5 is where you will learn the basics about creating IRC bots, with Chapters 6-12 introducing more complex bots that can be used for logging, servicing communities, searching, announcing, networking, managing channels or simply for having fun. Chapter 13 delves into the IRC protocol in more detail, and Chapter 14 demonstrates some interesting alternative methods for connecting to IRC. Finally, Chapter 15 will move you on to new pastures by showing you how to set up your own IRC server. This book presents an opportunity to learn how IRC works and how to make best use of some of the features that have made it the most successful, most scalable, and most mature chat system on this planet. IRC Hacks delves deep into the possibilities.

Table of Contents

  1. IRC Hacks
  2. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  3. Foreword
  4. Credits
    1. About the Author
    2. Contributors
    3. Acknowledgments
  5. Preface
    1. Why IRC Hacks?
    2. How to Use This Book
    3. How This Book Is Organized
    4. Conventions Used in this Book
    5. Using Code Examples
    6. How to Contact Us
    7. Got a Hack?
  6. 1. Connecting to IRC
    1. Introduction: Hacks #1-4
    2. Hack #1. IRC from Windows
    3. Hack #2. IRC from Linux
      1. Nicknames, Usernames, and Real Names
      2. Server Configuration
      3. Advanced Options and Autoconnects
      4. Setting Up Autologin
      5. Selecting a Stable Server
      6. Different Nicknames on Different Networks
      7. Setting Up the User Interface
        1. Interface/Text Box
        2. Chatting/General
        3. Logging
        4. Network/Setup
      8. Hacking XChat
        1. Tab in a window
        2. Per-channel options
        3. All-server commands
        4. Use colors
        5. Display output with /exec
        6. Setting up auto-replace strings
        7. Setting up user commands
        8. Customize messages/colors and set sounds
        9. Add user list buttons and menu commands
        10. Add CTCP replies
    4. Hack #3. IRC from Mac OS X
      1. Conversation
      2. X-Chat Aqua
      3. Snak
      4. IRCle
    5. Hack #4. IRC with ChatZilla
      1. Installing ChatZilla
      2. Using ChatZilla
      3. See Also
  7. 2. Using IRC
    1. Introduction: Hacks #5-11
    2. Hack #5. The IRC Model
      1. Network of Servers
      2. Clients
      3. Channels
      4. Operators
      5. Channel Operators
    3. Hack #6. Common Terms, Abbreviations, and Phrases
      1. Noun-Verb Duality
      2. Leet Speak
      3. Correction Syntax
      4. Phonetics and Keyboard Layouts
    4. Hack #7. Common Acronyms and Initialisms
    5. Hack #8. Register with NickServ
      1. Registering Yourself with NickServ
      2. Fixing Nick Collisions
      3. Changing Nicknames
    6. Hack #9. Register Your Channel with ChanServ
      1. Introducing ChanServ
      2. Registering a Channel
      3. Restoring Channel Operators
      4. Access Lists
      5. Adding Users to the Access List
      6. Other ChanServ Features
    7. Hack #10. The QuakeNet L Channel Bot
      1. Create an Account
      2. Getting L
      3. Setting Up L for Your Channel
    8. Hack #11. Fix Channel Problems with CHANFIX
      1. Channel Monitoring
      2. Automatic CHANFIX
      3. Manual CHANFIX
      4. Interesting CHANFIX Facts
      5. See Also
  8. 3. Users and Channels
    1. Introduction: Hacks #12-16
    2. Hack #12. Find Relevant Channels and Servers
      1. Finding Help on IRC
      2. Other Interesting Statistics
    3. Hack #13. Guess the Time Zone of a User
    4. Hack #14. Study Channel Statistics with pisg
      1. Running pisg
        1. Editing pisg.cfg
      2. Publishing pisg Statistics
        1. Setting up statistics options
        2. Nickname tracking
        3. User lines
        4. Photos and photo galleries
        5. Headers and footers
      3. The Results
    5. Hack #15. Find Users in Channels
      1. Nick Seeking
      2. Advanced Search
      3. A Strategy for Finding Users
      4. The Code
        1. Finding users with Net::IRC
        2. irssi
        3. PircBot
    6. Hack #16. Filter Channel Lists
      1. The Code
      2. Running the Hack
      3. Hacking the Hack
  9. 4. Enhancing IRC Clients
    1. Introduction: Hacks #17-30
    2. Hack #17. Automatic Completion of Nicknames
      1. mIRC
      2. irssi
      3. XChat
      4. ChatZilla
      5. BitchX
    3. Hack #18. Add Timestamps to mIRC Messages
      1. Adding Simple Timestamps
      2. Hacking the Timestamp
    4. Hack #19. Highlight Lines in mIRC
      1. Highlight Your Own Messages
      2. Highlight Messages from Other People
      3. Highlight Messages Containing Keywords
    5. Hack #20. Automate mIRC with Scripting
      1. Opening the Scripts Editor
      2. Making a Bad Word Banner
        1. alias
        2. set
        3. while
        4. if
        5. return
        6. inc
      3. Putting It All Together
        1. on TEXT
        2. if
        3. mode
        4. kick
      4. Running the Hack
    6. Hack #21. Format Text
      1. Formatting Text in mIRC
        1. Bold
        2. Underline
        3. Italic or reversed
        4. Normal
      2. Formatting Text with a Bot
        1. Bold
        2. Underline
        3. Italic or reversed
        4. Normal
      3. Formatting Text with PircBot
    7. Hack #22. Colorize Text
      1. Using Colors in mIRC
      2. Backgrounds
      3. Problems with Coloring Numbers
      4. Sending Colors from Bots
      5. Sending Colors from PircBot
    8. Hack #23. Play Sounds
      1. Enabling Sound Requests
      2. Adding Sounds to mIRC
      3. Sending Sound Requests
      4. Requesting Sounds
      5. Agents
    9. Hack #24. Enhance irssi with Perl
      1. Using an irssi Script
      2. See What Film Everyone’s Watching
      3. Who’s Behind That Nick?
      4. Strange Dialects
      5. Automatically Get Ops When the Channel Is Empty
      6. Keep Everyone Amused When You’re Away
      7. What Was That Query About Again?
      8. Other Interesting Scripts
      9. The Code
    10. Hack #25. Connect to Multiple Servers
      1. mIRC
      2. XChat
      3. irssi
    11. Hack #26. Secure Your IRC Connection with SSL
      1. Securing Your IRC Connection with mIRC
      2. Securing Your IRC Connection with XChat
      3. Securing Your IRC Connection with irssi
      4. Securing Your IRC Connection with stunnel
    12. Hack #27. Tunnel Your IRC Connection with SSH
      1. Setting Up an SSH Tunnel with OpenSSH
      2. Setting Up an SSH Tunnel with PuTTY
      3. Allowing Third Parties to Bypass the Firewall
    13. Hack #28. Automate Voice Management
      1. The Code
      2. Running the Hack
      3. Hacking the Hack
    14. Hack #29. Make IRC Talk
      1. The Code
      2. Running the Hack
      3. Hacking the Hack
    15. Hack #30. Add Your IRC Nickname to Your Webcam
      1. Writing Your Nickname to a File
      2. Displaying File Contents in Dorgem
      3. The Results
  10. 5. Writing IRC Bots
    1. Introduction: Hacks #31-39
    2. Hack #31. IRC Over Telnet
      1. Staying Alive
      2. Joining Channels and Sending Messages
    3. Hack #32. A Simple Perl IRC Client
      1. The Code
      2. Running the Hack
      3. The Results
    4. Hack #33. IRC with Perl and Net::IRC
      1. Preparations
      2. The Code
      3. Running the Hack
      4. The Results
    5. Hack #34. A Simple Java IRC Client
      1. The Code
      2. Running the Hack
      3. Results
    6. Hack #35. IRC with Java and PircBot
      1. Event-Driven Framework
      2. Running the Hack
      3. Hacking the Hack
    7. Hack #36. A Simple Python IRC Client
      1. The Code
      2. Running the Hack
    8. Hack #37. IRC with Python and IRCLib
      1. The Code
      2. Event Handlers
      3. Learning More About IRCLib
    9. Hack #38. Extend the Python IRCLib
      1. The Code
      2. Loading Your Extensions
      3. Built-in Extensions
    10. Hack #39. The Ethics of IRC Bots
  11. 6. Logging Bots
    1. Introduction: Hacks #40-43
    2. Hack #40. Keep Tabs on People
      1. !seen
      2. The Code
      3. Running the Hack
      4. Hacking the Hack
    3. Hack #41. Log URLs People Mention
      1. The Code
      2. Running the Hack
      3. Hacking the Hack
    4. Hack #42. Blog from IRC
      1. The Code
      2. Running the Hack
      3. The Results
    5. Hack #43. A Continuity Bot
      1. The Code
      2. Running the Hack
  12. 7. Community Bots
    1. Introduction: Hacks #44-50
    2. Hack #44. Infer Social Networks from IRC
      1. Installing PieSpy
      2. Configuring PieSpy
      3. Running PieSpy
      4. Getting Output from PieSpy
      5. Controlling PieSpy
      6. The Results
    3. Hack #45. Run an Infobot
      1. Getting Infobot
        1. Configuration
      2. Set Up Users
      3. Using the Infobot
      4. Reprogramming the Infobot
    4. Hack #46. Use PPF for Gaming Clans
      1. Get PPF
      2. PPF Core
      3. Running PPF
      4. ChannelCentral
      5. TriggerMessage
      6. ServerQuery
      7. ServerAdminShouter
      8. CBFinder
      9. BFTracks
      10. EDFinder
      11. Google
      12. Other Plug-ins
    5. Hack #47. Write a Plug-in for PPF
      1. The Code
      2. Running the Hack
      3. Creating Advanced Plug-ins
    6. Hack #48. Getting Friendly with FOAFBot
      1. Parsing a FOAF File
      2. Crawling FOAF Files
      3. Writing the IRC Interface
      4. Running the Hack
    7. Hack #49. Interrogate Trust Networks with TrustBot
      1. Getting Trust Data
      2. Modifying the IRC Interface
      3. The Results
    8. Hack #50. Pass Notes to Other Users
      1. The Code
      2. Running the Hack
      3. The Results
  13. 8. Search and Query Bots
    1. Introduction: Hacks #51-57
    2. Hack #51. Search the Web with Google
      1. Google Web APIs
      2. The Code
      3. Running the Hack
      4. The Results
    3. Hack #52. Use the Dictionary
      1. The Code
      2. Running the Hack
      3. The Results
      4. Hacking the Hack
    4. Hack #53. Check the Weather
      1. The Code
      2. Running the Hack
      3. Hacking the Hack
    5. Hack #54. Don’t Get Lost in Translation
      1. The Code
      2. Running the Hack
    6. Hack #55. Convert Currency
      1. The Code
      2. Running the Hack
    7. Hack #56. Find Out When People Are on the Network
      1. The Code
      2. Running the Hack
      3. The Results
    8. Hack #57. Search for Books on Amazon
      1. The Code
      2. Running the Hack
      3. Using the Bot
      4. Hacking the Hack
  14. 9. Fun Bots
    1. Introduction: Hacks #58-63
    2. Hack #58. A DiceBot
      1. The Code
      2. Running the Hack
      3. The Results
    3. Hack #59. An Egg Timer
      1. The Code
      2. Running the Hack
      3. The Results
      4. Hacking the Hack
    4. Hack #60. A Trivia Bot
      1. The Code
      2. Making Questions
      3. Running the Hack
      4. The Results
    5. Hack #61. Perform Feats of Math
      1. Java Expression Parser
      2. The Code
      3. Running the Hack
    6. Hack #62. An Artificial Intelligence Bot
      1. Markov Modeling
      2. JMegaHal
      3. The Code
        1. A simple example
        2. Combining JMegaHal and PircBot
      4. Running the Hack
      5. The Results
    7. Hack #63. Create Comic Strips
      1. Setting Up ComicBot
      2. Running ComicBot
      3. Comic Strip Templates
  15. 10. Announcement Bots
    1. Introduction: Hacks #64-67
    2. Hack #64. Welcome Visitors Automagically
      1. Channel Rules
      2. Welcome Options
      3. The Code
      4. Running the Hack
      5. The Results
    3. Hack #65. Announce Newsgroup Posts
      1. Connecting to a News Server
      2. The Code
      3. Running the Hack
      4. The Results
    4. Hack #66. Feed Syndicated RSS News
      1. The Code
      2. Running the Hack
      3. Hacking the Hack
    5. Hack #67. Watch Online Games with MatchEd
      1. Configuring MatchEd
      2. Starting MatchEd
      3. Message Styles
        1. Dynamic configuration
  16. 11. Network Bots
    1. Introduction: Hacks #68-72
    2. Hack #68. Link Channels on Multiple Networks
      1. The Code
      2. Running the Hack
      3. The Results
    3. Hack #69. Get a Remote Shell
      1. DCC
      2. The Code
      3. Running the Hack
      4. The Results
      5. DCC CHAT Limitations
    4. Hack #70. Tail Log Files
      1. The Code
      2. Running the Hack
      3. The Results
    5. Hack #71. Bridge Two Infobots
      1. The Code
      2. Running the Hack
    6. Hack #72. A File-Sharing Bot
      1. The Code
      2. Running the Hack
      3. Hacking the Hack
      4. The Results
  17. 12. Channel Management Bots
    1. Introduction: Hacks #73-77
    2. Hack #73. Protect the Channel Topic
      1. Topic Protection Mode
      2. Topic Erasure
      3. Formatting and Colors
      4. Profanity Filtering
      5. The Code
      6. Running the Hack
    3. Hack #74. Invite Users into Channels
      1. Create an InviteBot
      2. The Code
      3. Running the Hack
      4. The Results
    4. Hack #75. Maintain Operator Status
      1. The Code
      2. Running the Hack
      3. Hacking the Hack
    5. Hack #76. Set Up an Eggdrop Bot
      1. Configuring Eggdrop
    6. Hack #77. Manage Channels with an Eggdrop
      1. Joining Channels
      2. Adding Users
      3. Flood Protection
  18. 13. The IRC Protocol
    1. Introduction: Hacks #78-85
    2. Hack #78. Understanding the IRC Protocol
      1. Asynchronous by Nature
      2. The Protocol
        1. Message
        2. PRIVMSG
        3. NOTICE
        4. PING/PONG
    3. Hack #79. Text Over Multiple Lines
      1. Avoiding the Problem
    4. Hack #80. Fake an Ident Response
      1. The Code
      2. Running the Hack
      3. Firewalls and Ident
    5. Hack #81. Strip Formatting from Messages
      1. TimeBot Scenario
      2. Removing All Formatting
        1. Perl solution
        2. Python solution
        3. Java solution
        4. Java Applet solution
    6. Hack #82. Remove Color from Messages
      1. Simple Color Removal
        1. Perl solution
        2. Python solution
        3. Java solution
        4. Java Applet solution
      2. Hacking the Hack
    7. Hack #83. Encrypt Messages
      1. Key Encryption
      2. The Code
      3. Running the Hack
      4. The Results
    8. Hack #84. Timestamp with the TS Protocol
      1. Before TS
      2. TS Saves the Day
      3. Interesting TS Facts
    9. Hack #85. Understanding CTCP Messages
      1. Tagged Data
      2. Queries
  19. 14. Other Ways to Connect to IRC
    1. Introduction: Hacks #86-94
    2. Hack #86. Hypertext Links to IRC Channels
      1. HTML IRC Links
      2. Example Links
    3. Hack #87. IRC from Your Mobile Phone
    4. Hack #88. Enemies of Mobile IRC
      1. The Phone Keypad
      2. Predictive Text Entry
      3. Small Screen Size
      4. Street Traffic and Street Furniture
      5. Dropped Connections
      6. Others Unaware Your Client Is Limited
      7. The Ephemeral Nature of Sessions
      8. Battery Life
    5. Hack #89. IRC from a Pocket PC
    6. Hack #90. Access IRC with Java Applets
      1. Customizing PJIRC
        1. nick
        2. alternativenick
        3. host
        4. alternativeserver
        5. command
        6. authorizedjoinlist
        7. authorizedcommandlist
      2. The Results
    7. Hack #91. Use IRC from a Web Page Without Java
      1. Installing CGI:IRC
    8. Hack #92. Use IRC Within screen
    9. Hack #93. Set Up an IRC Proxy
      1. Setting Up CtrlProxy
      2. Running the Hack
      3. Advanced Features
    10. Hack #94. Use irssi and Its Proxy
      1. Connecting to a Server
      2. Using the irssi Proxy
  20. 15. Servers and Services
    1. Introduction: Hacks #95-100
    2. Hack #95. Set Up Your Own IRC Server for Unix/Linux
      1. Installing Unreal
    3. Hack #96. Install Services
      1. Configuring the IRC Server
      2. Configuring Services
      3. Running the Services
    4. Hack #97. Set Up Your Own beware ircd Server
      1. Downloading beware ircd
      2. O:Lines
      3. Running beware ircd
    5. Hack #98. Link Two IRC Servers Together
      1. Configuring the Servers
      2. Numerics
      3. C:Lines
      4. Linking the Servers
      5. Bursting
      6. Commands
    6. Hack #99. Use MSN/ICQ/Jabber from IRC
      1. Installation
      2. Using BitlBee
      3. More Than Just Talking
    7. Hack #100. Combine BitlBee and CtrlProxy
      1. Setting Up CtrlProxy and BitlBee
      2. Starting CtrlProxy
      3. Starting the Session
      4. Hacking the Hack
  21. Index
  22. About the Author
  23. Colophon
  24. SPECIAL OFFER: Upgrade this ebook with O’Reilly