当前位置: 首页>>代码示例>>PHP>>正文


PHP Track::is_recently_played方法代码示例

本文整理汇总了PHP中Track::is_recently_played方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::is_recently_played方法的具体用法?PHP Track::is_recently_played怎么用?PHP Track::is_recently_played使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Track的用法示例。


在下文中一共展示了Track::is_recently_played方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: web_post_vote

 /**
  * (Web service method) Submit vote for current track
  * @param  mixed[] $args time_utc (YYYY-MM-DD); stream_title; value (-5 .. 5); nick; user_id; is_authed (0|1)
  * @return mixed[] status; error_message; output (what to announce in IRC chat room)
  */
 private function web_post_vote($args)
 {
     $time_utc = $args['time_utc'];
     // YYYY-MM-DD HH:MM:SS
     $stream_title = $args['stream_title'];
     $nick = $args['nick'];
     $user_id = $args['user_id'];
     $is_authed = $args['is_authed'];
     $value_parts = explode(' ', $args['value'], 2);
     $value = str_replace(['[', ']', '{', '}', '"', '\''], '', $value_parts[0]);
     if (count($value_parts) == 1) {
         $comment = '';
     } else {
         $comment = $value_parts[1];
     }
     $opt = Options::get_instance();
     if (is_numeric($value)) {
         $num = (int) $value;
         if ($num < -5 || $num > 5) {
             $num = FALSE;
         }
     } else {
         $num = FALSE;
     }
     if ($num === FALSE) {
         $this->fail($nick . ': Invalid vote value. Say "' . explode(' ', $opt->cmd_help)[0] . '" for help.');
     }
     $track_id = Track::create_or_get_id($stream_title);
     if (!Track::is_recently_played($track_id)) {
         $this->fail($nick . ': "' . $stream_title . '" wasn\'t played recently!');
     }
     $vote_id = Vote::get_recent_id($track_id, $nick);
     if ($vote_id) {
         Vote::delete($vote_id);
         $txt_vote_response = $opt->txt_revote_response;
         $priv = $opt->txt_revote_response_switch;
     } else {
         $txt_vote_response = $opt->txt_vote_response;
         $priv = $opt->txt_vote_response_switch;
     }
     Vote::new_vote($time_utc, $track_id, $stream_title, $num, $nick, $user_id, $is_authed, $comment);
     if ($num > 0) {
         $num_txt = '+' . $num;
     } else {
         $num_txt = (string) $num;
     }
     $out = str_ireplace('${stream_title}', $args['stream_title'], $txt_vote_response);
     $out = str_ireplace('${nick}', $nick, $out);
     $out = str_ireplace('${value}', $num_txt, $out);
     Track::update_vote($track_id);
     return array('status' => 'ok', 'error_message' => '', 'output' => $out, 'private' => $priv);
 }
开发者ID:loonix,项目名称:music-stream-vote,代码行数:57,代码来源:BotService.php


注:本文中的Track::is_recently_played方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。