Quote:
Originally Posted by Lifesupporters
The one question I do have however is in regards to bot configuration. I know how to use the bot and have it configured to answer specific questions but I don't know how to configure the bot for wildcard questions?
Is there a way to configure the bot to reply to wildcard queries that have a portion of text that matches what's been programed in the ACP?
|
I have a solution for this and it seems to be working fine
Edit the includes/class_dm_mgccbchat.php file.
Search for :
PHP Code:
if (strcasecmp($bot['question'],$this->raw_chat) == 0)
and replace it by
PHP Code:
if (stripos($this->raw_chat,$bot['question']) === 0)
Simple ..isn't it? :up:
However this only works on PHP5 ..
Quote:
Originally Posted by VBDev
Edit the includes/class_dm_mgccbchat.php file.
Search for :
PHP Code:
if (strcasecmp($bot['question'],$this->raw_chat) == 0)
{
// Do some replacements
$bot['answer'] = str_replace('{username}',htmlspecialchars($this->registry->userinfo['username']), $bot['answer']);
$bot['answer'] = str_replace('{time}',vbdate($this->registry->options['timeformat'],TIMENOW,true,false), $bot['answer']);
$bot['answer'] = str_replace('{date}',vbdate($this->registry->options['dateformat'],TIMENOW,false,false), $bot['answer']);
// Save the bot answer for sending
$this->bot_answer = $bot['answer'];
$notfound = 0;
}
Replace this by :
PHP Code:
$found = 0;
if (strlen($bot['question']) == strlen($this->raw_chat))
{
if (strncasecmp($bot['question'],$this->raw_chat) == 0)
{
$found = 1; // Same length string and string equals
}
}
else if (strlen(stristr($this->raw_chat,$bot['question']))>0)
{
$found = 1; // Bot question included in part of the chat
}
if ($found)
{
// Do some replacements
$bot['answer'] = str_replace('{username}',htmlspecialchars($this->registry->userinfo['username']), $bot['answer']);
$bot['answer'] = str_replace('{time}',vbdate($this->registry->options['timeformat'],TIMENOW,true,false), $bot['answer']);
$bot['answer'] = str_replace('{date}',vbdate($this->registry->options['dateformat'],TIMENOW,false,false), $bot['answer']);
// Save the bot answer for sending
$this->bot_answer = $bot['answer'];
$notfound = 0;
}
I haven't tested the code and did it quickly @work but if you can try it that would be nice 
|
The code that you have posted did not seem to work well for some reason. :down: It does pick up the text from the string and I get a response from the bot, but for any message I try to post after that, it keeps giving me an error "A previous chat is being posted"
Thanks for this awesome mod