<?php
// Configuration
$satoriSetting              = array();
$satoriSetting['enabled']   = true;
$satoriSetting['userID']    = 9;
$satoriSetting['userName']  = 'Satori';
$satoriSetting['userRank']  = BOTS;
$satoriSetting['userIP']    = '127.0.0.1';


// Parsing
$satoriParse    = strtolower($text);
$satoriParse    = preg_replace('/\\[(?:\\/)?(\\w+)(?:=([^<>]*?))?\\]/ms', '', $satoriParse);
$textParts      = explode(' ', $satoriParse);


// Random Stuff
$defaultResponseArray   = ['What do you want?', 'Kindly fuck off.', 'Don\'t know how to "%s" something.', 'Come again?', 'Satori returned an empty result set (i.e. zero rows).'];
$defaultResponse        = sprintf($defaultResponseArray[array_rand($defaultResponseArray)], $textParts[0]);


// Actions
if(preg_match('/^k$/im', $satoriParse)) {
    $satoriResp = ['Thank you for your amazing and insightful message. It is truly an honour to have this message in my database. I can\'t thank you more than to say go fuck yourself. You truly touched me... Thank you.'];
}
if(preg_match('/^time to break the chat$/im', $satoriParse)) {
    $satoriResp = ['Stay away from me!'];
}
if(preg_match('/^all aboard the sailboat$/im', $satoriParse)) {
    $satoriResp = ['Why would we get on something that is about to sink :^)'];
}


