Wiki source for CIABotNotifier


Show raw source

=====""CIA"" Bot Notifier=====

>>**Related Links**
[[http://brlcad.org/~sean/CIAnotify/CIAnotify.php.txt | MediaWiki port]] derived from this initial implementation
>>

===About the ""CIA"" Bot Notifier===
This code is experimental code that takes advantage of the very popular ""IRC""-based source code change notifier bot, [[http://cia.vc | CIA]]. Basically, changes to your wiki pages, or new comments, generate an ""XML""-formatted message that is sent to the ""CIA"" bot server. The message is then re-broadcast over IRC channels via subscribed CIA bots. Details about CIA are beyond the scope of this document; those interested in additional information about the ""XML"" schema used in this code should start with the [[http://cia.vc/doc/development/ | CIA development docs]].

===Screenshot===
This is what the notifier looks like in action using the [[http://www.irssi.org | irssi]] IRC client:

{{image url="images/cia_notifier.jpg" title="Screenshot of CIA notifier" alt="Screenshot of CIA notifier"}}

===System Requirements===
~- Tested on Wikka trunk
~- PHP ##mail()## must be operational
~- A [[http://cia.vc/account/register/ | CIA account]]

===Implementation===
~- Add the following parameter to ##wikka.config.php##:
%%
'cia_bot_project_name' => 'your-project-name'
%%

~- In ##handlers/edit/edit.php##, search for the call to ##""SavePage()""##. Immediately after this code, insert the following code segment, providing your wiki URL where specified:
%%(php)
// Notify CIA bot if config param is set
if(isset($this->config['cia_bot_project_name']) &&
!preg_match('/[!]\*/', $this->ACLs['read_acl']))
{
$project_name = $this->config['cia_bot_project_name'];
$to = 'cia@cia.vc';
$subject = 'DeliverXML';
$user = $this->GetUserName();
$href = $this->Href('', $this->tag);
$xml = <<<EOT
<message>
<generator>
<name>WikkaWiki custom mod</name>
<version>0.01<version>
</generator>
<source>
<project>$project_name</project>
</source>
<body>
<commit>
<log>Page modified: $href</log>
<url>http://your-wiki-site-URL/$this->tag</url>
<author>$user</author>
</commit>
</body>
</message>
EOT;
mail($to, $subject, $xml);
}
%%

~- In ##handlers/processcomment/processcomment.php##, search for the call to ##""SaveComment()""##. Immediately after this code, insert the following code segment, providing your wiki URL where specified:
%%(php)
// Notify CIA bot if config param is set
if(isset($this->config['cia_bot_project_name']))
{
$project_name = $this->config['cia_bot_project_name'];
$to = 'cia@cia.vc';
$subject = 'DeliverXML';
$user = $this->GetUserName();
$href = $this->Href('', $this->tag);
$xml = <<<EOT
<message>
<generator>
<name>WikkaWiki custom mod</name>
<version>0.01<version>
</generator>
<source>
<project>$project_name</project>
</source>
<body>
<commit>
<log>Comment modified: $href</log>
<url>http://your-wiki-site-URL/$this->tag</url>
<author>$user</author>
</commit>
</body>
</message>
EOT;
mail($to, $subject, $xml);
}
%%
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki