Exemplo n.º 1
1
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     if ($discord->bot) {
         $appId = isset($config['app_id']) ? $config['app_id'] : '157746770539970560';
         $message->reply("This bot can't accpet invites, sorry! Please use this OAuth invite link: https://discordapp.com/oauth2/authorize?client_id={$appId}&scope=bot&permissions=36703232");
         return;
     }
     if (preg_match('/https:\\/\\/discord.gg\\/(.+)/', $params[0], $matches)) {
         $invite = $discord->acceptInvite($matches[1]);
         $message->reply("Joined server {$invite->guild->name}");
     }
 }
Exemplo n.º 2
1
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     if (preg_match('/https:\\/\\/discord.gg\\/(.+)/', $params[1], $matches)) {
         $invite = $discord->acceptInvite($matches[1]);
         $message->reply("Joined server {$invite->guild->name}");
     }
 }
Exemplo n.º 3
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[0])) {
         $message->reply('Please pass through a guild name.');
         return;
     }
     $guild = implode(' ', $params);
     $guild = $discord->guilds->get('name', $guild);
     if (is_null($guild)) {
         $message->reply('Could not find the guild!');
         return;
     }
     foreach ($guild->channels as $channel) {
         try {
             $invite = $channel->createInvite();
         } catch (DiscordRequestFailedException $e) {
             echo "Error attempting to create invite: {$e->getMessage()}\r\n";
             continue;
         }
         $message->author->sendMessage("Invite: {$invite->invite_url}");
         $message->reply('Invite sent in PM.');
         return;
     }
     $message->reply('Was unable to create an invite for "' . $guild->name . '"');
 }
Exemplo n.º 4
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     $bot->websocket->getVoiceClient($message->full_channel->guild_id)->then(function ($vc) use($message) {
         $message->reply('Leaving voice channel...');
         $vc->close();
     }, function ($e) use($message) {
         $message->reply('Could not find a voice channel for this guild.');
     });
 }
Exemplo n.º 5
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $prefix = isset($params[0]) ? $params[0] : $config['prefix'];
     $config['prefix'] = $prefix;
     Config::saveConfig($config, $config['filename']);
     $message->reply("Set the prefix to `{$prefix}`");
 }
Exemplo n.º 6
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     $guilds = '';
     foreach ($discord->guilds as $guild) {
         $guilds .= "{$guild->name}, ";
     }
     $message->reply(rtrim($guilds, ', '));
 }
Exemplo n.º 7
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[1])) {
         return;
     }
     try {
         eval('$response = ' . implode(' ', $params) . ';');
         if (is_string($response)) {
             $response = str_replace(DISCORD_TOKEN, 'TOKEN-HIDDEN', $response);
             $response = str_replace($config['password'], 'PASSWORD-HIDDEN', $response);
             $response = str_replace($config['sudo_pass'], 'SUDO-HIDDEN', $response);
         }
         $message->reply("`{$response}`");
     } catch (\Exception $e) {
         $message->reply("Eval failed. {$e->getMessage()}");
     }
 }
Exemplo n.º 8
0
 public function actionReply()
 {
     RoutingEngine::setPage("Messages | runnDAILY", "PV__300");
     $message = new Message($_POST);
     //TODO:add in error exception in case the message cannot be created
     if ($message->reply()) {
         Message::updateCount($message->uid_to, 1);
     }
     Page::redirect("/messages");
 }
Exemplo n.º 9
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[0])) {
         $message->reply('Please provide a string to make fancy!');
         return;
     }
     $orig = implode(' ', $params);
     $string = str_split($orig);
     $finalString = '';
     $fancy = function () use(&$fancy, &$string, &$finalString, $orig) {
         $finalString .= implode(' ', $string) . PHP_EOL;
         $string[] = array_shift($string);
         if (implode('', $string) != $orig) {
             $fancy();
         }
     };
     $fancy();
     $message->reply("```{$finalString}```");
 }
Exemplo n.º 10
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $rmmessages = isset($params[0]) ? $params[0] : 15;
     $channel = $message->channel;
     $num = 0;
     $channel->message_count = $rmmessages + 1;
     foreach ($channel->messages as $key => $message) {
         if ($num >= $rmmessages) {
             $message->reply("Flushed {$num} messages.");
             return;
         }
         try {
             $message->delete();
         } catch (PartRequestFailedException $e) {
             continue;
         }
         $num++;
     }
     $message->reply("Flushed {$num} messages.");
 }
Exemplo n.º 11
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[0])) {
         $message->reply('Please enter a channel name!');
         return;
     }
     $channelName = implode(' ', $params);
     $channel = $message->full_channel->guild->channels->get('name', $channelName);
     if (is_null($channel)) {
         $message->reply('Couldn\'t find that channel!');
         return;
     }
     $bot->websocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use($message, &$bot) {
         $message->reply("Joined voice channel.");
         $vc->on('stderr', function ($data) use($message) {
             $message->channel->sendMessage("**stderr:** {$data}");
         });
     }, function ($e) use($message) {
         $message->reply("Oops, there was an error joining the voice channel: {$e->getMessage()}");
     });
 }
