From 058b409adfcd3403361eed2ecc3a9b374cfb82d5 Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 14 Nov 2024 02:44:02 +0000 Subject: [PATCH] Added RPC for emotes list. --- src/Emoticons/EmotesRpcHandler.php | 40 ++++++++++++++++++++++++++++++ src/MisuzuContext.php | 4 +++ 2 files changed, 44 insertions(+) create mode 100644 src/Emoticons/EmotesRpcHandler.php diff --git a/src/Emoticons/EmotesRpcHandler.php b/src/Emoticons/EmotesRpcHandler.php new file mode 100644 index 0000000..28506fc --- /dev/null +++ b/src/Emoticons/EmotesRpcHandler.php @@ -0,0 +1,40 @@ +emotes->getEmotes(orderBy: 'order'), + function($emote) use ($includeId, $includeOrder) { + $info = [ + 'url' => $emote->getUrl(), + 'strings' => XArray::select( + $this->emotes->getEmoteStrings($emote), + fn($string) => $string->getString() + ), + ]; + + if($includeId) + $info['id'] = $emote->getId(); + if($includeOrder) + $info['order'] = $emote->getOrder(); + + $rank = $emote->getMinRank(); + if($rank != 0) + $info['min_rank'] = $rank; + + return $info; + } + ); + } +} diff --git a/src/MisuzuContext.php b/src/MisuzuContext.php index 9e572d4..aa90aa5 100644 --- a/src/MisuzuContext.php +++ b/src/MisuzuContext.php @@ -292,6 +292,10 @@ class MisuzuContext { $this->authCtx )); + $rpcServer->register(new Emoticons\EmotesRpcHandler( + $this->emotes + )); + $rpcServer->register(new Users\UsersRpcHandler( $this->siteInfo, $this->urls,