| Conditions | 2 |
| Paths | 2 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 47 | public function execute() |
||
| 48 | { |
||
| 49 | $message = $this->getMessage(); |
||
| 50 | |||
| 51 | $chat_id = $message->getChat()->getId(); |
||
| 52 | $text = $message->getText(true); |
||
| 53 | |||
| 54 | $sender = '@' . $message->getFrom()->getUsername(); |
||
| 55 | |||
| 56 | //username validation |
||
| 57 | $test = preg_match('/@[\w_]{5,}/', $text); |
||
| 58 | if ($test === 0) { |
||
| 59 | $text = $sender . ' sorry no one to slap around..'; |
||
| 60 | } else { |
||
| 61 | $text = $sender . ' slaps ' . $text . ' around a bit with a large trout'; |
||
| 62 | } |
||
| 63 | |||
| 64 | $data = [ |
||
| 65 | 'chat_id' => $chat_id, |
||
| 66 | 'text' => $text, |
||
| 67 | ]; |
||
| 68 | |||
| 69 | return Request::sendMessage($data); |
||
| 70 | } |
||
| 71 | } |
||
| 72 |