Exemplo n.º 12
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     if (isset($params[1])) {
         $user = $params[1];
         $level = isset($params[2]) ? $params[2] : 2;
         if (preg_match('/<@([0-9]+)>/', $user, $matches)) {
             $user = $matches[1];
         }
         $config['perms']['perms'][$user] = $level;
         Config::saveConfig($config);
         $message->reply("Set user <@{$user}> auth level to {$config['perms']['levels'][$level]}");
     }
 }
Exemplo n.º 13
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[0])) {
         return;
     }
     set_error_handler(function ($errno, $errstr) {
         if (!(error_reporting() & $errno)) {
             return;
         }
         echo "[Eval Error] {$errno} {$errstr}\r\n";
         throw new \Exception($errstr, $errno);
     }, E_ALL);
     try {
         $params = implode(' ', $params);
         $params = str_replace('```', '', $params);
         $params = "<?php\r\n" . $params;
         $fileName = BOT_DIR . '/eval/' . Str::random();
         file_put_contents($fileName, $params);
         // lint
         $lint = shell_exec('php -l ' . $fileName);
         if (strpos($lint, 'Errors parsing') !== false) {
             $message->reply("Erorrs linting the file: ```{$lint}```");
             restore_error_handler();
             return;
         }
         $response = (require_once $fileName);
         if (is_string($response)) {
             $response = str_replace(DISCORD_TOKEN, 'TOKEN-HIDDEN', $response);
             $response = str_replace($config['token'], 'TOKEN-HIDDEN', $response);
         }
         $message->reply("```\r\n{$response}\r\n```");
     } catch (\Throwable $e) {
         $message->reply("Eval failed. {$e->getMessage()}");
     }
     restore_error_handler();
 }
Exemplo n.º 14
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     $str = "**Commands:** \r\n";
     $user_level = isset($config['perms']['perms'][$message->author->id]) ? $config['perms']['perms'][$message->author->id] : $config['perms']['default'];
     foreach ($bot->getCommands() as $command => $data) {
         if ($user_level >= $data['perms']) {
             $str .= "**_{$config['prefix']}{$command}_**";
             if (!empty($data['usage'])) {
                 $str .= " - _{$data['usage']}_";
             }
             $str .= "\r\n\t{$data['description']}\r\n";
         }
     }
     $message->reply($str);
 }
Exemplo n.º 15
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $str = "**DiscordPHP Bot**\r\n";
     $str .= "**Library:** _DiscordPHP_ " . Discord::VERSION . "\r\n";
     $sha = substr(exec('git rev-parse HEAD'), 0, 7);
     $str .= "**Current Revision:** `{$sha}`\r\n";
     $str .= "**PHP Version:** " . PHP_VERSION . "\r\n";
     $uptime = Carbon::createFromTimestamp(DISCORDPHP_STARTTIME);
     $diff = $uptime->diff(Carbon::now());
     $str .= "**Uptime:** {$diff->d} day(s), {$diff->h} hour(s), {$diff->i} minute(s), {$diff->s} second(s)\r\n";
     $ram = round(memory_get_usage(true) / 1000000, 2);
     $str .= "**Memory Usage:** {$ram}mb\r\n";
     $str .= "**OS Info:** " . php_uname() . "\r\n";
     $str .= "**Source:** <https://github.com/uniquoooo/DiscordPHPBot>\r\n";
     $str .= "\r\n**Author:** David#9512 `78703938047582208`\r\n";
     $str .= "**Server Count:** {$discord->guilds->count()}\r\n";
     $message->reply($str);
 }
Exemplo n.º 16
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[0])) {
         $str = "Please provide a song:\r\n";
         foreach (glob($config['music_path'] . '/*') as $song) {
             $str .= "\t{$song}\r\n";
         }
         if (strlen($str) > 2000) {
             $chunks = str_split($str, 1800);
             $chunk = array_shift($chunks);
             $message->reply($chunk);
             foreach ($chunks as $chunk) {
                 $message->channel->sendMessage($chunk);
             }
         } else {
             $message->reply($str);
         }
         return;
     }
     $params = implode(' ', $params);
     if (!file_exists($config['music_path'] . '/' . $params)) {
         $message->reply('The file ' . $config['music_path'] . '/' . $params . ' does not exist!');
         return;
     }
     $bot->websocket->getVoiceClient($message->full_channel->guild_id)->then(function ($vc) use($config, $params, $message) {
         $message->reply('Playing song...');
         $vc->playFile($config['music_path'] . '/' . $params)->then(function () use($message) {
             $message->reply('Finished playing song.');
         }, function ($e) use($message) {
             $message->reply("Error playing file: {$e->getMessage()}");
         }, function ($meta) use($message) {
             $response = "**Song Info:**\r\n\r\n";
             $response .= "**Title:** {$meta['info']['title']}\r\n";
             $response .= "**Artist:** {$meta['info']['artist']}\r\n";
             $response .= "**Album:** {$meta['info']['album']}\r\n";
             $message->channel->sendMessage($response);
             if (isset($meta['info']['cover'])) {
                 $filename = BOT_DIR . '/eval/' . Str::random() . '.jpg';
                 file_put_contents($filename, base64_decode($meta['info']['cover']));
                 $message->channel->sendFile($filename, "Song Cover - {$meta['info']['title']}.jpg");
             }
         });
     }, function ($e) use($message) {
         $message->reply('Could not find an attached voice channel. Please run ' . $config['prefix'] . 'voice <channel-name> before you try to play a song.');
     });
 }
Exemplo n.º 17
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $memes = json_decode(file_get_contents('./command_files/dank_memes.json'), true);
     $message->reply($memes[array_rand($memes)]);
     //$message->reply("Did I ever tell you what the definition of insanity is? Insanity is doing the exact... same f*****g thing... over and over again expecting... shit to change... That. Is. Crazy. The first time somebody told me that, I dunno, I thought they were bullshitting me, so, I shot him. The thing is... He was right. And then I started seeing, everywhere I looked, everywhere I looked all these f*****g pricks, everywhere I looked, doing the exact same f*****g thing... over and over and over and over again thinking 'this time is gonna be different' no, no, no please... ");
 }
Exemplo n.º 18
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     $userlevel = isset($config['perms']['perms'][$message->author->id]) ? $config['perms']['perms'][$message->author->id] : 1;
     $message->reply("Your current level: {$config['perms']['levels'][$userlevel]}");
 }
Exemplo n.º 19
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     $choices = ['It is certain', 'It is decidedly so', 'Without a doubt', 'Yes, definitely', 'You may rely on it', 'As I see it, yes', 'Most likely', 'Outlook good', 'Yes', 'Signs point to yes', 'Reply hazy try again', 'Ask again later', 'Better not tell you now', 'Cannot predict now', 'Concentrate and ask again', 'Don\'t count on it', 'My reply is no', 'My sources say no', 'Outlook not so good', 'Very doubtful'];
     $message->reply($choices[array_rand($choices)]);
 }
Exemplo n.º 20
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     $sides = ['Heads', 'Tails'];
     $message->reply($sides[array_rand($sides)]);
 }
Exemplo n.º 21
0
function iterate($offset)
{
    $file = Api::getUpdates((string) $offset);
    for ($i = 0; $i < count($file); $i++) {
        $current = new Message($file[$i]);
        $offset = max($current->updateId, $offset) + 1;
        $cityLevel = [['Алматы'], ['Астана'], ['Шымкент'], ['Тараз'], ['Кызылорда'], ['Атырау'], ['Актау'], ['Караганда'], ['Павлодар'], ['Семипалатинск'], ['Костанай'], ['Петропавловск'], ['Талдыкорган'], ['Кокшетау']];
        $firstLevel = [['Услуги'], ['Акции'], ['Проверить Баланс'], ['Адреса, контакты'], ['Отправить запрос о неполадках'], ['Приложения АЛМА-ТВ']];
        $secondLevel = [['Телевидение'], ['Интернет'], ['Интернет + ТВ'], ['TV BOX']];
        // $current->reply("Ima got your text with {$current->text()}");
        if ($current->text() == '/start') {
            $current->replyCode('Добро пожаловать! Вас приветствует официальный бот АЛМА-ТВ' . '%0A' . 'Чтобы продолжить выберите ваш город:', $cityLevel);
        }
        if ($current->text() == 'Павлодар') {
            $current->replyDropDown("Выберите:", $firstLevel);
        }
        if ($current->text() == 'Алматы') {
            $current->replyDropDown("Выберите:", $firstLevel);
        }
        if ($current->text() == 'Шымкент') {
            $current->replyDropDown("Выберите:", $firstLevel);
        }
        if ($current->text() == 'Услуги') {
            $current->replyDropDown("Выберите:", $secondLevel);
        }
        if ($current->text() == 'Акции') {
            $current->reply('Уважаемые дамы и господа!' . '%0A' . 'АЛМА-ТВ запускает новогоднюю акцию, которая позволяет сэкономить до 10 000 тенге.' . '%0A' . 'При внесении предоплаты за 12 и более месяцев, предоставляются скидки:' . '%0A' . '-     на пакеты «TV100+» и «Антенна80+» - скидка 18%' . '%0A' . '-      на пакеты «TVMAX» и «AntennaMAX» -скидка в 24%.' . '%0A' . 'Специальное предложение, действует до 31 января 2016 года.');
        }
        if ($current->text() == 'Адреса, контакты') {
            $current->replyDropDown("Выберите:", $secondLevel);
        }
        if ($current->text() == 'Отправить запрос о неполадках') {
            $current->replyDropDown("Выберите:", $secondLevel);
        }
        if ($current->text() == 'Приложения АЛМА-ТВ') {
            $current->reply('Приложение “Alma TV” позволяет получить мгновенный доступ к балансу Вашего счёта, телепрограмме и многому другому. Дополнительно, у пользователя есть возможность отправки заявок на подключение или ремонт в несколько простых шагов.
        Для проверки баланса требуется быть абонентом компании «АЛМА-ТВ», остальные функции доступны всем пользователям. Возможность управления Вашим счётом и множество иных функций появятся в следующих версиях приложения.' . '%0A' . 'Для скачивания приложения ALMA-TV на Android перейдите по ссылке: ' . '%0A' . 'Приложение "TV BOX". Смотрите любимые передачи, как на телевизоре, так и на мобильных устройствах.
        Сортируйте каналы по жанрам, ставьте видео на паузу и перематывайте, выбирайте звуковую дорожку и качество изображения. Подробнее об этих и других функциях TV Box на сайте tv-box.kz' . '%0A' . 'Для скачивания приложения TV BOX на Ваше мобильное устройство, пройдите по ссылкам:', $secondLevel);
        }
        echo "==> Message text {$current->text()} \n\r";
    }
    echo "==> Setup new offset {$offset}\n\r";
    return $offset;
}
Exemplo n.º 22
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $memes = ['dank meme', '>mfw no gf', "m'lady *tip*", 'le toucan has arrived', "jet juel can't melt dank memes", '༼ つ ◕_◕ ༽つ gibe', 'ヽ༼ຈل͜ຈ༽ノ raise your dongers ヽ༼ຈل͜ຈ༽ノ', 'ヽʕ •ᴥ•ʔノ raise your koalas ヽʕ •ᴥ•ʔノ', 'ಠ_ಠ', '(-‸ლ)', '( ͡° ͜ʖ ͡°)', '( ° ͜ʖ͡°)╭∩╮', '(╯°□°)╯︵ ┻━┻', '┬──┬ ノ( ゜-゜ノ)', '•_•) ( •_•)>⌐■-■ (⌐■_■)', "i dunno lol ¯\\(°_o)/¯", "how do i shot web ¯\\(°_o)/¯", '(◕‿◕✿)', 'ヾ(〃^∇^)ノ', '\( ̄▽ ̄)/', '(ノ◕ヮ◕)ノ*:・゚✧', 'ᕕ( ͡° ͜ʖ ͡°)ᕗ', 'ᕕ( ᐛ )ᕗ ᕕ( ᐛ )ᕗ ᕕ( ᐛ )ᕗ', "(ノ◕ヮ◕)ノ *:・゚✧ SO KAWAII ✧・:* \\(◕ヮ◕\\)", 'ᕙ༼ຈل͜ຈ༽ᕗ. ʜᴀʀᴅᴇʀ, ʙᴇᴛᴛᴇʀ, ғᴀsᴛᴇʀ, ᴅᴏɴɢᴇʀ .ᕙ༼ຈل͜ຈ༽ᕗ', "(∩ ͡° ͜ʖ ͡°)⊃━☆゚. * ・ 。゚you've been touched by the donger fairy", '(ง ͠° ͟ل͜ ͡°)ง ᴍᴀsᴛᴇʀ ʏᴏᴜʀ ᴅᴏɴɢᴇʀ, ᴍᴀsᴛᴇʀ ᴛʜᴇ ᴇɴᴇᴍʏ (ง ͠° ͟ل͜ ͡°)ง', "(⌐■_■)=/̵͇̿̿/'̿'̿̿̿ ̿ ̿̿ ヽ༼ຈل͜ຈ༽ノ keep your dongers where i can see them", '[̲̅$̲̅(̲̅ ͡° ͜ʖ ͡°̲̅)̲̅$̲̅] do you have change for a donger bill [̲̅$̲̅(̲̅ ͡° ͜ʖ ͡°̲̅)̲̅$̲̅]', '╰( ͡° ͜ʖ ͡° )つ──☆*:・゚ clickty clack clickty clack with this chant I summon spam to the chat', 'work it ᕙ༼ຈل͜ຈ༽ᕗ harder make it (ง •̀_•́)ง better do it ᕦ༼ຈل͜ຈ༽ᕤ faster raise ur ヽ༼ຈل͜ຈ༽ノ donger'];
     $message->reply($memes[array_rand($memes)]);
 }