| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * T3Bot. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @author Frank Nägler <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @link http://www.t3bot.de | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @link http://wiki.typo3.org/T3Bot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | namespace T3Bot\Commands; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * Class BottyCommand. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class BottyCommand extends AbstractCommand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     protected $cats = [':smiley_cat:', ':smile_cat:', ':heart_eyes_cat:', ':kissing_cat:', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         ':smirk_cat:', ':scream_cat:', ':crying_cat_face:', ':joy_cat:' , ':pouting_cat:', ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     protected $responses = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         'daddy' => 'My daddy is Frank Nägler aka <@neoblack>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         'n8' => 'Good night %s! :sleeping:', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         'nacht' => 'Good night %s! :sleeping:', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         'night' => 'Good night %s! :sleeping:', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         'hello' => 'Hello %s, nice to see you!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         'hallo' => 'Hello %s, nice to see you!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         'ciao' => 'Bye, bye %s, cu later alligator! :wave:', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         'cu' => 'Bye, bye %s, cu later alligator! :wave:', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         'thx' => 'You are welcome %s!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         'thank' => 'You are welcome %s!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         'drink' => 'Coffee or beer %s?', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         'coffee' => 'Here is a :coffee: for you %s!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         'beer' => 'Here is a :t3beer: for you %s!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         'coke' => 'Coke is unhealthy %s!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         'cola' => 'Coke is unhealthy %s!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         'cookie' => 'Here is a :cookie: for you %s!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         'typo3' => ':typo3: TYPO3 CMS is the best open source CMS of the world!', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         'dark' => 'sure, we have cookies :cookie:', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         'cat' => 'ok, here is some cat content %s', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         'love' => 'I love you too, %s :kiss:', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     protected $links = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         'My Homepage' => 'http://www.t3bot.de', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         'Github' => 'https://github.com/NeoBlack/T3Bot', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         'Help for Commands' => 'http://wiki.typo3.org/T3Bot', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @return string | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 61 | 40 |  |     public function process() : string | 
            
                                                        
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 63 | 40 |  |         $message = strtolower($this->payload->getData()['text']); | 
            
                                                        
            
                                    
            
            
                | 64 | 40 |  |         $username = '<@' . $this->payload->getData()['user'] . '>'; | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 66 | 40 |  |         if (strpos($message, 'help') !== false) { | 
            
                                                        
            
                                    
            
            
                | 67 | 20 |  |             $result = []; | 
            
                                                        
            
                                    
            
            
                | 68 | 20 |  |             foreach ($this->links as $text => $link) { | 
            
                                                        
            
                                    
            
            
                | 69 | 20 |  |                 $result[] = ":link: <{$link}|{$text}>"; | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 71 | 20 |  |             return implode(' | ', $result); | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 73 | 20 |  |         foreach ($this->responses as $keyword => $response) { | 
            
                                                        
            
                                    
            
            
                | 74 | 20 |  |             $value = $keyword === 'cat' ? $this->cats[array_rand($this->cats)] : $username; | 
            
                                                        
            
                                    
            
            
                | 75 | 20 |  |             if (strpos($message, $keyword) !== false) { | 
            
                                                        
            
                                    
            
            
                | 76 | 20 |  |                 return sprintf($response, $value); | 
            
                                                        
            
                                    
            
            
                | 77 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 78 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 80 | 1 |  |         return ''; | 
            
                                                        
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 82 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 83 |  |  |  |