Extension:Multi-protocol notification

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Multi-protocol notification
Release status: stable
Implementation Notify
Description Forward major or minor change notifications to a multi-protocol chat and messaging server for IRC, XMPP and PSYC users.
Author(s) fippo & lynX
Latest version 1.1 (2007-05-06)
MediaWiki any
License No license specified
Download download
Translate the Multi-protocol notification extension if it is available at translatewiki.net
Check usage and version matrix.

Multi-protocol notification informs people or applications connected to a chatroom (IRC channel or XMPP MUC) or other PSYC entity about a change that has been submitted to a wiki in real-time.


You will need a chatroom on a psyced server. If you install a psyced on the same host with your wiki, it comes with a pre-configured wikinotify chatroom that should work out-of-the-box.


Taking the out-of-the-box place as an example, with an IRC client you would have to access #wikinotify on your psyced server, whereas using an XMPP client you would join a MUC called *wikinotify@example.org with example.org being the address of your psyced. The asterisk (*) cannot be left out!

You can also register an XMPP account on psyced directly, so you avoid having XMPP servers in-between.

The notifications will look something like this, depending on your user interface:

(Wiki:lynx) has made a major change in http://about.psyc.eu/Routing saying: packet ids
(Wiki:fippo) has made a minor change in http://about.psyc.eu/XMPP


psycnotify.php 1.1:
    deliver a change notification to a PSYC group.
    written by psyc://goodadvice.pages.de/~fippo
    flirted up by psyc://psyced.org/~lynX
    released as freeware. wash your socks with it.

http://www.psyc.eu - the answer in messaging and conferencing

this script uses UDP because (a) the wiki is running on the localhost of the
server (b) you could just as well use TCP (c) then again if you don't mind
potential fake messages, you can use this across the network too - if the
network is really congested enough to lose a wiki notification, is it really
worth congesting the network even more?

now comes the two line config zone.

$psyctarget: if you don't know the uniform of your chatroom, a /status
command will tell you.

$psychost: in some cases when you want to use a neat domain name you will
have to resort to using SRV to map it onto a different host from where your
webserver resides. since implementing SRV here looks like too much work,
we simply ask you to provide the ip or hostname of the receiving machine
where the $psyctarget actually resides on, into $psychost. under normal
circumstances $psychost has the same hostname as $psyctarget.

our settings look like this:
  $psyctarget = "psyc://psyced.org/@welcome";
  $psychost = "udp://psyced.org";

but the easiest way to set this up is to install a psyced on the same
host, then you don't need to change anything below and the "wikinotify"
chatroom will work out of the box (feel free to edit it, though).

$psyctarget = "psyc://localhost/@wikinotify";
$psychost = "udp://localhost";
$psycport = 4404;

/* in an ideal world, there is nothing you need to do below here */

function psycnotify($article, $user, $text, $summary, $isminor, $iswatch, $section) {
    global $psyctarget, $psychost;

    $url = "http://" . $_SERVER['SERVER_NAME'];
    $url .= str_replace("index.php?title=", "index.php/",
       substr($_SERVER['REQUEST_URI'], 0, -14));
    # header
    $s = ":_target\t$psyctarget\n"
#      . ":_encoding\tutf-8\n" # PSYC uses UTF-8 anyway
       . "\n"                  # move on from routing layer to application layer
       . ":_nick_wiki\t". strToLower($user->mName) ."\n"
       . ":_article\t". $article->mTitle->mTextform ."\n"
       . ":_page\t$url$section\n";
    if ($section) {
        $s .= ":_section\t$section\n";
        if ($summary && ($p = strpos($summary, " */ ")))
            $summary = substr($summary, $p + 4);
    if ($summary) $s .= ":_summary\t$summary\n";

    # method
    $mc = "_notice_update_wiki";
    if ($isminor) $mc .= "_minor";
    $s .= $mc ."\n";

    # body
    $s .= "(Wiki:[_nick_wiki]) has made a "
       . ($isminor ? "minor" : "major")
       . " change in [_page]\n";
    if ($summary) $s .= "saying: [_summary]\n";

    # deliver, as simple as that
    $udp = fsockopen($psychost, $psycport);
    fwrite($udp, ".\n". $s .".\n");
    return true;

$wgHooks['ArticleSaveComplete'][] = array('psycnotify');

put it into extensions/psycnotify.php, then add

require_once( "extensions/psycnotify.php" );

to LocalSettings.php


See notifications of changes to the about.psyc.eu Wiki by entering the welcome channel using any of these:

This extension has been running stable since 2005.