getTelegram()->addCommand(
new class extends Command {
- protected $name = 'faves';
+ protected $name = 'searchfaves';
protected $description = 'List favourites';
public function handle($arguments) {
$songHashMap = unserialize(file_get_contents(__DIR__ . '/hashmap.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));
$newFaves = zzipWith(∘(concat, flip(concat)(" in "), flip(field)($songHashMap)))(array_keys($faveMap))(array_values($faveMap));
+
+ $thing = map(function ($fave) use ($arguments) {
+ $justTitle = join(' ', array_slice(explode(' ', $fave), 0 , -2));
+ similar_text($arguments, $justTitle ?: '', $perc);
+ return ['title' => $fave, 'similarity' => $perc];
+ });
+ $top5 = ∘(unlines, aaray_column('title'), aaray_slice(0)(5), 'array_reverse', 'array_values', ssort(∘(∘f(field('similarity')), ⬄, field('similarity'))));
+
$this->replyWithMessage(
[
- 'text' => unlines($newFaves)
+ 'text' => unlines($top5($thing))
]
);
}