Forum bot (met chatbot adon bot reply niet in chatbox)

Hulp nodig bij een modificaties of op zoek naar een MOD? Bekijk ons archief. Support wordt helaas niet meer verleend.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
Gebruikersavatar
supperbas
Berichten: 389
Lid geworden op: 05 jun 2005, 10:02
Locatie: zeeland
Contacteer:

Forum bot (met chatbot adon bot reply niet in chatbox)

Bericht door supperbas » 27 jun 2005, 15:14

Mijn bot werkt voor 100% op mijn forum
Er zit bij de instalatie ook de install om de bot in de chatbox te laten werken

maar helaas deze werkt niet en de bot zegt dus nix terug :cry:

weet iemand of er iets mis is met de instaltie (van bot an chatbox)? smartor

Ik heb het tot 2x toe gedaan alles in GOED ingesteld en geupload etc
vervangen en ga zo maar door

iemand een idea waar aan het ligt?

svenn
Berichten: 5001
Lid geworden op: 14 jul 2004, 13:00
Locatie: Kortrijk
Contacteer:

je

Bericht door svenn » 27 jun 2005, 15:23

je moet iets wijziggen in de chatbox , kijk eens op phpbb.com , ben ook aan het zoeken ;)

Gebruikersavatar
supperbas
Berichten: 389
Lid geworden op: 05 jun 2005, 10:02
Locatie: zeeland
Contacteer:

Bericht door supperbas » 27 jun 2005, 15:26

Code: Selecteer alles

############################################################## 
## Forum AI MOD Intergration File
## MOD Author: zemaj < zemaj@palgn.com > (James Gay) http://www.palgn.com/
## * only to be used when both mods in question have been installed *
## MOD Which Intergrates With: *ChatBox for phpBB2 (v1.18b) by Smartor*
## Description: This is an extensive intergration feature which makes your AI into the
## administrator of the chat system (system messages all come from the bot). The
## the AI will also participate in the chat. Users also have the option of ignoring
## the AI in chat.
############################################################## 
## More detail:
## 
## This is another cool system. How does the bot interact with the chat?
## Well it is based on the number of users present. It once again works
## on a percentage system. If there is only one user in chat then the bot
## will repond 100% of the time.
## o Two users: 100% / 2
## o Three users: 100% / 3
## etc... it works very well.
## The bot will also repond to the forum always respond words, if you have any.
##
## Note: It DOES lead to a slight slow down when IAI is responding to a message,
## however if this annoys people they can choose the ignore IAI function which
## will stop IAI from reponding to that user and stop that user seeing IAI's
## messages.
##
## It's a good intergration, huh? The systems complement each other very well.
############################################################## 
# 
#-----[ OPEN ]------------------------------------------ 
# 
chatbox_mod/chatbox_config.php

# 
#-----[ FIND ]------------------------------------------ 
# 
define("_CHATBOX_SYSTEM_MSG", "<span style='color: #DD6900'>System Msg</span>");

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
// Find out how many people are using:
$sql = "DELETE FROM " . $table_chatbox_session_name . " WHERE lastactive < '" . (time() - 300) . "'";
if (!$result = $db->sql_query($sql))
{
	message_die(GENERAL_ERROR, "Could not check session for Ghosts", "", __LINE__, __FILE__, $sql);
}
$sql = 'SELECT * FROM ' . $table_chatbox_session_name;
if (!$result = $db->sql_query($sql))
{
	message_die(GENERAL_ERROR, "Could not query ChatBox Session information", "", __LINE__, __FILE__, $sql);
}
$howmanychat = $db->sql_numrows($result);

// for IAI system messages
define("_CHATBOX_SYSTEM_MSG", "<span style='color: #DD6900'>" . $board_config['iai_username'] . " Msg</span>");

// for normal IAI replies
define("_IAI_MSG", $board_config['iai_username']);

# 
#-----[ OPEN ]------------------------------------------ 
# 
chatbox_mod/chatbox_function.php

