projects
/
GrooveNetBot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5f1feb9
)
Convert faves to searchfaves since there's too many
author
Cameron Ball
<cameron@moodle.com>
Tue, 7 May 2019 08:05:03 +0000
(16:05 +0800)
committer
Cameron Ball
<cameron@moodle.com>
Tue, 7 May 2019 08:05:03 +0000
(16:05 +0800)
src/gnb.php
patch
|
blob
|
history
diff --git
a/src/gnb.php
b/src/gnb.php
index
fb0c2e5
..
fcf4a9d
100644
(file)
--- a/
src/gnb.php
+++ b/
src/gnb.php
@@
-22,7
+22,7
@@
function scoresFileContentsToScoresList($who) {
getTelegram()->addCommand(
new class extends Command {
getTelegram()->addCommand(
new class extends Command {
- protected $name = 'faves';
+ protected $name = '
search
faves';
protected $description = 'List favourites';
public function handle($arguments) {
protected $description = 'List favourites';
public function handle($arguments) {
@@
-32,9
+32,17
@@
getTelegram()->addCommand(
$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));
$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(
[
$this->replyWithMessage(
[
- 'text' => unlines($
newFaves
)
+ 'text' => unlines($
top5($thing)
)
]
);
}
]
);
}