1717use Longman \TelegramBot \Request ;
1818use Longman \TelegramBot \Telegram ;
1919use Longman \TelegramBot \TelegramLog ;
20+ use MatthiasMullie \Scrapbook \Adapters \MySQL ;
21+ use MatthiasMullie \Scrapbook \Psr6 \Pool ;
2022use Monolog \Formatter \LineFormatter ;
2123use Monolog \Handler \StreamHandler ;
2224use Monolog \Logger ;
@@ -108,6 +110,10 @@ function parseReleaseBody($body, $user, $repo): string
108110 }, $ body );
109111
110112 $ github_client = new Client ();
113+ $ github_client ->addCache (new Pool (new MySQL (
114+ new PDO ('mysql:dbname= ' . getenv ('TG_DB_DATABASE ' ) . ';host= ' . getenv ('TG_DB_HOST ' ), getenv ('TG_DB_USER ' ), getenv ('TG_DB_PASSWORD ' ))
115+ )));
116+
111117 // Replace any ID links with the corresponding issue or pull request link.
112118 $ body = preg_replace_callback ('~(?:(?<user>[0-9a-z\-]*)/(?<repo>[0-9a-z\-]*))?#(?<id>\d*)~i ' , static function ($ matches ) use ($ github_client , $ user , $ repo ) {
113119 $ text = $ matches [0 ];
@@ -118,7 +124,7 @@ function parseReleaseBody($body, $user, $repo): string
118124 // Check if this ID is an issue.
119125 try {
120126 /** @var Issue $issue */
121- $ issue = $ github_client ->api ( ' issue ' )->show ($ user , $ repo , $ id );
127+ $ issue = $ github_client ->issue ( )->show ($ user , $ repo , $ id );
122128 return "[ {$ text }]( {$ issue ['html_url ' ]}) " ;
123129 } catch (Throwable $ e ) {
124130 // Silently ignore.
@@ -127,7 +133,7 @@ function parseReleaseBody($body, $user, $repo): string
127133 // Check if this ID is a pull request.
128134 try {
129135 /** @var PullRequest $pr */
130- $ pr = $ github_client ->api ( ' pull_request ' )->show ($ user , $ repo , $ id );
136+ $ pr = $ github_client ->pr ( )->show ($ user , $ repo , $ id );
131137 return "[ {$ text }]( {$ pr ['html_url ' ]}) " ;
132138 } catch (Throwable $ e ) {
133139 // Silently ignore.
0 commit comments