1 <?php
declare(strict_types
=1);
5 use Telegram\Bot\Actions
;
6 use Telegram\Bot\Commands\Command
;
8 if(getTelegram()->getWebHookUpdates()->get('message') && !canChatWith(getTelegram()->getWebhookUpdates())) {
9 getTelegram()->sendMessage([
10 'chat_id' => getTelegram()->getWebhookUpdates()->get('message')->get('chat')->get('id'),
11 'text' => "Sorry, Dad says I can't talk to you."
16 const scoresFileContentsToScoresList
= 'scoresFileContentsToScoresList';
17 function scoresFileContentsToScoresList($who) {
18 return function($lines) use ($who) {
19 return filter(notEmpty
)(foldMap(∘
(map(filterk(≠
('NODATA'))), unflatten
, insert($who)(3), delemit(':')))(lines($lines)));
23 getTelegram()->addCommand(
24 new class extends Command
{
25 protected $name = 'scores';
26 protected $description = 'Get all scores with specified high score name';
28 public function handle($arguments) {
38 $songHashMap = unserialize(file_get_contents(__DIR__
. '/hashmap.txt'));
40 $scoreFiles = foldMap(∘
(☐
(lhead
)(null
), 'file_get_contents'))(glob(PATH_TO_GROOVENET
. '/*.scores.txt'));
41 $scoreTesseract = map(map(map(maxKey
)))(
42 ∘
(foldMap(id
), zzipWith(pa
)(map(ltail
)($scoreFiles)), map(∘
(scoresFileContentsToScoresList
, lhead
)))($scoreFiles)
45 $asdf = prefixKey('', $scoreTesseract);
47 foreach ($asdf as $k => $v) {
48 $k = explode('.', $k);
49 if ($k[3] !== $arguments) {
53 $pranks[] = glue('')([
56 $k[2] == 'dance-double' ?
$diffEmojiMap[$k[1]] : '',
57 ' ' . $songHashMap[$k[0]],
59 truncate($v*100, 2) . "%"
63 $this->replyWithMessage(
65 'text' => "High scores for $arguments ...\n\n" . unlines($pranks)
72 getTelegram()->addCommand(
73 new class extends Command
{
74 protected $name = 'hashgen';
75 protected $description = 'Generate the songs hash';
77 public function handle($arguments) {
78 $this->replyWithMessage(
80 'text' => "Building songs hash... This will take a while."
84 exec('/root/hashghen.sh');
90 getTelegram()->commandsHandler(true
); //must come afterwards because lolzer