# 
#-----[ FIND ]------------------------------------------ 
# 
function write_msg($nick, $msg)
{
	global $chatbox_config, $table_chatbox_name, $board_config, $table_chatbox_name, $db;

	if (($nick != _CHATBOX_SYSTEM_MSG) && (isuser_active($nick) == "offline"))
	{
		write_msg(_CHATBOX_SYSTEM_MSG,"<span style='color: #006600'><b><i>$nick</b> joined chat on " . create_date($board_config['default_dateformat'], time(), $board_config['board_timezone']) . "</i></span>");
		user_join($nick,"offline");
	}

	if (($nick != _CHATBOX_SYSTEM_MSG) && (isuser_active($nick) == "away"))
	{
		write_msg(_CHATBOX_SYSTEM_MSG, "<span style='color: #000066'><i><b>$nick</b> is online again</i></span>");
	    user_active($nick);
	}

	$sql = "INSERT INTO ".$table_chatbox_name." VALUES ('','".mysql_escape_string($nick)."','".mysql_escape_string($msg)."','".time()."')";

    if (!$result = $db->sql_query($sql))
	{
		die("SQL Error in function write_msg()");
	}
}

# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
function write_msg($nick, $msg)
{
	global $chatbox_config, $table_chatbox_name, $board_config, $table_chatbox_name, $db;

	if (($nick != _CHATBOX_SYSTEM_MSG) && ($nick != _IAI_MSG) && (isuser_active($nick) == "offline"))
	{
		write_msg(_CHATBOX_SYSTEM_MSG,"<span style='color: #006600'><b><i>$nick</b> joined chat on " . create_date($board_config['default_dateformat'], time(), $board_config['board_timezone']) . "</i></span>");
		user_join($nick,"offline");
	}

	if (($nick != _CHATBOX_SYSTEM_MSG) && ($nick != _IAI_MSG) && (isuser_active($nick) == "away"))
	{
		write_msg(_CHATBOX_SYSTEM_MSG, "<span style='color: #000066'><i><b>$nick</b> is online again</i></span>");
	    user_active($nick);
	}

	$sql = "INSERT INTO ".$table_chatbox_name." VALUES ('','".mysql_escape_string($nick)."','".mysql_escape_string($msg)."','".time()."')";

    if (!$result = $db->sql_query($sql))
	{
		die("SQL Error in function write_msg()");
	}
}

# 
#-----[ OPEN ]------------------------------------------ 
# 
chatbox_mod/messenger_view.php

# 
#-----[ FIND ]------------------------------------------ 
# 
include_once($phpbb_root_path . 'extension.inc');

# 
#-----[ ADD AFTER ]------------------------------------------ 
#
$iai_root_path = $phpbb_root_path . 'mods/iai/';
include_once($iai_root_path . 'includes/iai_functions.'.$phpEx);

# 
#-----[ FIND ]------------------------------------------ 
# 
<meta http-equiv="refresh" content="<?php echo $chatbox_config['refresh_time']; ?>; URL=<?php echo append_sid("messenger_view.php"); ?>">

# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
<meta http-equiv="refresh" content="<?php echo $chatbox_config['refresh_time']; ?>; URL=<?php echo append_sid("messenger_view.php?show_iai=$show_iai"); ?>">

# 
#-----[ FIND ]------------------------------------------ 
# 
//
// End session management
//

# 
#-----[ ADD, AFTER ]------------------------------------------ 
#
if(!isset($show_iai))
{
	// I recomend that you leave this as false. The bot can become a little obtrusive
	// so, leave if off and people can turn it on if they want to play with it.
	$show_iai = FALSE;
}

