quinta-feira, 3 de março de 2005

SendToQW Miranda mbot script

Adaptei o meu plugin do Miranda SendToQW e fiz um script em PHP para o mbot. O script faz exatamento o que o plugin fazia: envia as mensagens que você recebe no Miranda para o seu cliente de Quakeworld.

<?php
/*
SendtoQW Mbot Script
Copyright (C) 2005 Leandro Koiti Sato, aka "Shogun"
http://shogunbr.blogspot.com

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.


You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

function mbot_load()
{
    mb_SelfRegister(MB_EVENT_MSG_IN,1);
}

function mbe_MsgIn($cid,$body,$timestamp,$known)
{
    $port = 27001;
    $fp = fsockopen("udp://127.0.0.1", $port, $errno, $errstr);
    if (!$fp) {
        mb_Echo ("ERROR: $errno - $errstr\n");
    }
    else {
        $fingerprint = "\xff\xff\xff\xffn";
        $lb = "\x90"; //left bracket
        $rb = "\x91"; //right bracket
        $dot = "\x9c"; //yellow dot
        $arrow = "\x8d"; //arrow

        $cn = mb_CGetDisplayName($cid);
        $proto = mb_CGetProto($cid);

        $msg = $fingerprint .$lb .$proto .$rb .$dot .$cn .$arrow ." ".$body ."\n";
        $msg = str_replace ("\r", "", $msg);
        fwrite($fp,$msg);
        fclose($fp);
    }
    return 0;
}
?>

Nenhum comentário: