Пример #1
0
     if (count($matches) > 1) {
         $pixelArt = pixelArt($matches[1]);
     } else {
         $pixelArt = pixelArt();
     }
     if ($pixelArt !== false) {
         sendNotification($roomId, $yoda, $userName, $pixelArt, "green", true);
     } else {
         sendNotification($roomId, $yoda, $userName, 'No pixel art was found.', "green", true);
     }
     exit;
 }
 if (preg_match('/^\\/yoda\\s(.+)/', $messageItem->message, $matches) != false) {
     $messageItem->message = $matches[1];
     if (strlen($messageItem->message) <= 255) {
         $translated = getYodaTranslation($messageItem->message) . '<img src="https://yoda.hepforge.org/images/yoda-logo1.png"  height="42" width="37" />';
         sendNotification($roomId, $yoda, $userName, $translated, "green", true);
     } else {
         sendNotification($roomId, $yoda, $userName, '<img src="http://media.tumblr.com/tumblr_m26nvnNG5o1qkk10ro1_500.jpg" width="100" height="90" /><img src="http://mm0030165/projects/yoda/assets/images/yoda.png"  height="42" width="37" />', "green", true);
     }
     exit;
 }
 if (preg_match('/^\\/memelist\\s?(.*)?/i', $messageItem->message, $matches) != false) {
     $memes = memeList();
     $keys = array_keys($memes);
     if (isset($matches[1]) && !empty($matches[1])) {
         $found = [];
         foreach ($keys as $key) {
             if (preg_match('/(?:[\\w\\s]+)?' . $matches[1] . '(?:[\\w\\s]+)?/i', $key)) {
                 $found[] = $key;
             }
Пример #2
0
        Room Id: <input style="width: 30px" type="text" id="roomId" name="roomId" value="46"/>
        Token: <input style="width: 200px" type="text" id="token" name="token" value="9P86U6BNPZ9QfIanjyx0OxAfeCpKJwfoV4XuTlop"/>
    </fieldset>
</form>
</body>
</html>
<?php 
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    error_reporting(0);
    $roomId = $_POST['roomId'];
    $token = $_POST['token'];
    $yodaMode = $_POST['yodaMode'] == 'false' ? false : true;
    $spam = $_POST['spam'];
    $message = $_POST['message'];
    if ($yodaMode) {
        $message = array("message" => getYodaTranslation($message) . '<img src="https://yoda.hepforge.org/images/yoda-logo1.png"  height="42" width="37" />', "message_format" => "html", "color" => "green");
    } else {
        $message = array("message" => $message, "message_format" => "html", "color" => "gray");
    }
    $message = json_encode($message);
    $ch = curl_init('https://chat.mediamonks.local/v2/room/' . $roomId . '/notification?auth_token=' . $token);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: chat.mediamonks.local', 'Content-Type: application/json', 'Cache-Control: no-cache'));
    for ($index = 0; $index <= $spam; $index++) {
        $result = curl_exec($ch);
    }
}