[問題]Artificial intelligence 2

phpBB 2 MOD Support
無論是官方或非官方認證之外掛,安裝與使用問題討論。
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

頭像
kevinyung
星球公民
星球公民
文章: 123
註冊時間: 2004-04-14 10:22
來自: 地球
聯繫:

文章 kevinyung »

可到 http://phpbb.com/ 官方站的 Community 裡, 尋找更多 aiml 檔,
或 自己製作~
i-Piggy.com feeds you with the latest tech news and detailed tutorials
20 個步驟安裝 phpBB 3 (以 987mb.com 所提供的免費空間作示範)

kevinyung 在 侏羅紀時代 作了第 1 次修改
neoesque
星球普通子民
星球普通子民
文章: 19
註冊時間: 2003-06-05 17:12
來自: 台灣高雄

文章 neoesque »

不是這樣的

要用安全模式

這樣才不會發生逾時

這代表你只傳到A而已喔(因為A就已經很大了)
夢幻LUGIA
竹貓忠實會員
竹貓忠實會員
文章: 352
註冊時間: 2003-11-16 07:27
來自: 竹貓不忠實會員

文章 夢幻LUGIA »

之前裝過
就算AI檔很多
要講出令人滿意的結果還是很困難\r
AI是門高深的學問...要自己去研究才能體會|||
〈眾:口胡!不能把AI當羅莉推阿〈痛毆〉

A還好...
要是遇到那種問句W開頭的會...|||
如果說單個檔案還是太大\r
就把檔案拆成多個部分
neoesque
星球普通子民
星球普通子民
文章: 19
註冊時間: 2003-06-05 17:12
來自: 台灣高雄

文章 neoesque »

夢幻LUGIA 寫:之前裝過
就算AI檔很多
要講出令人滿意的結果還是很困難\r
AI是門高深的學問...要自己去研究才能體會|||
〈眾:口胡!不能把AI當羅莉推阿〈痛毆〉

A還好...
要是遇到那種問句W開頭的會...|||
如果說單個檔案還是太大\r
就把檔案拆成多個部分
沒錯 畢竟只是把人類目前說的話試著擺上去罷了

真正的AI 恩... 還差的多吧\r

W檔案是A檔案的4倍吧@@(我目前裝的)

英文尚且如此\r

那如果要做出中文的人工智慧... :?:
neoesque
星球普通子民
星球普通子民
文章: 19
註冊時間: 2003-06-05 17:12
來自: 台灣高雄

文章 neoesque »

直接修改...

也可以啦 我之前也是這麼想過

不過...

改完上傳完後記得要再改回來 = =

我怕我傳一傳忘記改回來 後來就先選用安全模式了~

不過我的都不會超時 連檔案最大的W也不會 :-o
神川小羽
調皮の小羽
調皮の小羽
文章: 1461
註冊時間: 2004-05-01 05:55
來自: 謎樣之筱語
聯繫:

文章 神川小羽 »

可否發表一篇完整的安裝程序(中文說明版)我對這套很有興趣,但是實在是有看沒有懂,以上僅建議如此冒昧請求還望見諒。
-.-
夢幻LUGIA
竹貓忠實會員
竹貓忠實會員
文章: 352
註冊時間: 2003-11-16 07:27
來自: 竹貓不忠實會員

文章 夢幻LUGIA »

改php.ini的前提是主機必須是自己的...
若主機是別人的且時間設很短就很麻煩\r
所以才需要安全模式

事實上裝aiml檔就是把東西寫到資料庫裡
如果你有裝過去看看資料庫就知道那有多大...


不懂可以翻字典〈轟
基本上就是照說明裝一裝、改一改程式
然後下載aiml給他灌頂就是了〈歐
neoesque
星球普通子民
星球普通子民
文章: 19
註冊時間: 2003-06-05 17:12
來自: 台灣高雄

文章 neoesque »

專門搞破壞 寫:
neoesque 寫:直接修改...

也可以啦 我之前也是這麼想過

不過...

改完上傳完後記得要再改回來 = =

我怕我傳一傳忘記改回來 後來就先選用安全模式了~

不過我的都不會超時 連檔案最大的W也不會 :-o
那您的php可能沒有打開超時停止的功能
事實上是有的

因為其實我下載了三個版本的AI語言

前兩個即使在安全模式都會逾時= =|||

第三個開了安全模式就不會了(而且全部成功^^)
neoesque
星球普通子民
星球普通子民
文章: 19
註冊時間: 2003-06-05 17:12
來自: 台灣高雄

文章 neoesque »

夢幻LUGIA 寫:改php.ini的前提是主機必須是自己的...
若主機是別人的且時間設很短就很麻煩\r
所以才需要安全模式

事實上裝aiml檔就是把東西寫到資料庫裡
如果你有裝過去看看資料庫就知道那有多大...


不懂可以翻字典〈轟
基本上就是照說明裝一裝、改一改程式
然後下載aiml給他灌頂就是了〈歐
沒錯...

這是很佔空間的東西

我灌完後查了一下

光是AI的資料就已經16.5MB了 :-o

而全部資料庫依共19MB

所以...

在自己電腦上裝比較好 :mrgreen:
.::藍色的天空::.
竹貓忠實會員
竹貓忠實會員
文章: 587
註冊時間: 2003-09-14 17:29
來自: 我不知道
聯繫:

文章 .::藍色的天空::. »

AI 在史上沒人做到 =.=
電腦沒有人腦的感情等等學習功能...
其實找一個人開個腦研究就好了。
i-Web System 隨坊出來耶

新聞:
遊戲區開幕啦! 打造隨城最強的遊戲王國!
宣傳車出動! 賣力宣傳隨坊吧!
版主召募!版主魂激發!
中文好好學,不要方言通天飛
i-Web System 正式版上架測試!
neoesque
星球普通子民
星球普通子民
文章: 19
註冊時間: 2003-06-05 17:12
來自: 台灣高雄

文章 neoesque »

自己隨便翻的

翻不好請見諒^^"

另外有人有做後台的中文化喔 自己找一找\r

因為原來的檔案是附英文的語言檔

代碼: 選擇全部

############################################################## 
## 外掛名稱: Forum AI論壇人工智慧機器人
## Project Homepage/Demo: http://palgn.com/iai/
## 外掛作者: zemaj < zemaj@palgn.com > (James Gay) http://www.palgn.com/
## Description: This mod with give your forums an "artifical intelligence" bot based on the ALICE system
## (& Program E by Paul Rydell) which will respond to users' posts/pms in your forum and chat with users.
## 外掛版本: 0.2.0
##
## 安裝難度: 難\r
## 安裝時間: ~25 分 (再加裝AIML語言可能要在多10分鐘)
## 要修改的檔案: posting.php
##                includes/functions_post.php
##		  privmsg.php
##		  includes/usercp_register.php
## 附加的檔案: 40 (including extra mods)
############################################################## 
## This MOD is released under the GPL License. 
## Intellectual Property is retained by the MOD Author(s) listed above 
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/ 
############################################################## 
## Authors Notes:
##
## It's ALIVE.... welcome to IAI v0.2.0!
##
## PLEASE NOTE: 
## >> this modification is quite different from most mods, I have tried to be quite intensive
## with the installation notes here in order to compensate, but you still need quite some grasp
## of what is going on to get it right.
## At the same time I have also made a few changes to the layout of this file, rather than the usual mod
## template, to make it easier to go through and follow all the various steps which extend beyond
## simply editing a few files. Thus:
##
## - MAKE SURE YOU TAKE NOTE OF THE BEFORE INSTALLATION AND AFTER INSTALLATION PANELS -
##
## New to v0.2.0:
## o various bug fixes (esp. blank posts fix)
## o some degree of coding clean up, but needs more work (I got bored after about 3 hours :P )
## o SRS (Salient Response System) - makes bot give far more salient (succinct and to the point) responses
## o response for private messages to bot's username
## o waaaay better variable tracking
## o customisable welcome message from bot to newly registering users
## o much, much better AIML updating from admin panel
## o move away from various traditional ALICE systems to better suit phpBB/forum systems
## o repositioning of files to better fit phpBB standards
## o improved installation procedure in install.php (now loads initial aiml files at same time)
## o added some intergration mods (note the ChatBox intergration mod - this is REALLY cool ;) )
##
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
\n############################################################## 
## 安裝須知:
## 
## 安裝本外掛之前,請自行備份所有相關檔案以及資料庫,以防不測。
## 
##
##  解壓縮ZIP檔案並將資料夾內全部檔案放置於相對位置\r
##  
## 
##
## 請先確認你已將全部檔案上傳至你PHPBB的位置\r
##
## 在 (phpbb_root_dir)/mods/iai/ 應該有以下三個檔案:
## o install.php
## o upgrade.php
## o uninstall.php
##
## 這是寫入MYAQL的檔案如果妳是全新安裝請使用install.php檔(在網址列打上http://www.yoursite.com/(phpbb_root_dir)/mods/iai/install.php)
##如果妳是升級就用upgrade.php
## 
## Once you have used your respective file, ALL should be deleted for security purposes.
## If you are upgrading then please stop using this file and use UPGRADE.txt
## Otherwise continue with the commands below.
## 
############################################################## 
# 
#-----[ 開啟 ]------------------------------------------ 
#
posting.php

# 
#-----[ 尋找 ]------------------------------------------ 
#
			update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);

# 
#-----[ 之後加入 ]------------------------------------------ 
#
			//
			// Begin IAI system
			//

			// Note: the switch statements here can be quite complicated, so I've used
			// some weird setting out. This helps to show exactly what is going on and
			// allows me to bear down on the problems that were occuring before.

			// Do seed for random replies
			list($usec, $sec) = explode(' ', microtime());
			mt_srand((float) $sec + ((float) $usec * 100000));
			$iai_rand = mt_rand(0, 100);

			// Initial should IAI run check
			$run_iai = 
			(
				(
					$mode == 'newtopic'
					||
					$mode == 'reply'
				) 
				&& 
				(
					$iai_rand <= $board_config['iai_percentage_all']
				) 
				&& 
				(
					$board_config['iai_percentage_all'] != 0
				) 
				&& 
				(
					$board_config['iai_active_all']
				)
			) ? TRUE : FALSE;

			// Check if forum has settings which overide this
			if($post_info['iai_override'])
			{
				$run_iai = (($iai_rand <= $post_info['iai_percentage']) && ($post_info['iai_percentage'] != 0)) ? TRUE : FALSE;
			}

			// If IAI is not currently set to run, then it should find any call words
			// in the post which might overide this.
			// Not in the usual set out, but it allows you to actually understand what's going on.
			if(
				(
					!($run_iai)
				) 
				&&
				( 
					(
						$post_info['iai_override'] 
						&& 
						$post_info['iai_stop_words']
					) 
					|| 
					(
						!($post_info['iai_override']) 
						&& 
						$board_config['iai_active_all']
					)
				)
			)
			{
				// See if there is any match in the respond words array.
				// I know this system is pretty bad (there must be a faster way), but I haven't had much experience with it, so any help would be greatly appreciated
				$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(".", "", $HTTP_POST_VARS['message']);
				$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;
						}
					}
				}
	     		}

			// START IAI response and entry to db (if active)
			if ($run_iai)
			{
				$iai_root_path = $phpbb_root_path . "mods/iai/";
				include($iai_root_path . 'includes/iai_functions.'.$phpEx);
				
				// Initialise variables
				$iai_mode = 'reply';
				$iai_post_id = '';
				$iai_id = $board_config['iai_userid'];
				$iai_subject = '';
				$iai_username = $board_config['iai_username'];
				$iai_topic_type = POST_NORMAL;
				$numselects = 0;
				$user_id = ($userdata['session_logged_in']) ? $userdata['user_id'] : 0;
				// $topic_id should be set already
				$sesh_id = $userdata['session_id']; // should NOT be null in any situation
				$iai_reply_to = str_replace("is " .  $iai_username, "are you", $HTTP_POST_VARS['message']);
				$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;

				// prepare IAI message(IAI may have used html, smilies etc...)
				$bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
				$iai_message = str_replace("'", "''", $iai_message);
				$iai_message = prepare_message(trim($iai_message), 0, 1, 1, $bbcode_uid);

				if ( $error_msg == '' && !empty($iai_message) )
				{
					// Submit IAI's response to DB & update stats
					iai_submit_post($iai_mode, $iai_id, $forum_id, $topic_id, $iai_post_id, $iai_topic_type, 1, 1, 1, 1, $bbcode_uid, str_replace("\'", "''", $iai_username), str_replace("\'", "''", $iai_subject), str_replace("\'", "''", $iai_message));
					iai_update_post_stats($forum_id, $topic_id, $iai_post_id, $iai_id);
				}
			}
			// END IAI response and entry to db

			//
			// END IAI system
			//

# 
#-----[ 開啟 ]------------------------------------------ 
#
includes/functions_post.php

# 
#-----[ 尋找 ]------------------------------------------ 
#
//
// This function will prepare a posted message for
// entry into the database.
//

# 
#-----[ 之前加入 ]------------------------------------------ 
#
//
// Post IAI's response to database
//
function iai_submit_post($mode, &$iai_id, &$forum_id, &$topic_id, &$iai_post_id, &$topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, &$bbcode_uid, &$iai_username, &$iai_subject, &$iai_message)
{
	global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
        
	//Stores user's IP since IAI has none. Can be changed as wished.
	global $user_ip;

	$current_time = time();

	$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ($topic_id, $forum_id, $iai_id, '$iai_username', $current_time, '$user_ip', $bbcode_on, $html_on, $smilies_on, $attach_sig)";
	if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
	{
		message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
	}

	$iai_post_id = $db->sql_nextid();

	$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ($iai_post_id, '$iai_subject', '$bbcode_uid', '$iai_message')";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
	}

	add_search_words($iai_post_id, stripslashes($iai_message), stripslashes($iai_subject));

	return false;
}
//
// Update Stats for IAI: must be run AFTER update_post_stats() for original post
//
function iai_update_post_stats(&$forum_id, &$topic_id, &$iai_post_id, &$iai_id)
{
	global $db;

	//This simply runs the 3 db updating functions (only used for IAI replies).

	$sql = "UPDATE " . FORUMS_TABLE . "
		SET forum_posts = forum_posts + 1, forum_last_post_id = $iai_post_id
		WHERE forum_id = $forum_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
	}

	$sql = "UPDATE " . TOPICS_TABLE . "
		SET topic_last_post_id = $iai_post_id, topic_replies = topic_replies + 1
		WHERE topic_id = $topic_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
	}

	// Comment out the next 7 lines if you don't want user posts to be updated (it will annoy some users otherwise).
	$sql = "UPDATE " . USERS_TABLE . "
		SET user_posts = user_posts + 1
		WHERE user_id = $iai_id";
	if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
	{
		message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
	}

	return;
}
//
// Allows bot to send pms requiring only subject, message and user_id of user it is being sent to.
// I've made it an easy to use function so you can adapt it to use in many situations on your site
// an example is in the welcome message system which is included with this package. The function
// also sends emails (if $send_email set) and does all the inbox checking stuff that normal pms do.
//
function iai_send_pm($user_to_id, $iai_subject, $iai_message, $send_email)
{
	global $board_config, $lang, $db, $phpbb_root_path, $phpEx;

	$sql = "SELECT *
		FROM " . USERS_TABLE . " 
		WHERE user_id = " . $user_to_id . "
		AND user_id <> " . ANONYMOUS;
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Tried obtaining data for a non-existent user', '', __LINE__, __FILE__, $sql);
	}
	$usertodata = $db->sql_fetchrow($result);

	// prepare IAI message (IAI may have used html, smilies etc...)
	$bbcode_uid = make_bbcode_uid();
	$iai_message = str_replace("'", "''", $iai_message);

	// This is to fix up some of the bad formatting which comes out of the AI
	if(empty($iai_message))
	{
		$iai_message = "Thank you.";
	}
	$iai_message = prepare_message(trim($iai_message), 0, 1, 1, $bbcode_uid);

	$msg_time = time();

	// Do inbox limit stuff
	$sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time 
		FROM " . PRIVMSGS_TABLE . " 
		WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " 
			OR privmsgs_type = " . PRIVMSGS_READ_MAIL . "  
			OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) 
			AND privmsgs_to_userid = " . $usertodata['user_id'];
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_MESSAGE, $lang['No_such_user']);
	}

	$sql_priority = ( SQL_LAYER == 'mysql' ) ? 'LOW_PRIORITY' : '';

	if ( $inbox_info = $db->sql_fetchrow($result) )
	{
		if ( $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] )
		{
			$sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . " 
				WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " 
					OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " 
					OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . "  ) 
					AND privmsgs_date = " . $inbox_info['oldest_post_time'] . " 
					AND privmsgs_to_userid = " . $usertodata['user_id'];
			if ( !$db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, 'Could not delete your oldest privmsgs', '', __LINE__, __FILE__, $sql);
			}
		}
	}

	$sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig)
		VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $iai_subject) . "', " . $board_config['iai_userid'] . ", " . $usertodata['user_id'] . ", $msg_time, '$user_ip', 0, 1, 1, 1)";

	if ( !($result = $db->sql_query($sql_info, BEGIN_TRANSACTION)) )
	{
		message_die(GENERAL_ERROR, "Could not insert private message sent info.", "", __LINE__, __FILE__, $sql_info);
	}

	$privmsg_sent_id = $db->sql_nextid();

	$sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)
		VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '" . str_replace("\'", "''", $iai_message) . "')";

	if ( !$db->sql_query($sql, END_TRANSACTION) )
	{
		message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info);
	}

	// Add to the users new pm counter
	$sql = "UPDATE " . USERS_TABLE . "
		SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . "  
		WHERE user_id = " . $usertodata['user_id']; 
	if ( !$status = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
	}

	// now send email if all the usual conditions & $send_email is set
	if ( $send_email && $usertodata['user_notify_pm'] && !empty($usertodata['user_email']) && $usertodata['user_active'] )
	{
		$email_headers = 'From: ' . $board_config['board_email'] . "
Return-Path: " . $board_config['board_email'] . "
";

		$script_name = preg_replace('/^\/?(.*?)\/?$/', "\\\1", trim($board_config['script_path']));
		$script_name = ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx;
		$server_name = trim($board_config['server_name']);
		$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
		$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

		include($phpbb_root_path . 'includes/emailer.'.$phpEx);
		$emailer = new emailer($board_config['smtp_delivery']);
			
		$emailer->use_template('privmsg_notify', $usertodata['user_lang']);
		$emailer->extra_headers($email_headers);
		$emailer->email_address($usertodata['user_email']);
		$emailer->set_subject(); //$lang['Notification_subject']
			
		$emailer->assign_vars(array(
			'USERNAME' => $usertodata['username'], 
			'SITENAME' => $board_config['sitename'],
			'EMAIL_SIG' => str_replace('<br />', "
", "-- 
" . $board_config['board_email_sig']), 

			'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')
		);

		$emailer->send();
		$emailer->reset();
	}

	return;
}

# 
#-----[ 開啟 ]------------------------------------------ 
#
privmsg.php

# 
#-----[ 尋找 ]------------------------------------------ 
#
		$template->assign_vars(array(
			'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("privmsg.$phpEx?folder=inbox") . '">')
		);

# 
#-----[ 之前加入 ]------------------------------------------ 
#
		//
		// START PM SYSTEM FOR IAI
		//

		// Should IAI respond to this pm?
		if (
			(
				$mode != "edit"
			) 
			&& 
			(
				$to_userdata['user_id'] == $board_config['iai_userid']
			) 
			&&
			( 
				$board_config['iai_active_pm']
			)
		)
		{

			$iai_root_path = $phpbb_root_path . "mods/iai/";
			include($iai_root_path . 'includes/iai_functions.'.$phpEx);
				
			// Init IAI specific vars
			$iai_subject = ( ( !preg_match('/^Re:/',  $privmsg_subject) ) ? 'Re: ' : '' ) .  $privmsg_subject;

			// Get IAI reply
			$user_id = ($userdata['session_logged_in']) ? $userdata['user_id'] : 0;
			$topic_id = 0; // the null topic
			$sesh_id = $userdata['session_id']; // should NOT be null in any situation
			$numselects = 0;
			// set bot to reply to subject as well as message as long as subject is not a reply (i.e. has Re: out the front)
			$iai_reply_to = ( ( !preg_match('/^Re:/',  $privmsg_subject) ) ? $privmsg_subject . " " : "" ) . $privmsg_message;
			$iai_reply_to = str_replace("is " . $board_config['iai_username'], "are you", $iai_reply_to);
			$iai_reply_to = str_replace($board_config['iai_username'], "you", $iai_reply_to);
			$iai_reply = reply($iai_reply_to,$user_id,$topic_id,$sesh_id);
			$iai_message = $iai_reply->response;
			
			//
			// START Delete user's message from bot's inbox/user's outbox (it gets too full and wastes space otherwise).
			// Note that this wipes ALL PAST pms in the bot's inbox from the user. This ensures that any backlog of pms
			// sent while bot was inactive are also wiped.
			//
			$sql = "UPDATE " . USERS_TABLE . " 
				SET user_unread_privmsg = user_unread_privmsg - 1 
				WHERE user_id = " . $board_config['iai_userid'];
			if ( !$db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, 'Could not update private message read status for user', '', __LINE__, __FILE__, $sql);
			}
			$sql = "SELECT privmsgs_id
				FROM " . PRIVMSGS_TABLE . "
				WHERE privmsgs_to_userid = " . $board_config['iai_userid'] . " AND (privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )";
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Could not obtain id list to delete all messages', '', __LINE__, __FILE__, $sql);
			}
			$mark_list = array();
			while ( $row = $db->sql_fetchrow($result) )
			{
				$mark_list[] = $row['privmsgs_id'];
			}
			unset($delete_type);

			if ( count($mark_list) )
			{
				$delete_sql_id = implode(', ', $mark_list);
			}

			$delete_text_sql = "DELETE FROM " . PRIVMSGS_TEXT_TABLE . "
						WHERE privmsgs_text_id IN ($delete_sql_id)";
			$delete_sql = "DELETE FROM " . PRIVMSGS_TABLE . "
					WHERE privmsgs_id IN ($delete_sql_id)
					AND privmsgs_to_userid = " . $board_config['iai_userid'] . "
					AND (privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )";

			if ( !$db->sql_query($delete_sql, BEGIN_TRANSACTION) )
			{
				message_die(GENERAL_ERROR, 'Could not delete private message info', '', __LINE__, __FILE__, $delete_sql);
			}

			if ( !$db->sql_query($delete_text_sql, END_TRANSACTION) )
			{
				message_die(GENERAL_ERROR, 'Could not delete private message text', '', __LINE__, __FILE__, $delete_text_sql);
			}
			//
			// END delete sent pms
			//

			// run iai pm send function
			$iai_message = str_replace(".", ". ", $iai_message);
			$iai_message = str_replace("!", "! ", $iai_message);
			$iai_message = str_replace("?", "? ", $iai_message);
			iai_send_pm($userdata['user_id'], $iai_subject, $iai_message, 0);
		}
		//
		// END PM SYSTEM FOR IAI
		//

# 
#-----[ 開啟 ]------------------------------------------ 
#
includes/usercp_register.php

# 
#-----[ 尋找 ]------------------------------------------ 
#
			message_die(GENERAL_MESSAGE, $message);
		} // if mode == register
	}
} // End of submit

# 
#-----[ 之前加入 ]------------------------------------------ 
#
			//
			// START IAI welcome pm message
			//
			$iai_root_path = $phpbb_root_path . "mods/iai/";
			include($iai_root_path.'includes/constants.'.$phpEx);
			if($board_config['iai_active_wpm'])
			{
				$sql = "SELECT *
					FROM " . IAI_BOT_T;
				if(!$result = $db->sql_query($sql))
				{
					message_die(GENERAL_ERROR, "Could not query bot information", "", __LINE__, __FILE__, $sql);
				}
				else
				{
					while($row = $db->sql_fetchrow($result))
					{
						$bot_config[$row['name']] = $row['value'];
					}
				}

				// Just a couple of replaces for better customisation on a per user basis
				// no point making a special function since there are so few needed

				$iai_wpm_subject = str_replace("[username]", $username, $bot_config['iai_wpm_subject']);
				$iai_wpm_subject = str_replace("[user_id]", $user_id, $iai_wpm_subject);
				$iai_wpm_subject = str_replace("[sitename]", $board_config['sitename'], $iai_wpm_subject);
				$iai_wpm_subject = str_replace("[botname]", $bot_config['name'], $iai_wpm_subject);

				$iai_wpm_message = str_replace("[username]", $username, $bot_config['iai_wpm_message']);
				$iai_wpm_message = str_replace("[user_id]", $user_id, $iai_wpm_message);
				$iai_wpm_message = str_replace("[sitename]", $board_config['sitename'], $iai_wpm_message);
				$iai_wpm_message = str_replace("[botname]", $bot_config['name'], $iai_wpm_message);

				// Will not send a pm notification via email (already sent the standard welcome email)
				// Simply change the 0 to a 1 to turn it on
				iai_send_pm($user_id, $iai_wpm_subject, $iai_wpm_message, 0);
			}
			//
			// END IAI welcome pm message
			//

# 
#-----[ 儲存並關閉所有檔案 ]------------------------------------------ 
#
############################################################## 
## 安裝後說明:
## 
## AIML 檔案安裝:
## o 要讓妳的機器人更人性化, 妳須到 http://palgn.com/iai/aiml/
##   並下載 iai_alice.zip (如果妳有額外的空間 妳也可以下載其他檔案).
## o 解壓縮後上傳至 (phpbb_root_dir)/mods/iai/aiml/
## o 到系統管理控制台的Forum AI 點選 "AIML files" 頁面\r
## o 點"學習智慧"(中文版感覺怪怪的英文的話是"INSTALL ALL")
## 妳也可以用相同方式設定妳之後新增的檔案
## 安裝後妳可以從妳的電腦移除AIML檔案在 (phpbb_root_dir)/mods/iai/aiml/ 
## if you wish, as they will stay in the brain untill you click the "Wipe AIML files" button.
## 
## 如果妳的機器人似乎極笨那妳可以安裝更多的AIML或試試以下步驟
## 
##
## Now go through the various pages in the "Forum AI" section of your admin panel and put your
## preferences in.
## o "AI Settings" is for the basic personality/likes/dislikes settings
## o "PM Settings" is for the way your bot sends pms
## o "Forum Settings" is for the way your bot replies to messages in your forum
##
## OTHER MODS:
## Some other mods have an obvious conflict with this mod, so if you are using any of the mods below
## then use their respective text file to fix the problem:
## o "Points Mod" use docs/mod_intergration/iai_points.txt
## o "Send PM On User Registration" use docs/mod_intergration/iai_reg_pm.txt
## o "ChatBox for phpBB2" use docs/mod_intergration/iai_chat_box.txt *** awesome intergration system
## If you make any files which can fix conflicts with other mods then please send them to me so I can
## include them here.
##
## 妳機器人的聊天頁面在 (phpbb_root_dir)/mods/iai/index.html or (phpbb_root_dir)/bot/index.html
## 不是 (phpbb_root_dir)/mods/iai/jsrs/jsrs.php file.
## 妳必須改 (phpbb_root_dir)/bot/ 成 (phpbb_root_dir)/(妳的機器人名稱)/
## 以下的修改也是必須的:
# 
#-----[ 開啟 ]------------------------------------------ 
#
(妳的機器人名稱)/index.html

# 
#-----[ 尋找 ]------------------------------------------ 
#
document.all('ChatPane').innerHTML += '<span id="a' + mycount + '"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Bot: </font></b><font color="#003366">' + returnstring + '</font></font><BR></span>';

# 
#-----[ 在同行中尋找 ]------------------------------------------ 
#
Bot: 

# 
#-----[ 取代 ]------------------------------------------ 
#
(妳的機器人名稱): 

# 
#-----[ 存檔並關閉所有檔案 ]------------------------------------------ 
#
## I haven't templated and left the code raw since people choose to do different things with this page. 
## Some people add it the template of their index.php page.
## A link to it in your header may also be a good idea for some (unless you are pretending the bot is
## an actual user).
##
## >>-------------------------------------------------------<<
##
## Yay, you made it! Congrats. Now have fun chatting with your bot, but remember, winners don't do drugs :|
##
## Make sure you look at http://palgn.com/iai/ for the latest info about this system and how to work with it.
## Anyone who spells zemaj with a capital Z will not recieve support ;)
##
############################################################## 
#
# EoM                                                                                                                                                                                                                                                             
純文字檔按此下載
主題已鎖定

回到「外掛問題討論」