The scripts require some more work before they can be released IMO...the php provided has some weird stuff in it (a while loop that looks like it's supposed to emulate sleep(), (try fflush() instead?) no timeout for the socket etc..) and the tcl part is insecure (just find the port and you're free to talk through the bot )awyeah wrote:Eleet, I like the idea.
I would recommend the owner of the script should submit it on egghelp.org's TCL Archive and other famous on the web so the public is aware of such a script.
Code: Select all
$nick = $userdata[user_id];
Code: Select all
$nick = $userdata[username];
Code: Select all
listen 7777 script phpbb2eggaccept pub
set check(pass) "agoodpasshere"
proc phpbb2eggaccept {idx} {
control $idx phpbbincoming
}
proc phpbbincoming {idx args} {
global check
set args [join $args]
set inc(pass) [lindex [split $args] 0]
set inc(chan) [lindex [split $args] 1]
set inc(message) [join [lrange [split $args] 2 end]]
if { $inc(message) != ""} {
killdcc $idx
}
if {[string match [md5 $check(pass)] $inc(pass)]} {
set line [split $inc(message) ";"]
foreach line $line {
putserv "PRIVMSG $inc(chan) :\00304$line"
}
} else { return 0 }
}
putlog "\00312phpbb2egg.tcl beta 0.0.2"
Code: Select all
<?php
$bb2egg['channel'] = "#your_channel";
$bb2egg['ids'] = "4 5 6 7 8"; // forums to display posts from
$bb2egg['botip'] = "255.255.255.255"; // your bot's ip
$bb2egg['botport'] = "7777"; // a nice port
$bb2egg['boardurl'] = "www.yourdomain.com";
$bb2egg['pass'] = "agoodpasshere";
function send2egg($mode, $forumid, $topic_id, $user_id, $subject, $message, $poll_title)
{
### echo "$mode, $forumid, $topic_id, $user_id, $subject, $message, $poll_title";
global $userdata, $bb2egg;
// something to do?
if ( check_id($forumid) == 0 )
{
return;
}
$nick = $userdata[$user_id];
if ( $nick == "" ) { $nick = "A Guest"; }
//strip BBCode off
$message = preg_replace("#\[(.*?)]#si", "", $message);
// shorten longer postings to 300 signs
$text = wordwrap($message, 300, "\0") . ' ...';
//here we ask for several cases and do some formating stuff with tcl readable colors.
if ( $poll_title != '' )
{
$text2 = "\00300,02 New poll! \00301,99 on our board:<br>";
}
else if ( $mode == 'newtopic' )
{
$text2 = "\00300,02 New topic! \00301,99 on our board:<br>";
}
else
{
$text2 = "\00300,02 Fresh! \00301,99 from our board:<br>";
}
if ( $poll_title != '' )
{
$text2 .= "\00300,04 $nick \00302,99 asks: $poll_title <br>";
}
else if ( $subject != '' )
{
$text2 .= "\00300,04 $nick \00302,99 about the subject $subject :<br>";
$text2 .= "\00302,99$message <br>";
}
else
{
$text2 .= "\00300,04 $nick".":";
$text2 .= "\00302,99$message <br>";
}
$text2 .= "Link: \037\00312,99" . $bb2egg['boardurl'] . "/viewtopic.php?t=$topic_id\003\037\ ";
phpbb2egg($text2);
}
function phpbb2egg($text)
{
global $bb2egg;
if ( $text == '') {
return;
}
$text = ereg_replace(";", ":", $text);
$text = ereg_replace("<br>", ";", $text);
$fp = fsockopen($bb2egg['botip'], $bb2egg['botport'], $errno, $errstr, 30);
if ($fp) {
fputs($fp, md5($bb2egg['pass']) ." ". $bb2egg['channel'] ." $text\n");
usleep(500);
fclose($fp);
}
}
function check_id($current)
{
global $bb2egg;
$forumids=explode(" ", $bb2egg['ids']);
while ( list($n, $id) = each($forumids))
{
if ($id == $current)
{
return 1;
}
}
return 0;
}
?>