Beruflich Dokumente
Kultur Dokumente
n A user runs a client program to connect to n Each user must have a unique nickname
the IRC server § Commonly referred to as a “nick”
n The client program allows you to send and § Must not contain certain characters, e.g. spaces
receive messages to and from other users n Channel names must start with # or &
n Some popular IRC clients are: - n Some users may be channel operators
§ mIRC § Can kick other users out of their channel
§ BitchX § Can “op” and “deop” other users in the channel
§ xchat § Can ban users from entering the channel
1
What Can IRC Bots Do? Using Bots Sensibly
n Tell people what the time is n Never annoy other users with your Bot
n Pass messages on to other users n Only place your Bot in channels where it may
n Display information from TV listings be of use or amusement
n Perform simple mathematics n Bots should only speak when spoken to!
n Send and receive files n Make the purpose of your Bot clear
n Monitor channels to generate statistics n Make it clear that you own your Bot
n ... anything you want! n Never try to pretend that it’s not a Bot!
n A framework for writing IRC Bots with Java n The PircBot homepage
§ Simplifies the task of writing an IRC Bot § http://www.jibble.org/pircbot.php
§ No need to worry about the underlying protocol • Documentation
changelog
§ Very simple Bots can be written within minutes! •
PircBot FAQ
Event-driven architecture
•
n
• Examples of some Bots that use PircBot
Can make a Bot that responds to certain events
§
n Download the zip file
§ Contains a file named pircbot.jar
§ Also contains a directory full of documentation
2
Connecting To an IRC Server Some Notes About SimpleBot
public static void main(String[] args) {
SimpleBot bot = new SimpleBot();
n SimpleBot.java
bot.setVerbose(true); § The setName method is inherited from the
try { PircBot class and sets the nick that will be used
bot.connect(“compsoc1.ukc.ac.uk”); when the Bot joins an IRC server
}
catch (Exception e) { n Connecting to an IRC server
System.out.println(“Can’t connect: ” + e); § setVerbose(true) causes everything to be printed
return;
out as it arrives from the IRC server
}
bot.joinChannel(“#bots”); n Each method in the PircBot class is fully
} described in the provided API documentation
Copyright Paul Mutton, http://www.jibble.org/pircbot.php 13 Copyright Paul Mutton, http://www.jibble.org/pircbot.php 14
3
Reconnecting to an IRC Server PircBot Ident Server
public void onDisconnect() {
n Some IRC servers require you to connect
while (!isConnected()) { from a machine that runs an Ident Server
try { n PircBot can emulate the functionality of an
reconnect();
} Ident Server if you do not already run one
catch (Exception e) { n Provides the IRC server with your Bot’s login
// Couldn’t reconnect.
// Pause for a short while before retrying? when it asks for it
}
}
bot.startIdentServer();
}
4
User List Example Multiple Server Support in PircBot
IRC Bots Based On PircBot (1) IRC Bots Based On PircBot (2)
n ComicBot n Monty
§ Creates comic strips out of things that people say § The first ever PircBot!
§ ‘Learns’ from what it sees other people saying
§ Dictionary and thesaurus lookup feature
§ Can remind people to do things after a set time
§ Shows TV schedule listings
§ Performs google searches
§ Calculates results of mathematical expressions
§ etc.
Copyright Paul Mutton, http://www.jibble.org/pircbot.php 27 Copyright Paul Mutton, http://www.jibble.org/pircbot.php 28
n SocialNetworkBot n ScreenIRC
§ Attempts to produce graphical representations of § IRC client with a Swing GUI
“who talks to who” on IRC channels § Can be ‘detached’ from a server and reconnected
without appearing to have ever left
5
Final Words...