Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ChatAssist [Testing]

Comments in 'Plugin Development' started by Falk, Oct 30, 2013.

  1. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    I am going to try to release a tiny alpha of this plugin tommrow when I have access to a PC. This plugin is inspired by Legomite's plugin it just has less features and does things differently. Basically it has a long (not long yet) priorities list in ifs to create matches with and then if a match is made it will select a random response from an array.

    If anyone has a chance to read through the code or test it out, here it is:

    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=Chat Assistnat
    description=A simple robot to talk to about stuff
    version=0.0.1
    author=Falkirks
    class=chatassist
    apiversion=10
    */
    class chatassist implements Plugin{
    private 
    $api;
    public function 
    __construct(ServerAPI $api$server false){
    $this->api $api;
    }

    public function 
    init(){

    $this->api->console->register("bot""Talk to the robot", array($this"command"));
    console("[Bot] ChatAssist loading...");
    console("[Bot] Please check out Siri by Legomite for my inspriation");
    }

    public function 
    __destruct(){}

    public function 
    command($cmd$params$issuer$alias$args$issuer){
    //Start the stupid response arrays
    $greets = array("Hi there!""Hello""Hey""Hello","Greetings!");
    $killall = array("Enjoy your Deaths!""Happy dying!""My pleasure""Come in here you may roast your goose","Tell me how oblivion is");
    $brightup = array("Here comes the sun!""Avert your eyes!""Go blind yourself""Your wish is my command!","Enjoy the day!");
    $brightup = array("Have fun running into trees""Look at all the stars""Done and done, im so good""*Darkness Falls*","Oooooooo...Monster time");
    $howare = array("Happy to be alive!""Exellent!""Great""Ready!","Life is boring!");
    $expand = array("Sorry I dont understand""The answer is 42""I lose, im crying now""My knowledge has reached its else","I have an issue with apostrophes");
    $iam = array("Sounds useful""Great!""And how does this concern me?""I can do better!","okayyyyyyyy");
    $likeweather = array("Its okay""Dreary as always""It is Awesome? Isnt it?""Weather is great");
    $weather = array("I have no use of weather""Weather is weather!""Last time I checked there was no weather");
    $forecast = array("Looks like sunny with a partial cloud cover""Sun, sun and sun""Remember your sunscreen");
    //End Response arrays
    $subcmd strtolower(implode(" ",$params));
    //Insert Intelligence below this line
    if(strpos($subcmd'time')!==false||strpos($subcmd'brightness')){
    if(
    strpos($subcmd'day')!==false||strpos($subcmd'increase')||strpos($subcmd'light')||strpos($subcmd'up')){
    $this->api->chat->broadcast(array_rand($brightup));
    $this -> api -> console -> run("time set day");
    }
    elseif(
    strpos($subcmd'night')!==false||strpos($subcmd'decrease')||strpos($subcmd'dark')||strpos($subcmd'down')){
    $this->api->chat->broadcast(array_rand($brightup));
    $this -> api -> console -> run("time set night");
    }
    }
    elseif(
    strpos($subcmd,'kill')!==false||strpos($subcmd,'murder')!==false||strpos($subcmd,'slaughter')!==false){
    if(
    strpos($subcmd,'everyone')!==false||strpos($subcmd,'all')!==false) {
        
    $this->api->chat->broadcast(array_rand($killall));
        
    $this -> api -> console -> run("kill @a");
        }
        elseif (
    strpos($subcmd,'random')!==false) {
            
    $this->api->chat->broadcast('Random kills arent ready');
        }
        else {
            
    $this->api->chat->broadcast('Less talk more actual killing');
            
    $this->api->chat->broadcast('Unless PVP is off, then good luck');

        }
       
      }
        elseif(
    strpos($subcmd,'weather')!==false||strpos($subcmd,'forecast')!==false)){
        if (
    strpos($subcmd,'do you')!==false) {
            
    $this->api->chat->broadcast(array_rand($likeweather));

        }
        elseif (
    strpos($subcmd,'what')!==false||strpos($subcmd,'forecast')!==false) {
            
    $this->api->chat->broadcast(array_rand($forecast));
        }
    else {
       
    $this->api->chat->broadcast(array_rand($weather));
    }
    }
     
        elseif(
    strpos($subcmd,'how are you')!==false||strpos($subcmd,'how is it going')!==false||strpos($subcmd,'whats up')!==false||strpos($subcmd,'what is up')!==false){
    $this->api->chat->broadcast(array_rand($howare));
    }
        elseif(
    strpos($subcmd,'how are you')!==false||strpos($subcmd,'how is it going')!==false||strpos($subcmd,'whats up')!==false||strpos($subcmd,'what is up')!==false){
    $this->api->chat->broadcast(array_rand($howare));
    }
    elseif(
    strpos($subcmd,'I am')!==false||strpos($subcmd,'I\'m')!==false||strpos($subcmd,'hi')!==false){
    $this->api->chat->broadcast(array_rand($iam));
    }
    else {
        
    $this->api->chat->broadcast(array_rand($expand));

    }
    }
    }
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Time is too generic it still can cause considerable issues when asking things like "How are you at this time?", Any ideas an how to fix that?
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    lol kill random returns "random kills arent ready".
    So when someone do /bot someone kill me give me any random sword?

    He was already randomly killed, but random kills still arent ready :p
  4. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    I don't see what you mean?
  5. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    looks like a pretty good plugin
  6. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    I have fixed most of the bugs in the code, hope to release when I have a computer that uploads it
  7. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    You made it so it can do random responses? Cool!
  8. VanishedKevin
    Offline

    VanishedKevin Banned

    Joined:
    Aug 27, 2013
    Posts:
    279
    Minecraft User:
    VanishedKevin
    You need to have a AI engine for it.
  9. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Wish I knew how to do that :(
  10. VanishedKevin
    Offline

    VanishedKevin Banned

    Joined:
    Aug 27, 2013
    Posts:
    279
    Minecraft User:
    VanishedKevin
    You can use some AI Web API.

Share This Page

Advertisement