示例#1
0
 /**
  * @param cURL\Event $event
  * @param ChannelContext $context
  */
 public function onRequestComplete(cURL\Event $event, ChannelContext $context)
 {
     $res = $event->response;
     $code = $res->getInfo(CURLINFO_HTTP_CODE);
     $feed = $res->getContent();
     if ($code != 200 || empty($feed)) {
         return;
     }
     $feed = json_decode($feed, true);
     $track =& $feed['track'];
     $replace = ['%artist' => $track['artists'][0]['name'], '%track' => $track['name'], '%duration' => TimeDuration::get((int) $track['length']), '%album' => $track['album'] ? $track['album']['name'] : 'n/d', '%released' => $track['album']['released']];
     $response = strtr('<b><color fg="white" bg="green"> Spotify </color></b>  ' . '<b>%artist - <u>%track</u></b> (%duration), album: <b>%album</b> (%released)', $replace);
     $context->send(Formatter::parse($response));
 }
示例#2
0
 public function testEmphasize()
 {
     $this->assertValidFormat("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 'Lorem <b>ipsum</b> dolor <i>sit amet</i>, <x>consectetur</x> adipiscing elit.');
     $this->assertEquals("Foo bar", 'Foo ' . Formatter::bold('bar'));
 }