# 
#-----[ FIND ]------------------------------------------ 
# 
function add_msg($nick, $msg) // This function processes the submission from user - Smartor
{
	global $chatbox_config, $userdata;

	$error = FALSE;

	$nick = stripslashes(htmlspecialchars(trim($nick)));
	$msg = htmlspecialchars(trim($msg));

	// Check Admin Command
	if ($userdata['user_level'] == ADMIN)
	{
		if ( strtolower(substr($msg, 0, 5)) == '/kick') // /KICK
		{
			$victim = substr($msg, 6, strlen($msg) - 6);
			write_msg(_CHATBOX_SYSTEM_MSG, '<i>' . $victim . ' was kicked</i>');
			return;
		}
		elseif (strtolower($msg) == '/clear') // /CLEAR
		{
			clear_chat();
			return;
		}
	}
	// END - Check

	if ( (!isset($msg)) or ($msg == "") or (!isset($nick)) or ($nick == "") )
	{
		$error = TRUE;
	}

	if ( strlen($msg) > $chatbox_config['max_msg_len'] )
	{
		$msg = substr($msg, 0, $chatbox_config['max_msg_len']);
	}

	if ($error == FALSE)
	{
		write_msg($nick, $msg);
		user_active($nick);
	}
}

# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
function add_msg($nick, $msg) // This function processes the submission from user - Smartor
{
	global $chatbox_config, $userdata, $howmanychat, $board_config, $phpbb_root_path, $show_iai, $phpEx;

	$error = FALSE;

	$nick = stripslashes(htmlspecialchars(trim($nick)));
	$msg = htmlspecialchars(trim($msg));

	// Check Admin Command
	if ($userdata['user_level'] == ADMIN)
	{
		if ( strtolower(substr($msg, 0, 5)) == '/kick') // /KICK
		{
			$victim = substr($msg, 6, strlen($msg) - 6);
			write_msg(_CHATBOX_SYSTEM_MSG, '<i>' . $victim . ' was kicked</i>');
			return;
		}
		elseif (strtolower($msg) == '/clear') // /CLEAR
		{
			clear_chat();
			return;
		}
	}
	// END - Check

	if ( (!isset($msg)) or ($msg == "") or (!isset($nick)) or ($nick == "") )
	{
		$error = TRUE;
	}

	if ( strlen($msg) > $chatbox_config['max_msg_len'] )
	{
		$msg = substr($msg, 0, $chatbox_config['max_msg_len']);
	}

	if ($error == FALSE)
	{
		write_msg($nick, $msg);
		user_active($nick);

		//
		//  BEGIN IAI respond process
		//
		if($show_iai)
		{
			// Does IAI reply?
			$howmanychat = ($howmanychat == 0) ? 1 : $howmanychat;
			$percent_reply = ( 100 / $howmanychat );
			list($usec, $sec) = explode(' ', microtime());
			mt_srand((float) $sec + ((float) $usec * 100000));
			$iai_rand = mt_rand(0, 100);
			$run_iai = ($iai_rand <= $percent_reply) ? TRUE : FALSE;
			if(!$run_iai)
			{
				$res_words = str_replace(", ", ",", $board_config['iai_respond_words']);
				$res_words = str_replace("!", "", $res_words);
				$res_words = str_replace("?", "", $res_words);
				$res_words = str_replace("'", "", $res_words);
				$res_words = str_replace('"', '', $res_words);				
				$res_words = explode(",", $res_words);
				$words = str_replace(".", "", $msg);
				$words = str_replace("!", "", $words);
				$words = str_replace("?", "", $words);
				$words = str_replace(",", "", $words);
				$words = str_replace("'", "", $words);
				$words = str_replace('"', '', $words);
				$words = explode(" ", $words);
				for($i = 0; $i < count($res_words); $i++)
				{
					$words = str_replace($res_words[$i] . " ", " " . $res_words[$i] . " ", $words);
					$words = str_replace(" " . $res_words[$i], " " . $res_words[$i] . " ", $words);
					for($g = 0; $g < count($words); $g++)
					{
						if($res_words[$i] == $words[$g])
						{
							$run_iai = TRUE;
						}
					}
				}	
			}

			if ($run_iai)
			{					
				// Initialise variables
				$numselects = 0;
				$user_id = ($userdata['session_logged_in']) ? $userdata['user_id'] : 0;
				$topic_id = 1; // all chat logs go in topic_id = 1
				$sesh_id = $userdata['session_id']; // should NOT be null in any situation
				$iai_reply_to = str_replace("is " .  $iai_username, "are you", $msg);
				$iai_reply_to = str_replace( $iai_username, "you", $iai_reply_to);
					
				// Get IAI reply
				$iai_reply = reply($iai_reply_to,$user_id,$topic_id,$sesh_id);
				$iai_message = $iai_reply->response;	

				write_msg(_IAI_MSG, $iai_message);
			}
		}
		//
		// End IAI respond process
		//
	}
}

