|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
@Role public interface IRCBot
Represents an IRC Bot.
| Method Summary | |
|---|---|
void |
connect(String hostname)
Attempt to connect to the specified IRC server. |
void |
disconnect()
This method disconnects from the server cleanly by calling the quitServer() method. |
Set<String> |
getChannelsNames()
Gets all the name's of all the channels that we are connected to. |
org.pircbotx.hooks.managers.ListenerManager<? extends org.pircbotx.PircBotX> |
getListenerManager()
Returns the current ListenerManager in use by this bot. |
void |
identify(String password)
Identify the bot with NickServ, supplying the appropriate password. |
void |
initialize(String wikiName)
Initialize the IRC Bot. |
boolean |
isConnected()
Returns whether or not the Bot is currently connected to a server. |
void |
joinChannel(String channel)
Joins a channel. |
void |
sendMessage(String target,
String message)
Sends a message to a channel or a private message to a user. |
void |
setName(String botName)
Sets the name of the bot, which will be used as its nick when it tries to join an IRC server. |
| Method Detail |
|---|
void initialize(String wikiName)
wikiName - the name of the wiki under which the IRC Bot listener will execute (eg "xwiki")void setName(String botName)
botName - the new name of the Bot
void connect(String hostname)
throws IOException,
org.pircbotx.exception.IrcException
hostname - the hostname of the server to connect to
IOException - if it was not possible to connect to the server
org.pircbotx.exception.IrcException - if the server would not let us join itvoid joinChannel(String channel)
channel - the name of the channel to join (eg "#cs")void disconnect()
void identify(String password)
This method issues a raw NICKSERV command to the server, and is therefore safer than the alternative approach of sending a private message to NickServ. The latter approach is considered dangerous, as it may cause you to inadvertently transmit your password to an untrusted party if you connect to a network which does not run a NickServ service and where the untrusted party has assumed the nick "NickServ". However, if your IRC network is only compatible with the private message approach, you may typically identify like so:
sendMessage("NickServ", "identify PASSWORD");
Note that this method will add a temporary listener for ConnectEvent if the bot is not logged in yet. If the bot is logged in the command is sent immediately to the server
password - The password which will be used to identify with NickServ.
void sendMessage(String target,
String message)
Some examples: -
// Send the message "Hello!" to the channel #cs.
sendMessage("#cs", "Hello!");
// Send a private message to Paul that says "Hi".
sendMessage("Paul", "Hi");
You may optionally apply colours, boldness, underlining, etc to the message by using the Colors
class.
target - The name of the channel or user nick to send to.message - The message to send.Set<String> getChannelsNames()
boolean isConnected()
org.pircbotx.hooks.managers.ListenerManager<? extends org.pircbotx.PircBotX> getListenerManager()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||