Toon posts:

[PHP/TCL] Eggdrop script aansturen via socket verbinding.

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik heb een PHP/MySQL website draaiend op een UNiX server.

Nu wil ik dat als er nieuws gepost is dit direct op IRC gespammed wordt. Dus niet dat er om de zoveel tijd gecontroleert wordt op nieuwe posts.

Nu heb ik een eggdrop draaien op een remote shell. Dit staat in het .tcl script wat het moet gaan doen:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# listening port
set tS(port) "34625"

listen $tS(port) script tS:sock

proc tS:sock {idx} {
    control $idx tS:parse
}

proc tS:parse {idx args} {
    putlog $args
    switch -exact -- [lindex $args 0] {
        "l" {
            set message "[lindex $args 1] logged in"
        }
    }
    putserv "PRIVMSG #channel :[lindex $args 0]"
}


Ik stuur deze .tcl aan vanaf buitenaf met php met behulp van deze functie:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?
function printBot($string)
    $server = xx.xxx.xx.xxx;
    $port = '34625';
    
    $string = $string.'\n';
    
    $socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
    $connection = socket_connect($socket,$server,$port);
    sleep(2);
    socket_write($socket,$string);
    socket_close($socket);
?>


De invoer als er een nieuw bericht ingevoerd is wordt dan printBot('news 5')

De bot zou dan moeten zoek naar nieuws bericht #5. En deze url in het IRC kanaal spammen.

(MySQL connectiviteit in de bot werkt)
De bot krijgt echter helemaal geen informatie binnen. Weet iemand wat ik fout doe?

BVD!