Jump to content
InvisionCommunity.de - Der Deutsche Invision Community Support
Sign in to follow this  
Luke

[Suche] IRC-Notify für neue Posts

Recommended Posts

Gibt es für das IPB eine Möglichkeit über einen Eggdrop (ein IRC-Bot) im Chat-Room eine Meldung ausgeben zu lassen, die über einen neues Topic bzw. Post im Board informiert?

Für das WBB gibt es bereits eine Lösung, vielleicht läßt sich damit ja etwas anfangen:

1. Das eggdrop-Modul (die Dateien müssen in src/mod/remote.mod liegen, dann den bot neu compilieren. in der config "loadmodule remote" hinzufügen)

Makefile:

# Makefile for src/mod/remote.mod/


srcdir = .



doofus:

        @echo ""

        @echo "Let's try this from the right directory..."

        @echo ""

        @cd ../../../ && make


static: ../remote.o


modules: ../../../remote.$(MOD_EXT)


../remote.o:

        $(CC) $(CFLAGS) $(CPPFLAGS) -DMAKING_MODS -c $(srcdir)/remote.c

        @rm -f ../remote.o

        mv remote.o ../


../../../remote.$(MOD_EXT): ../remote.o

        $(LD) -o ../../../remote.$(MOD_EXT) ../remote.o

        $(STRIP) ../../../remote.$(MOD_EXT)


