HTML2IRC plugin for PPF
Here’s a nifty and powerful plugin for the PircbotPluginFramework (PPF) for you. The plugin enables loading html-content to irc very fast. You are able to configure which parts of the HTML should be output into irc.
This plugin is very powerful and should replace all further instances of plugins which only read from html sites and output some content in the channel like the googlePlugin, filemirrorPlugin, bash, nanoGoogle, nanoBash and nanoTorrent.
Its a perfect addition to the feedReader plugin, now having the ultimate powertools to work with xml and html.
PPF Version: PPF 0.5 beta
Current Plugin Version: 0.1
Please Note: the author of the plugin takes no responsibility on any harm or violation the users do by using the plugin. Do not access/read sites which do not explicitly allow so or without the permission of the respective webmasters!
Download
You can download the plugin by clicking on one of the following links:
- html2irc.rar (6,82 kb)
- html2irc.zip (6,95 kb)
- html2irc.7z (6,74 kb)
- html2irc.tar.gz (xx kb)
Installation
Extract the downloaded archive into your /ppf/system/ directory. After exctraction you should have a directory called /ppf/system/html2irc.
Now open your PPFConfig.xml and add the following lines to your plugins section:
<plugin load="yes">
<name>html2irc</name>
<classname>net.sourceforge.ppf.plugin.html2ircplugin.html2ircPlugin</classname>
</plugin>
Now restart your bot. You can load/unload the plugin as any other plugins by using "loadplugin html2irc" and "unloadplugin html2irc" repectively.
Adding new commands
You add a command by modifying the html2ircConfig.xml file. You need to know how to form proper regular expressions in java or else you dont have to continue reading.
Here’s the basic code snippet for new commands:
<command message="regex" authLevel="none|any|admin|master|trusted|none" output="channel|notice|pm">
<href>URI</href>
<regex><![CDATA[your regular expression here]]></regex>
<output reapeat="true|false" count="[1-9]" striphtml="true|false">output string</output>
</command>
Here is an example of the plugin retrieving 3 results from www.google.com :
<command message="!google (.*)" authLevel="none" output="channel">
<href>http://www.google.com/search?q=$1</href>
<regex><![CDATA[<a class=l href=\"([^\"]*)\">(.*?)</a>]]></regex>
<output repeat="true" count="3" striphtml="true">(google) $2 ( $BLUE$1$NORMAL )</output>
</command>
Notes
- if you want to use HTML tags (’<’,'>’,'&’) in the output code, please make sure you convert them to entities (’<’,>’,'&’)
- you can backreference with $1 $2 $3 $4 (href backreferences to message attribute, output backreferences to regex)
- you can show current index number of output with $INDEX (repeat="true" and count>1 only)
The following features are not completely implemented yet:
- /command/ attribute autLevel
- /command/ attribute output
- /command/output/ attribute striphtml
- /command/output/ attribute multiline
As always, feedback and suggestions are welcome.
October 28th, 2007 at 4:12 am
[…] ChrisWell » HTML2IRC plugin for PPF Tags: java opensource dev pircbot plugin framework ppf […]