};
}
+const not = 'not';
+function not($v) {
+ return !$v;
+}
+
const notEmpty = 'notEmpty';
function notEmpty($value) : bool {
return !empty($value);
function contains(string $what) {
return function(string $h) use ($what) {
- return strpos($h, $what) === false;
+ return strpos($h, $what) !== false;
};
}
getTelegram()->addCommand(
new class extends Command {
+ protected $name = 'scoresummary';
+ protected $description = 'Get a count of how many scores each participant has';
+
+ public function handle($arguments) {
+ $counts = foldMap(∘(☐(lhead)(∘('count', filter(∘(not, contains('NODATA'))), lines)), 'trim', 'file_get_contents'))(glob(PATH_TO_GROOVENET . '/*.scores.txt'));
+
+ $out = array_reduce(
+ array_keys($counts)
+ ,function($c, $v) use ($counts) {
+ return "$c\n$v: " . $counts[$v] . " pranks";
+ }, '');
+
+ $chatid = getTelegram()->getWebhookUpdates()->get('message')->get('chat')->get('id');
+ getTelegram()->sendMessage(
+ [
+ 'chat_id' => $chatid,
+ 'parse_mode' => 'Markdown',
+ 'text' => "```" . $out . "\n```\n"
+ ]
+ );
+ }
+ }
+);
+
+getTelegram()->addCommand(
+ new class extends Command {
protected $name = 'digest';
protected $description = 'Get the prank digest for today';