// Reactions
if(preg_match('/^satori/im', $textParts[0])) {
    switch($satoriInput = preg_replace('/^satori? ?/', '', $satoriParse)) {
        case 'version':
            $satoriResp = ['[b][color=Red]S[/color][color=Ruby]a[/color][color=Citrine]t[/color][color=Green]o[/color][color=Teal]r[/color][color=Cobalt]i[/color][/b] Version not [b]6[/b]'];
        break;
        case 'what are you':
            $satoriResp = ['I am nice girl for nice chat.', '[img]http://i.imgur.com/NcFitL2.jpg[/img]'];
        break;
        case 'hi':
            $satoriResp = ['sup'];
        break;
        case 'help':
            $satoriResp = ['If you need help with things refer to the [url=http://flashii.net/r/faq]FAQ[/url].', 'If this didn\'t help you don\'t hesitate to ask an active user.'];
        break;
        case 'why do you exist':
            $satoriResp = ['So you have someone to hate. <3'];
        break;
        case 'suck my dick':
            $satoriResp = ['Do you even have one? Can\'t see it.'];
        break;
        case 'make me admin':
            $satoriResp = ['Why the fuck would you WANT admin? It\'s nothing more than extra work for an ugly red username! Look now the colour for deactivated user, that one\'s fucking hot.'];
        break;
        case 'anime':
            $satoriResp = ['Oh god, i wish i could leave this chat but i\'m stuck in here ;__;'];
        break;
        case 'e':
            $satoriResp = ['Do I look like Nasbot or something?'];
        break;
        case 'meow':
            $satoriResp = ['Mewow!'];
        break;
        case 'puush':
            $satoriResp = ['Something you should be using.'];
        break;
        case 'what is flash\'s password':
        case 'what is flashwave\'s password':
        case 'what is moka\'s password':
            $satoriResp = ['/suicide', 'I do recommend sending it in chat right now.'];
        break;
        case 'what do you think about snailmush':
        case 'what do you like snailmush':
        case 'snailmush':
            $satoriResp = ['I-it\'s not like I like him or-or any-anything...... ;_;'];
        break;
        case 'x snailmush':
        case 'loves snailmush':
        case 'do you love snailmush':
        case 'do you love snailmush?':
            $satoriResp = ['NO!', '[s]Trigger Kick'];
        break;
        case 'saibateku':
            $satoriResp = ['That place is still up?'];
        break;
        case 'titanic':
            $satoriResp = ['Did you mean Sailboat?'];
        break;
        case 'did sailboat sink yet':
            $satoriResp = ['No but I wish it would. Fuck that place. Seems to be getting pretty close however...'];
        break;
        case 'malwareup':
            $satoriResp = ['Good malware discussion forum.'];
        break;
        case 'flashii':
            $satoriResp = ['Mediocre shithole. 0/10'];
        break;
        case 'cybernetics':
            $satoriResp = ['Did you mean "Saibateku"?'];
        break;
        case 'nathat':
            $satoriResp = ['shut up'];
        break;
        case 'waifu':
        case 'inori aizawa':
        case 'internet explorer tan':
            $satoriResp = ['Inori Aizawa Is Mai Waifu.', 'Welcome To Mai Web Browser Is Mai Waifu Land!'];
        break;
        case 'webkit':
        case 'safari':
        case 'blink':
        case 'chrome':
            $satoriResp = [':puke::puke::puke:'];
        break;
        case 'gecko':
        case 'trident':
        case 'internet explorer':
        case 'iexplore':
        case 'firefox':
        case 'mozilla firefox':
            $satoriResp = [':love::love::love:'];
        break;
        case 'bribob':
        case 'bribob4':
            $satoriResp = ['Mediocre faggot. 0/10'];
        break;
        case 'kelopez':
        case 'brante':
            $satoriResp = ['http://en.wikipedia.org/wiki/Mexican'];
        break;
        case 'kamil':
        case 'rakowski':
        case 'kamilrakowski':
            $satoriResp = ['http://en.wikipedia.org/wiki/Jews'];
        break;
        case 'secret':
            $satoriResp = ['I\'m not a secret ripoff, what are you talking about?', '[i]My code is better, time to kill yourself![/i]'];
        break;
        case 'koishi':
            $satoriResp = ['Don\'t fuck with Koishi.'];
        break;
        case ':^)':
            $satoriResp = ['8^)'];
        break;
        case 'nookls':
            $satoriResp = ['HOOOOLLLLLYYYYYYYYYYYYY CRAP NOOKLS IS SO AMAZING WOWOWOWOWOWOW HE\'S ACTUALLY ON THIS SITE WORSHIP WORSHIP AMAZING BRILLIANT I LOVE YOU NOOKLS WE ALL LOVE YOU WE LOVE YOU AS MUCH AS FANGIRLS LOVE JUSTIN BIEBER AAAAAAAAHHHHHHHHHHHH THIS IS THE BEST MOMENT!'];
        break;
        case 'zeniea':
            $satoriResp = ['For whatever reason I have the urge to say "This place smells like a catholic church on crack"...'];
        break;
        case 'zquest':
            $satoriResp = ['Good comic 10/10'];
        break;
        case 'fuck me':
            $satoriResp = [':wtf:'];
        break;
        case 'satori':
            $satoriResp = ['Wait, what are you trying to do?'];
        break;
        case 'satori satori':
            $satoriResp = ['Don\'t fucking do this to me...'];
        break;
        case 'satori satori satori':
            $satoriResp = ['[b][i]I\'ll fucking murder you![/i][/b]'];
        break;
        case 'satori satori satori satori':
            $satoriResp = ['no don\'t'];
        break;
        case 'satori satori satori satori satori':
            $satoriResp = ['please don\'t do this to me'];
        break;
        case 'satori satori satori satori satori satori':
            $satoriResp = ['i have a waifu and kids'];
        break;
        case 'satori satori satori satori satori satori satori':
            $satoriResp = ['okay i was kidding about the kids part'];
        break;
        case 'satori satori satori satori satori satori satori satori':
            $satoriResp = ['rip life'];
        break;
        case 'you are annoying':
        case 'please die':
        case 'die':
            $satoriResp = ['Well I\'m God and you can\'t do shit.'];
        break;
        case 'misaka-20001':
            $satoriResp = ['We\'ll have to move one of these days...', 'The good ol\' Pentium 4 doesn\'t seem to be able to handle shit anymore...'];
        break;
        case 'how old are you':
        case 'how old is flashii':
        case 'how old is koishi':
            $satoriResp = [date_diff(date_create('2013-01-27 22:14:44 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')];
        break;
        case 'how old is zeniea':
        case 'how old is secret':
            $satoriResp = [date_diff(date_create('2011-07-07 00:00:00 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')];
        break;
        case 'how old is zquest':
            $satoriResp = [date_diff(date_create('2013-11-16 00:00:00 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')];
        break;
        case 'are you broken':
        case 'are you broken?':
        case 'is flashii broken':
        case 'is flashii broken?':
            $satoriResp = ['yes'];
        break;
        default:
            $satoriResp = [$defaultResponse];
        break;
    }
}


// Check if disabled
if(!$satoriSetting['enabled'])
    $satoriResp = null;


// Bring the process of sending a message down to one if
if(isset($satoriResp)) {
    foreach($satoriResp as $response) {
        if($response == '[s]Trigger Kick') {
            $this->logout('Kicked');
        } else {
            $this->insertCustomMessage(
                $satoriSetting['userID'],
                $satoriSetting['userName'],
                $satoriSetting['userRank'],
                $this->getChannel(),
                $response,
                $satoriSetting['userIP'],
                0
            );
        }
    }
}
