--- /dev/null
+<?php declare(strict_types=1);
+
+require('common.php');
+
+use Telegram\Bot\Actions;
+use Telegram\Bot\Commands\Command;
+
+if(getTelegram()->getWebHookUpdates()->get('message') && !canChatWith(getTelegram()->getWebhookUpdates())) {
+ getTelegram()->sendMessage([
+ 'chat_id' => getTelegram()->getWebhookUpdates()->get('message')->get('chat')->get('id'),
+ 'text' => "Sorry, Dad says I can't talk to you."
+ ]);
+ exit(0);
+}
+
+const scoresFileContentsToScoresList = 'scoresFileContentsToScoresList';
+function scoresFileContentsToScoresList($who) {
+ return function($lines) use ($who) {
+ return filter(notEmpty)(foldMap(∘(map(filterk(≠('NODATA'))), unflatten, insert($who)(3), delemit(':')))(lines($lines)));
+ };
+}
+
+getTelegram()->addCommand(
+ new class extends Command {
+ protected $name = 'scores';
+ protected $description = 'Get all scores with specified high score name';
+
+ public function handle($arguments) {
+ $diffEmojiMap = [
+ 'Beginner' => '🗑',
+ 'Easy' => '📗',
+ 'Medium' => '📙',
+ 'Hard' => '📕',
+ 'Challenge' => '📘',
+ 'Edit' => '📓'
+ ];
+
+ $songHashMap = foldMap(
+ ☐(∘(field(0), delemit(' ')))(∘(field(5), delemit('/')))
+ )(foldMap(∘(lines, 'trim', 'file_get_contents'))(glob(PATH_TO_GROOVENET . '/songs.*.txt')));
+
+ $scoreFiles = foldMap(∘(☐(lhead)(null), 'file_get_contents'))(glob(PATH_TO_GROOVENET . '/*.scores.txt'));
+ $scoreTesseract = map(map(map(maxKey)))(
+ ∘(foldMap(id), zzipWith(pa)(map(ltail)($scoreFiles)), map(∘(scoresFileContentsToScoresList, lhead)))($scoreFiles)
+ );
+
+ $asdf = prefixKey('', $scoreTesseract);
+ $pranks = [];
+ foreach ($asdf as $k => $v) {
+ $k = explode('.', $k);
+ if ($k[3] !== $arguments) {
+ continue;
+ }
+
+ $pranks[] = glue('')([
+ "——————————————\n",
+ $diffEmojiMap[$k[1]],
+ $k[2] == 'dance-double' ? $diffEmojiMap[$k[1]] : '',
+ ' ' . $songHashMap[$k[0]],
+ "\n ",
+ truncate($v*100, 2) . "%"
+ ]);
+ }
+
+ $this->replyWithMessage(
+ [
+ 'text' => "High scores for $arguments ...\n\n" . unlines($pranks)
+ ]
+ );
+ }
+ }
+);