# 
#-----[ FIND ]------------------------------------------ 
# 
function show_msg()
{
	global $chatbox_config, $userdata;

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
function show_msg()
{
	global $chatbox_config, $userdata, $board_config, $show_iai;

# 
#-----[ FIND ]------------------------------------------ 
# 
			if ($colour == 0)
			{
				$colour=1;
			}
			else
			{
				$colour=0;
			}


			echo output_msg($chat['nick'], $msg, $colour);

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
			// Test if user is ignoring the AI
			if(!(($chat['nick'] == $board_config['iai_username']) && !($show_iai)))
			{

				if ($colour == 0)
				{
					$colour=1;
				}
				else
				{
					$colour=0;
				}


				echo output_msg($chat['nick'], $msg, $colour);
			}

# 
#-----[ OPEN ]------------------------------------------ 
# 
chatbox_mod/messenger_send.php

# 
#-----[ FIND ]------------------------------------------ 
# 
		<input type="text" name="message" size="30" maxlength="<?php echo $chatbox_config['max_msg_len']; ?>" value="Enter Message" onFocus="clear_text()" <?php if (isset($chatbox_config['vietuni'])) echo " onkeyup='initTyper(this);'"; ?> class="editbox">

# 
#-----[ ADD, BEFORE ]------------------------------------------ 
# 
		Ignore <?php echo $board_config['iai_username']; ?>'s replies:
		<input type=radio name="show_iai"  value="0" CHECKED>Yes&nbsp;
		<input type=radio name="show_iai" value="1">No
		<br />

# 
#-----[ OPEN ]------------------------------------------ 
# 
chatbox_mod/messenger_list.php

# 
#-----[ FIND ]------------------------------------------ 
# 
function who_are_on_chat()
{
	global $chatbox_config, $table_chatbox_session_name, $db;

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
function who_are_on_chat()
{
	global $chatbox_config, $table_chatbox_session_name, $db, $board_config;

# 
#-----[ FIND ]------------------------------------------ 
# 
	for($s = 1; $s <= $isimler[0]; $s++)
	{

# 
#-----[ ADD, BEFORE ]------------------------------------------ 
# 
	$online .= $board_config['iai_username']."<br />";

# 
#-----[ OPEN ]------------------------------------------ 
# 
chatbox_front.php

# 
#-----[ FIND ]------------------------------------------ 
# 
$howmanychat = $db->sql_numrows($sol); // Return this

# 
#-----[ ADD, AFTER ]------------------------------------------ 
# 
// add AI bot to chat number
$howmanychat++;

# 
#-----[ FIND ]------------------------------------------ 
# 
$chatters = $isimler[1];

for($s = 2; $s <= $isimler[0]; $s++)
{
	$chatters .= ", $isimler[$s]"; // Return this
}

# 
#-----[ REPLACE, WITH ]------------------------------------------ 
# 
$chatters = $board_config['iai_username'];

for($s = 1; $s <= $isimler[0]; $s++)
{
	$chatters .= ", $isimler[$s]"; // Return this
}

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM

is gebeurd maar werkt niet dit is beschrijving

Code: Selecteer alles

The file list all the intergration mods in this directory and give a short description
about what installing each one will do:
MOD: ChatBox for phpBB2 (v1.18b) by Smartor
Intergration Author: zemaj
Filename to use: iai_chat_box.txt
Description: This is an extensive intergration feature which makes your AI into the
	administrator of the chat system (system messages all come from the bot). The
	the AI will also participate in the chat. Users also have the option of ignoring
	the AI in chat.

Gesloten