CIA Bot Notifier


Related Links
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, 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 CIA development docs.

Screenshot

This is what the notifier looks like in action using the irssi IRC client:

Screenshot of CIA notifier

System Requirements


Implementation

'cia_bot_project_name' => 'your-project-name'


                    // 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);
                    }


                    // 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);
                    }
Comments
Comment by NilsLindenberg
2009-07-10 17:22:40
Brian, very nice idea. Some suggestions: instead of using cod twice, it would be better to use a function, so changes don't have to be applied twice. The <url> code looks unfinished. < and > should probably be escaped in the xml-file? Both times, the code should better check if the page is readable for all, shouldn't it?
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki