[ABD] Forum AI v0.2.0

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Locked
User avatar
morpheus2matrix
Former Team Member
Posts: 9171
Joined: Wed Apr 10, 2002 7:31 pm
Location: France
Contact:

Post by morpheus2matrix »

this is the MOD's i'm using :

Code: Select all

- Attachment MOD of Acyd Burn 
- Last visit MOD of Niels Chr Denmark 
- BirthDay MOD of Niels Chr Denmark 
- Quick Reply MOD of Ralendil (i've solved a problem with the name of the form tag) 
- View Profile Sig MOD of netclectic 
- Mini Cal MOD of netclectic (also a little modify by me  ) 
- phpBB SpellCheck MOD of the Team phpSpell (Ifroggy & Nathan_Anderson) 


and i don't use activation link :cry:

maybe it's because i've phpBB 2.0.4 ?
Former phpBB MOD-Team Member -

Forgive my bad English :(

No support by PM/Email - Thanks - You can thanks me here :) - Pay me for installing MOD's :lol:
zemaj
Registered User
Posts: 267
Joined: Thu Mar 07, 2002 3:58 am
Location: Australia
Contact:

Post by zemaj »

No, I'm running 2.0.4

-zem
User avatar
morpheus2matrix
Former Team Member
Posts: 9171
Joined: Wed Apr 10, 2002 7:31 pm
Location: France
Contact:

Post by morpheus2matrix »

so you have no ideas ?
Former phpBB MOD-Team Member -

Forgive my bad English :(

No support by PM/Email - Thanks - You can thanks me here :) - Pay me for installing MOD's :lol:
ianwarren
Registered User
Posts: 37
Joined: Sat Feb 01, 2003 7:34 pm
Location: UK

I'm tired!

Post by ianwarren »

I've just read all 43 pages of this thread, this MOD sounds really 8)
I'm going to install it once I have finished setting up my board (other MOD's to add first!)

As far as making it learn quicker, can you tell me does it read all the posts and only reply to those it's told to? If not it should as it would 'learn' more!
I am now really interested in the way it processes info and how the language is controlled, if anyone has any links to info that may help me learn the original coding for ALICE please post them.

Hopefully I might be able to make it more intelligent. My first aim will be to get it to understand what things are ie blue is a colour;description whilst a rock is an item;no gender

I can see I'm going to lose years of my life trying to make it more intelligent!
ianwarren
Registered User
Posts: 37
Joined: Sat Feb 01, 2003 7:34 pm
Location: UK

how long?

Post by ianwarren »

before I download v0.2.0 how long will v1.0.0 be as you said in december it would only be a month and it will save me all the hassle of manually fixign the remaining few bugs!
(Yeah, I know I'm lazy but if your doing it anyway there no point us both sorting it :wink: )
Budweiser
Registered User
Posts: 18
Joined: Sat Dec 28, 2002 3:06 pm
Contact:

Post by Budweiser »

i have just installed it on phpbb 2.0.4.

when i post something i get the error

Fatal error: Call to undefined function: iai_submit_post() in /home/signumbv/public_html/raymond/posting.php on line 737


anyone has tips?
--------------------8<---------(Cut at this line)--------------------------------------------
craigkoh
Registered User
Posts: 17
Joined: Mon Jan 06, 2003 2:23 pm
Contact:

Post by craigkoh »

I installed this 2.0.4 and had no problems, I did not install the part to send a PM to new users.

I LOVE THIS MOD. I installed it without telling any of my users, it has been a funny couple of days. Please continue support, this a Great thing to add to your forum!!!!!
zemaj
Registered User
Posts: 267
Joined: Thu Mar 07, 2002 3:58 am
Location: Australia
Contact:

Post by zemaj »

BTW - I've recently discovered how to use cron jobs. I had a though that it would be relatively easy to get the bot to response within a few mins after the post which it is replying to.

Would anyone be interested in this? I not long run the mod on my forums, but if anyone's interesting and can test it for me, then I'll make it. You'll need the ability to run cron jobs on your site.

-zem
kfc
Registered User
Posts: 403
Joined: Thu Jun 27, 2002 7:23 am

Post by kfc »

..
ianwarren
Registered User
Posts: 37
Joined: Sat Feb 01, 2003 7:34 pm
Location: UK

Yep

Post by ianwarren »

Having read this whole 40+ page thread one of the main things people wanted was cron jobs and when I eventually get to install this on a test board I will be happy to test it for you.
FMC Sponge
Registered User
Posts: 7
Joined: Tue Feb 11, 2003 5:26 pm
Contact:

Post by FMC Sponge »

Is there any way to keep the bots posts from counting against the total post count on the board?
ianwarren
Registered User
Posts: 37
Joined: Sat Feb 01, 2003 7:34 pm
Location: UK

Post by ianwarren »

FMC Sponge
Is there any way to keep the bots posts from counting against the total post count on the board?

Easy answer: yes
Problem: I can't remember where in the 40+ pages it fix is, sorry :roll:
zemaj
Registered User
Posts: 267
Joined: Thu Mar 07, 2002 3:58 am
Location: Australia
Contact:

Post by zemaj »

Ok, I got a little sidetracked on adding a new system to my site, but I'll try to get the cron jobs done when I have a spare moment (or get too pissed off with the debugging the thing I'm currently working on ;) ).

FMC Sponge: assuming you have basic php knowledge you can find the iai_update_stats() function in the includes/functions_post.php file and edit out the part that updates the Bot's post count. I think it's pretty obvious (from memory).

Actually stuff it, I'll do the cron jobs now. It shouldn't take too long.

Opps, I never posted this message. Oh well I've finished the cron job thingy. Here's the code:

NOT TESTED.

Code: Select all

##############################################################
## MOD Title: Forum AI Post Delay
## Project Homepage/Demo: http://palgn.com/iai/
## MOD Author: zemaj < zemaj@palgn.com > (James Gay) http://www.palgn.com/
## Description: This mod edits your Forum AI and adds a delay in the posting time
## so it posts more like a normal user.
## MOD Version: 0.1.0
##
## Installation Level: Easy
## Installation Time: ~3 Minutes
## Files To Edit: posting.php
##                includes/functions_post.php
##                mods/iai/includes/constants.php
## Included Files: 1
############################################################## 
## 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:
##
## This adds a delay to your bot's posting. If someone else has posted since the bot is replying,
## then the bot quotes the post it is responding to, so we know who it is.
##
## You need IAI v0.2.0 installed and the abilty to add cron jobs on your server to run this.
##
## Once you have done the editing below you will need to add iai_cron.php as a cron job to be run
## every minute. e.g. * * * * * lynx -dump http://yoursite.com/iai_cron.php
##
## In order to change the time between which the bot responds you can edit the second replace below.
## I have made it obvious what to edit.
##
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
#
# Table structure for table 'iai_cron_posts'
#
CREATE TABLE iai_cron_posts (
   post_id int(11) NOT NULL,
   topic_id int(11) NOT NULL,
   forum_id int(11) NOT NULL,
   post_subject text,
   post_text text,
   bbcode_uid varchar(255),
   past_post_id int(11) NOT NULL,
   update_time int(11) NOT NULL,
);

#
#-----[ OPEN ]------------------------------------------ 
#
includes/functions_post.php

# 
#-----[ FIND ]------------------------------------------ 
#
//
// 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;
}

# 
#-----[ REPLACE WITH ]------------------------------------------
#
//
// Prepare IAI's post to submitted with in the cron job.
//
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, &$update_time)
{
        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 = "SELECT topic_last_post_id
                FROM " . TOPICS_TABLE . "
                WHERE topic_id = $topic_id";
        if ( !($result = $db->sql_query($sql)) )
        {
                message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }
        $past_post = $db->sql_fetchrow($result);
        $past_post_id = $past_post['topic_last_post_id'];

        $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 (0, 0, $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 " . IAI_CRON_TABLE . " (post_id, topic_id, forum_id, post_subject, post_text, bbcode_uid, past_post_id, update_time) VALUES ($iai_post_id, $topic_id, $forum_id, '$iai_subject', '$iai_message', '$bbcode_uid', $past_post_id, $update_time)";
        if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
        {
                message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }

        return false;
}

#
#-----[ OPEN ]------------------------------------------
#
posting.php

#
#-----[ FIND ]------------------------------------------
#
                                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);
                                }

#
#-----[ REPLACE WITH ]------------------------------------------
#
                                if ( $error_msg == '' && !empty($iai_message) )
                                {
                                        // You can edit the two values below to set the minimum and maximum time
                                        // in minutes to wait before posting the message. A random time will be
                                        // choosen between the two.
                                        $minimum_time = 0; //in mins
                                        $maximum_time = 10; //in mins
                                        $add_mins = mt_rand($minimum_time, $maximum_time);
                                        $update_time = time() + ($add_mins * 60);
                                        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), $update_time);
                                }

#
#-----[ OPEN ]------------------------------------------
#
mods/iai/includes/constants.php

#
#-----[ FIND ]------------------------------------------
#
define('IAI_THATIDEX_T', $iai_prefix.'thatindex');
define('IAI_THATSTACK_T', $iai_prefix.'thatstack');
define('IAI_GMCACHE_T', $iai_prefix.'gmcache');

#
#-----[ ADD AFTER ]------------------------------------------
#
define('IAI_CRON_TABLE', $iai_prefix.'cron_posts');

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

Code: Select all

<?php
/***************************************************************************
 *                                iai_cron.php
 *                            -------------------
 *   copyright            : (C) 2003 James Gay
 *   email                : zemaj@palgn.com
 *
 ***************************************************************************/
/***************************************************************************
 *
 *   This *should* check & update IAI posts where needed when called.
 *   To use set this page as a cron jobs to run every minute.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path='./';
include($phpbb_root_path.'extension.inc');
include($phpbb_root_path.'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include($phpbb_root_path . 'includes/functions_post.'.$phpEx);

// Grab all our data
$sql = "SELECT c.*, pt.post_text AS past_message, pt.bbcode_uid AS past_bbcode_uid, p.post_username, t.topic_last_post_id
        FROM " . IAI_CRON_TABLE . " c, " . POSTS_TEXT_TABLE . " pt, " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
        WHERE c.update_time < " . time() . "
                AND pt.post_id = c.past_post_id
                AND p.post_id = c.past_post_id
                AND t.topic_id = p.topic_id";
if ( !($result = $db->sql_query($sql)) )
{
        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}
$posts = $db->sql_fetchrowset($result);
if($total_posts = count($posts))
{
        for( $i = 0; $i < $total_posts; $i++ )
        {
                // Int vars
                $iai_post_id = $posts[$i]['post_id'];
                $topic_id = $posts[$i]['topic_id'];
                $forum_id = $posts[$i]['forum_id'];
                $iai_subject = $posts[$i]['post_subject'];
                $bbcode_uid = $posts[$i]['post_text'];
                $iai_message = $posts[$i]['bbcode_uid'];
                $current_time = time();

                if($posts[$i]['topic_last_post_id'] != $posts[$i]['past_post_id'])
                {
                        // New posts in thread since this reply was set...
                        // Now we have to add old text in a quote. Fun.
                        $past_message = preg_replace('/\:(([a-z0-9]:)?)' . $posts[$i]['past_bbcode_uid'] . '/s', '', $posts[$i]['past_message']);
                        $iai_message = preg_replace('/\:(([a-z0-9]:)?)' . $bbcode_uid . '/s', '', $iai_message);
                        $iai_message = '[quote="' . $posts[$i]['post_username'] . '"]' . $past_message . '[/quote]' . $iai_message;
                        // Parse with new bbcode
                        $bbcode_uid = make_bbcode_uid();
                        $iai_message = bbencode_first_pass($iai_message, $bbcode_uid);
                }

                $sql = "UPDATE " . POSTS_TABLE . "
                        SET topic_id = $topic_id, forum_id = $forum_id, post_time = $current_time
                        WHERE post_id = $iai_post_id";
                if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
                {
                        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
                }

                $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));

                iai_update_post_stats($forum_id, $topic_id, $iai_post_id, $board_config['iai_userid']);

                // Updating complete! Remove this cron job!
                $sql = "DELETE FROM " . IAI_CRON_TABLE . "
                        WHERE post_id = $iai_post_id";
                if ( !($result = $db->sql_query($sql)) )
                {
                        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
                }

        }
}
?>
Whipped it up in half an hour or so. It was a little more complicated than I thought it might be, but everything should still run smoothly.

I haven't tested this AT ALL, so if anyone does, please do not do try it on a live forum.

Please use debug mode and post the full errors if you get any.

Cheers,

-zemaj
FMC Sponge
Registered User
Posts: 7
Joined: Tue Feb 11, 2003 5:26 pm
Contact:

Post by FMC Sponge »

zemaj wrote: FMC Sponge: assuming you have basic php knowledge you can find the iai_update_stats() function in the includes/functions_post.php file and edit out the part that updates the Bot's post count. I think it's pretty obvious (from memory).


yes, zemaj, I figured it out. Thanks, and thanks for the great work here. My forum users have nominated our bot for president. :D
Xiph3r
Registered User
Posts: 342
Joined: Sun Oct 27, 2002 8:21 pm
Location: the wired
Contact:

Post by Xiph3r »

does the iai bot work with subforums yet?
Locked

Return to “[2.0.x] MODs in Development”