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 = 'digest';
+ protected $description = 'Get the prank digest for today';
+
+ public function handle($arguments) {
+ $diffEmojiMap = [
+ 'Beginner' => 'š',
+ 'Easy' => 'š',
+ 'Medium' => 'š',
+ 'Hard' => 'š',
+ 'Challenge' => 'š',
+ 'Edit' => 'š'
+ ];
+
+ $songHashMap = unserialize(file_get_contents(__DIR__ . '/hashmap.txt'));
+ $scoreFiles = foldMap(ā(ā(lhead)(null), 'file_get_contents'))(glob(PATH_TO_GROOVENET . '/*.scores.txt'));
+ $faveFiles = foldMap(ā(null)(ā(lines, 'trim', 'file_get_contents')))(glob(PATH_TO_GROOVENET . '/*.favourites.txt'));
+ $names = map(ā(produceValue(0))(null))(array_keys($faveFiles));
+ $hashes = map(map(ā(produceValue(0))(null)))(array_values($faveFiles));
+
+ $oldFaveMap = unserialize(file_get_contents(__DIR__ . '/faves.txt'));
+ $faveMap = ā(map(ā(flip(concat)("'s Faves"), 'ucwords', field(0), delemit('.'), 'basename')), foldMap(ā(field(1))(field(0))), foldMap(id))(zzipWith(ā(map, aaray_merge))($names)($hashes));
+ $oldScoreTesseract = unserialize(file_get_contents(__DIR__ . '/tesseract.txt'));
+ $scoreTesseract = map(map(map(maxKey)))(
+ ā(foldMap(id), zzipWith(pa)(map(ltail)($scoreFiles)), map(ā(scoresFileContentsToScoresList, lhead)))($scoreFiles)
+ );
+
+ $diff = array_diff_assoc_recursive($scoreTesseract, $oldScoreTesseract);
+ $asdf = prefixKey('', $diff);
+ $pranks = [];
+
+ foreach ($asdf as $k => $v) {
+ $k = explode('.', $k);
+
+ if (!isset($oldScoreTesseract[$k[0]][$k[1]][$k[2]])) {
+ continue;
+ }
+
+ $previous = $oldScoreTesseract[$k[0]][$k[1]][$k[2]];
+ $scorer = array_keys($previous)[0];
+ $score = $previous[$scorer];
+
+ if ($scorer !== $k[3]) {
+ $pranks[] = glue('')([
+ "āāāāāāāāāāāāāā\n",
+ $diffEmojiMap[$k[1]],
+ $k[2] == 'dance-double' ? $diffEmojiMap[$k[1]] : '',
+ ' ' . explode('/', $songHashMap[$k[0]])[1],
+ "\n",
+ $k[3] . ": " . truncate($v*100, 2) . "%",
+ " (was $scorer: " . truncate($score*100, 2) . "%)"
+ ]);
+ }
+ }
+
+ if ($pranks) {
+ $numE = count($pranks);
+ $pranks[$numE- 1] .= "\nāāāāāāāāāāāāāā";
+ }
+
+ $faveDiff = array_diff_assoc($faveMap, $oldFaveMap);
+ $newFaves = zzipWith(ā(concat, flip(concat)(" in "), field(1), delemit('/'), ā(flip(field))($songHashMap)))(array_keys($faveDiff))(array_values($faveDiff));
+
+ if ($pranks || $newFaves) {
+ getTelegram()->sendMessage(
+ [
+ 'chat_id' => CHAT_ID,
+ 'parse_mode' => 'Markdown',
+ 'text' => unlines(
+ array_merge(
+ ['Welcome to the GrooveNet digest', ""],
+ $pranks ? ["Latest pranks:", '```'] : [],
+ $pranks,
+ $pranks ? ['```'] : [],
+ $newFaves ? ['Latest faves:', '```'] : [],
+ $newFaves,
+ $newFaves ? ['```'] : []
+ )
+ )
+ ]
+ );
+ }
+ }
+ }
+);
getTelegram()->addCommand(
new class extends Command {
require_once('common.php');
-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)));
- };
-}
-
$diffEmojiMap = [
'Beginner' => 'š',
'Easy' => 'š',
}
$faveDiff = array_diff_assoc($faveMap, $oldFaveMap);
-$newFaves = zzipWith(ā(concat, flip(concat)(" in "), field(1),delemit('/'), ā(flip(field))($songHashMap)))(array_keys($faveDiff))(array_values($faveDiff));
+$newFaves = zzipWith(ā(concat, flip(concat)(" in "), field(1), delemit('/'), ā(flip(field))($songHashMap)))(array_keys($faveDiff))(array_values($faveDiff));
if ($pranks || $newFaves) {
getTelegram()->sendMessage(