depend:

        $(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/remote.c > .depend


clean:

        @rm -f .depend *.o *.$(MOD_EXT) *~

distclean: clean


#safety hash

../remote.o: .././remote.mod/remote.c ../../../src/mod/module.h \

 ../../../src/main.h ../../../src/lang.h ../../../src/eggdrop.h \

 ../../../src/flags.h ../../../src/proto.h ../../../lush.h \

 ../../../src/misc_file.h ../../../src/cmdt.h ../../../src/tclegg.h \

 ../../../src/tclhash.h ../../../src/chan.h ../../../src/users.h \

 ../../../src/compat/compat.h ../../../src/compat/inet_aton.h \

 ../../../src/compat/snprintf.h ../../../src/compat/memset.h \

 ../../../src/compat/memcpy.h ../../../src/compat/strcasecmp.h \

 ../../../src/mod/modvals.h ../../../src/tandem.h
remote.c:
#define MODULE_NAME "remote"


/* remote.c V0.1

 *

 * Eggdrop module 12/2002 by Zirias

 *

 * This module just listens on a socket for lines to put on the IRC-server

 * The socket is protected by a password.

 * Very handy if you want to have any other software give messages in a

 * channel through your bot. Just make it send the password followed by a

 * newline-character and then the line for IRC to the socket.

 *

 * ATTENTION, there is no syntax checking at all. Your program has to provide

 * a correct IRC protocol line like

 * 

 * PRIVMSG #chan :this is just an example

 *

 * For now, the password has to be set in this source file. Maybe this will

 * be changed.

 */


// Config:


#define PORT 12345

#define PASS "Password"


// End Config


#define MAKING_REMOTE


#include "src/mod/module.h"


#include <sys/socket.h>

#include <netinet/in.h>

#include <netdb.h>

#include <unistd.h>

#include <fcntl.h>


static Function *global = NULL;


static int remote_sock, remote_conn, cl_len;

static struct sockaddr_in cl_addr, svr_addr;

static char buffer[1024];


static int remote_expmem() {

        return 0;

}


static void remote_report(int idx, int details) {

}


static int readline(int fd, char *buf, int maxlen, int to_sec, int to_usec) {

        fd_set rfds;

        struct timeval tv;

        char *ptr=buf;

        int i=0;


        FD_ZERO(&rfds);

        FD_SET(fd,&rfds);

        tv.tv_sec=to_sec;

        tv.tv_usec=to_usec;

        while (i<maxlen) {

                if (select(fd+1,&rfds,NULL,NULL,&tv)<1) { i=-1; break; }

                i++;

                do recv(fd,ptr,1,0); while (*ptr=='\r');

                if (*ptr=='\n') {

                        *ptr='\0';

                        break;

                }

                ptr++;

        }

        return i;

}


static void remote_data() {

        if ((remote_conn=accept(remote_sock,(struct sockaddr *)&cl_addr, &cl_len))>0) {

                if (readline(remote_conn,(char *)&buffer,1023,3,0)>0) {

                        if (strcmp(PASS,(char *)&buffer)==0) {

                                if (readline(remote_conn,(char *)&buffer,1023,3,0)>0) {

                                        dprintf(DP_SERVER,"%s\n",(char *)&buffer);

                                }

                        }

                }

                close(remote_conn);

        }

}


static char *remote_close() {

        del_hook(HOOK_SECONDLY,(Function) remote_data);

        close(remote_sock);

        return NULL;

}


EXPORT_SCOPE char *remote_start();


static Function remote_table[] = {

        (Function) remote_start,

        (Function) remote_close,

        (Function) remote_expmem,

        (Function) remote_report,

};


char *remote_start(Function *func_table) {

        int socket_flags;

        global = func_table;

        module_register(MODULE_NAME,remote_table,0,1);

        if ((remote_sock=socket(AF_INET, SOCK_STREAM, 0))<0) {

                return "socket()";

        } else {

                socket_flags=fcntl(remote_sock,F_GETFL);

                socket_flags|=O_NONBLOCK;

                fcntl(remote_sock,F_SETFL,socket_flags);

                svr_addr.sin_family=AF_INET;

                svr_addr.sin_addr.s_addr=htonl(INADDR_ANY);

                svr_addr.sin_port=htons(PORT);

                if (bind(remote_sock,(struct sockaddr *)&svr_addr, sizeof(svr_addr))<0) {

                        return "bind()";

                } else {

                        add_hook(HOOK_SECONDLY,(Function) remote_data);

                        listen(remote_sock,5);

                        return NULL;

                }

        }

}
Dieses Modul ist universell einsetzbar, es nimmt einfach Zeilen an und sendet sie an den IRC-Server. 2. Der Board-Hack: Hier müssen 2 files gepatcht werden:
--- wbb-org/addreply.php        2002-12-09 22:45:38.000000000 +0100

+++ wbb/addreply.php    2002-12-09 16:14:42.000000000 +0100

@@ -3,6 +3,9 @@


 require("./global.php");

 require("./acp/lib/class_parse.php");

+//IRC-Notify-Hack by Zirias:

+require("./irc_notify.php");

+//END Hack.


 if(!isset($threadid)) eval("error("".$tpl->get("error_falselink")."");");

@@ -53,6 +56,9 @@

    $postid = $db->insert_id();

+   //IRC-Notify-Hack by Zirias:

+   irc_notify($wbbuserdata['username'],$postid,$threadid);

+   //END Hack.

    if($attachment_id) {

--- wbb-org/newthread.php       2002-12-09 22:45:54.000000000 +0100

+++ wbb/newthread.php   2002-12-09 16:13:55.000000000 +0100

@@ -2,6 +2,9 @@

 $filename="newthread.php";


 require("./global.php");

+//IRC-Notify-Hack by Zirias:

+require("./irc_notify.php");

+//END Hack.


 if($_REQUEST['action']=="announce") {

@@ -106,6 +109,9 @@

    $postid=$db->insert_id();

+   //IRC-Notify-Hack by Zirias:

+   irc_notify($wbbuserdata['username'],$postid,$threadid);

+   //END Hack.
und dazu kommt das eigentliche notify-script irc_notify.php:
<?php


/* irc_notify.php

 * 12/2002 by Zirias

 *

 * announces new threads in IRC via an eggdrop using my remote module

 */


//Config:


$thread_url="http://my.boards.host.net/thread.php";

$egg_host="my.bots.host.net";

$egg_port="12345";

$egg_pass="Password";

$channel="#mychan";


//END Config.


function irc_notify($poster,$postid,$threadid) {

        global $thread_url,$egg_host,$egg_port,$egg_pass,$channel,$db,$n;

        $thread=$db->query_first("SELECT topic,boardid FROM bb".$n."_threads WHERE threadid=".$threadid);

        $board=$db->query_first("SELECT title,invisible FROM bb".$n."_boards WHERE boardid=".$thread['boardid']);

        $trans=array_flip(get_html_translation_table(HTML_ENTITIES));

        $boardname=strtr($board['title'],$trans);

        $threadname=strtr($thread['topic'],$trans);

        if ($board['invisible']==0) {

                if ($fp=fsockopen($egg_host,$egg_port,$errno,$errstr,30)) {

                        fputs($fp,$egg_pass."\r\n");

                        fputs($fp,"PRIVMSG $channel :Neuer Post von \037$poster\037: ");

                        fputs($fp,"$thread_url?postid=$postid#post$postid ");

                        fputs($fp,"\002Forum\002: $boardname ");

                        fputs($fp,"\002Thread\002: $threadname\r\n");

                        fclose($fp);

                }

        }

}


?>

Es wäre wirklich der Hammer, wenn sich mal jemand mit dem Thema befassen könnte! :w00t:

Edited by Luke

Share this post


Link to post

Hi, also ich habe das mal getestet,aber ich weiss nicht wie es funzen soll

Du schreibst nach den beiden modulen fürs egg

"Dieses Modul ist universell einsetzbar, es nimmt einfach Zeilen an und sendet sie an den IRC-Server"

Doch ich bekomme immer wieder nach dem make befehl fehlermeldung :(

und zwar

make[2]: Leaving directory `/eggdrop/src/mod/notes.mod'

make[2]: Entering directory `/eggdrop/src/mod/remote.mod'

makefile:7: *** missing separator. Stop.

make[2]: Leaving directory `/eggdrop/src/mod/remote.mod'

make[1]: *** [remote.mod_so] Error 2

make[1]: Leaving directory `/eggdrop/src/mod'

make: *** [modules] Error 2

weiss nicht woran es liegt.

vieleicht kannst du mir das erklären , wäre nett

thx

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×