Jump to content

Chat bot code help


Recommended Posts

I a php based chat bot used for deviant art chat and there is a vend module that simulates and in chat. The commands typed in chat cause the bot to add despense and remove items form a master vending list. I cannot seem get the delete command to work. In chat the command will take and the bot will say the item has been removed however the removed item stays on the list and can be requested again.

 

The codes as follows

<?php

 

// Add drinks using same syntax

global $config;

if(empty($config['vending_machine'])){

$config['vending_machine']=array(

  'coke',

  'diet coke',

  'pepsi',

  'diet pepsi',

  'lemonade',

  'wine',

  'beer',

  'mountain dew',

  'tea',

  'electictocnet doll',

  'sprite',

  'coffee',

  'root beer',

  'hot chocolate',

  'cream soda',

  'fuzzy dice',

);

sort($config['vending_machine']);

}

// Quality of vending machine

// High # = Better quality

// 0 quality always jams

$quality=5;

 

$found=in_array(strtolower($argsE[2]),$config['vending_machine']);

switch(strtolower($args[1])){

case '':

$dAmn->say("$from: Please order something.", $c);

break;

case 'add':

if($found){

$dAmn->say("Can't add, the machine already stocks {$argsE[2]}.", $c);

}else{

$dAmn->say("{$argsE[2]} added!",$c);

$config['vending_machine'][]=strtolower($argsE[2]);

sort($config['vending_machine']);

}

break;

case 'del':

if($found){

$dAmn->say("{$argsE[2]} removed!",$c);

unset($config['vending_machine'][strtolower($argsE[2])]);

}else{

$dAmn->say("Can't remove, the machine doesn't stock {$argsE[2]}.", $c);

}

break;

case 'list':

$dAmn->say("The machine stocks: ".implode(", ",$config['vending_machine']),$c);

break;

default:

if(!in_array(strtolower($argsF),$config['vending_machine'])){

$dAmn->say("$from: The machine doesn't stock {$argsF}.", $c);

return;

}

$items=count($config['vending_machine']);

$max=intval(floor(($items*$quality)+1));

$get=mt_rand(1, $max);

$jam=intval(floor(.5*$items));

$oops=$items;

$i=array_rand($config['vending_machine']);

$vend=$config['vending_machine'][$i];

if($vend==strtolower($argsF)) $get=$oops+1;

if($jam>$get) $dAmn->say("$f It's jammed. :thumb14796735:", $c);

elseif($oops>$get) $dAmn->say("$f You got a {$vend}. :shakefist: ", $c);

else $dAmn->say("$f Here is your {$argsF}.", $c);

break;

}

?>

 

Please let me know if you can help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.