The programmer's corner.

Please post computer issues here. We will try to help you. Also for showing off your PC.
Post Reply
User avatar
axe_pidy
Gangsta Clucker
Posts: 1336
Joined: Tue May 15, 2012 1:55 pm
KCNR Username: axe_pidy
Location: Mumbai,India
Contact:
Status: Offline

Thu Sep 10, 2015 1:44 pm

Didn't understand shit coz idk about the "rmi" package :3
This is a Signature
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Thu Sep 10, 2015 7:31 pm

axe_pidy wrote:Didn't understand shit coz idk about the "rmi" package :3
https://en.wikipedia.org/wiki/Java_remo ... invocation
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Sun Dec 13, 2015 7:22 pm

Code: Select all

<?php
/**
 * Function: addModule
 * Required Parameter: modulename - Must be equal to Classname and filename.
 * Optional Parameter: IRC Events to attach to - Insert null if not needed.
 * Optional Parameter: IRC Commands - Insert null if not needed.
 * Optional Parameter: Ingame Commands - Insert Null if not needed.
 * Optional Parameter: Ingame Words - Insert null if not needed. Looks for specific word in specific position in IRC Messages it receives.
 */
addModule('TestModule',['PRIVMSG','ON_CONNECT'],['test' => ['trigger' => '!','level' => 0, 'help' => "First command."]],['test' => ['trigger' => '&', 'level' => 0, 'help' => "First Ingame Command"]], ['robbery' => ['position' => 3]]);

/**
 * Class name, class should extend AbstractObserver
 */
class TestModule extends AbstractObserver {
    /**
     * Variable instantation, the comments above the variables are for autocomplete in the IDE.
     */

     /** @var Logger $logger */
    private $logger;
    /**@var AbstractSubject|IrcMessageStringHandler|IrcMessageNumericHandler $subject*/
    private $subject;
    /**@var IRC $irc*/
    private $irc;

    /**
     * Constructor, set the logger and IRC variable here.
     *
     * @param $irc
     */
    public function TestModule($irc) {
        global $logger;
        $this->logger = $logger;
        $this->irc = $irc;
    }

    /** This function is called when data changes elsewhere. E.g. commands/events.
     *
     * @param AbstractSubject $subject_in
     * @param                 $hook
     */
    function update(AbstractSubject $subject_in, $hook) {
        $this->subject = $subject_in;

        /**
         * Switch between the different values that $hook can have.
        */
        switch($hook) {
            case "PRIVMSG":
                /**
                 * If $hook is PRIVMSG, execute the function on_privmsg();.
                 */
                $this->on_privmsg();
                break;
            case "ON_CONNECT":
                /**
                 * if $hook is ON_CONNECT, execute the function on_connect();.
                 */
                $this->on_connect();
                break;
            case "IRC_TEST":
                /**
                 * if $hook is TEST (which is a command), execute the function command();.
                 */
                $this->command();
                break;
            case "IG_TEST":
                /**
                 * if $hook is TEST (which is a command), execute the function command();.
                 */
                $this->command();
                break;
            case "robbery":
                $this->onFindRobbery();
                break;
        }
    }
    /**
     * on_privmsg implementation. Get the object and then send a message to IRC.
    */
    private function on_privmsg() {
        /**@var IrcMessage $ircobject*/
        $ircobject = $this->subject->getPrivmsgobject();
        $this->irc->irc_say($ircobject->getChannel(),$ircobject->getMessage());
    }
    /**
     * on_connect implementation, log that the on_connect hook works fine.
    */
    private function on_connect() {
        /**@var DB $db*/
        global $db;
        $this->logger->log("On_connect hook works.");

        /**
         * Finding data from database table, creating row in database, change data in database and remove data in database.
         */
        $db->find("stats",['what','text'],[['rowid' => ['operator' => '=', 'check' => '1']], ['rowid' => ['operator' => 'OR', 'comparison' => '=', 'check' => '2']]],['rowid' => 'ASC'], ['start' => 0, 'stop' => 10]);
        $db->create("test",["id","name"],["1","test"]);
        $db->change("test",["name"],["name" => "test2"],[['id' => ['operator' => '=', 'check' => '1']]]);
        $db->remove("test",[['id' => ['operator' => '=', 'check' => '1']]]);
    }
    /**
     * command implementation, because test is used for both ingame and irc command, we check which one it really is.
    */
    private function command() {
        /**
         * Retrieve the object containing the data for the IRC Command.
         * @var IrcCmdMessage $ircobject
         */
        $ircobject = $this->subject->getIrccmdobject("test");
        /**
         * Retrieve the object containing the data for the Ingame Command.
         * @var IgCmdMessage $igobject
         */
        $igobject = $this->subject->getIgcmdobject("test");
        /**
         * If it's the one used from IRC, we send a message with "Command executed." to IRC.
        */
        if(!is_null($ircobject)) {
            $this->irc->irc_say($ircobject->getChannel(), "Command executed.");
        }
        /**
         * If it's the one used from ingame, we send a message with all kinds of information to IRC.
         */
        if(!is_null($igobject)) {
            $this->irc->irc_say($igobject->getChannel(), $igobject->getUser()." ".$igobject->getClass()." ".$igobject->getUid()." ".$igobject->getCmd()." - ".implode(" ",$igobject->getMessage()));
        }
    }

    /**
     * On find word implementation, shows a message on IRC when that specific word is found.
     */
    private function onFindRobbery() {
        /**
         * Retrieve the object containing the data for the Ingame Command.
         * @var IrcMessage $igobject
         */
        $igobject = $this->subject->getIngameWordFoundobject();
        $this->irc->irc_say($igobject->getChannel(),$igobject->getMessage()." - Reply from onFindRobbery().");

    }
}

?>
Current module structure of Anonymous v2.



http://selten.github.io/AnonymousV2/
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Sun Dec 13, 2015 11:32 pm

Updated the script above.
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
wasay0029
Clucker
Posts: 226
Joined: Wed Dec 25, 2013 10:12 am
KCNR Username: Jackman
Status: Offline

Mon Dec 14, 2015 7:52 am

Looks great though
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Mon Dec 14, 2015 8:03 am

And this is how Anonymous will be written from now on.
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
wasay0029
Clucker
Posts: 226
Joined: Wed Dec 25, 2013 10:12 am
KCNR Username: Jackman
Status: Offline

Mon Dec 14, 2015 10:47 am

It seems and doesnt seems to be C family at the same time.
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Wed Dec 16, 2015 10:34 pm

Database module examples added.
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Sun Dec 20, 2015 6:21 pm

Core is done at this moment.
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
wasay0029
Clucker
Posts: 226
Joined: Wed Dec 25, 2013 10:12 am
KCNR Username: Jackman
Status: Offline

Sun Dec 20, 2015 9:05 pm

I don't get what you mean by core? Jessica's core?
Post Reply