Overview
The IRC Bot available at https://svn.atlassian.com/svn/public/contrib/confluence/ircbot/trunk/ is capable of logging IRC chats from multiple channels to confluence. The bot is in the early stages of development but fully functional. It was created for developers of the uPortal project to allow for IRC discussion with good conversation archiving.
The IRC functionality of the bot is implemented using the PIRC Java IRC Bot framework.
The Confluence RPC calls are done via the Swizzle Confluence API.
Bot Configuration
The bot configuration exists in a Spring application context XML: /ConfluenceIrcLogger/src/main/resources/applicationContext.xml
- At the top of the file the logBot bean is configured with the name the bot should attempt to use. The bot will fail to connect if the name is already in use.
- Near the top of the file the loggedChannels bean (a util:set) contains the set of channels that the bot should connect to. This set is also used by the IrcEvent filters to determine which events should be logged to confluence.
- At the bottom of the file the confluenceMessageHandler bean has the configuration for logging to Confluence
- endpoint The XML RPC Endpoint for your confluence instance. Usually at http://yourhost/confluence/rpc/xmlrpc
- username Username of the confluence user to perform the logging
- password Password of the confluence user to perform the logging
- spaceKey The Confluence Space that contains the logs
- pageTitleDateFormat A SimpleDateFormat compliant string to create the page names for writing logs to.
- parentPage The title of the parent page for the log pages, this page will be updated with a link to each log page.
- messageEscapePairs A Map of Strings to Strings used for escaping messages before they are logged. This allows for escaping the confluence syntax from IRC messages.
IRC Functionality
Currently the bot can connect to a single IRC server and multiple channels in that server. The only interaction code currently written provides channel notifications to people joining the channel that it is being logged. The notification message is configurable.
The bot will reconnect to the IRC server if it is disconnected and rejoin channels if it is kicked.
Confluence Logging
To reduce the number of RPC calls a message buffer can be used to hold a certain number of messages before writing them in a group to the Confluence server. There is also an option to log messages at a configurable interval to ensure messages don't remain the buffer too long.
A parent page is specified on which the bot creates a link to the current log page using a string that complies with the SimpleDateFormat specifications. This allows pages to be easily scoped by a time period since as the results of the SimpleDateFormat pattern change the target log page will change.
A .properties file is used to pull formatting strings for each IRC event. The strings are run through a Java MessageFormat object to generate the final message that is logged.
Design Overview
The IRC logic is contained in the PIRC org.jibble.pircbot.PircBot class. PircBot provides a number of protected on* methods that are called by the PircBot code when the corresponding event takes place.
To decouple the bot class from code actually taking actions an event hierarchy and handler was created. Not all of the events that PircBot represents as methods have had event classes created for them yet only those immediatly interesting to the initial development of the log bot.
| To Be Continued |
