super3 / IRC-Bot

A very little basic IRCBot that will get improved over the next time.
http://www.wildphp.com
102 stars 47 forks source link

Command System #14

Open DanielSiepmann opened 12 years ago

DanielSiepmann commented 12 years ago

Currently all commands are in one folder. The commands aren't configurable.

Change that.

DanielSiepmann commented 12 years ago

Take a little look at the mind map (http://layne.dyndns.org/coding/mindmap_ircbot.pdf)

We'll add a manager that will read all available commands and cache them in a file. If this file exist, he will use this instead of scanning again.

You can add commands or packages (same as modules, just a collection of commands) using the manager.

DanielSiepmann commented 12 years ago

We can use the following to use dynamic namespaces and classes. We need this, because we 'll create namespaces and classnames from the filesystem (http://de3.php.net/manual/en/language.namespaces.dynamic.php):

namespace Test1 {

    class test1 {

        public function getName() {
            return __CLASS__;
        }

    }
}

namespace Test2 {

    class test2 {

        public function getName() {
            return __CLASS__;
        }

    }
}

namespace {
    // Global namespace
    $namespace = 'Test1';
    $classname = 'test1';

    $fullyname = $namespace . $classname;
    $debug = new $fullyname;
    echo $debug->getName();

    $namespace = 'Test2';
    $classname = 'test2';

    $fullyname = $namespace . $classname;
    $debug = new $fullyname;
    echo $debug->getName();
}