├── README.md ├── inc ├── config.php └── function.php ├── index.php ├── plugins ├── BaiDu_Wiki.php ├── BiliMusic.php ├── Check_QQ.php ├── GroupSign.php ├── Group_Add.php ├── Group_Welcome.php ├── Hello World.php ├── Hitokoto.php ├── HuLuXia_Pic.php ├── KonaChan_Pic.php ├── Kuai_Video.php ├── MiguMusic.php ├── MisaKa_EQ.php ├── Netease_Music.php ├── PoisonousChickenSoup.php ├── QQMusic.php ├── Rand.php ├── Time.php ├── Weather_List.php └── Xiaoi_Bot.php └── themes └── index.php /README.md: -------------------------------------------------------------------------------- 1 |

2 | hanximeng-botapi 3 |

4 | 5 |
6 | 7 | # BOT_API 8 | 9 | _👻 基于 [PHP](https://www.php.net/) 以及 [go-cqhttp](https://github.com/Mrs4s/go-cqhttp/) 的 BOT 服务 👻_ 10 | 11 | 12 |
13 |

14 | 下载 15 | / 16 | 视频教程 17 |

18 | 19 | ## **兼容性** 20 | * 仅在 PHP 7.2 以上进行过测试。 21 | 22 | ## **插件列表** 23 | 24 | * 百度百科 25 | * 点歌(网易音乐、QQ音乐、咪咕音乐、哔哩哔哩音乐) 26 | * 群打卡 or 群签到 27 | * 一言([Hitokoto](https://hitokoto.cn/)) 28 | * 毒鸡汤 29 | * 葫芦侠三楼图片 30 | * 帮我选 31 | * 地震通报 32 | 33 | ## **注意事项** 34 | * 计划任务功能依赖于go-cqhttp的心跳事件,请勿关闭! 35 | * 延时功能需编辑 ./inc/config.php 将 $BOT_Sleep 的值改为 true ,该功能可有效防止被风控,但会导致消息延迟收到,请根据自身需求判断是否启用。 36 | -------------------------------------------------------------------------------- /inc/config.php: -------------------------------------------------------------------------------- 1 | 60 or empty($code)){$code=3;} 51 | sleep($code);//延时避免风控 52 | } 53 | //提交至go-cqhttp 54 | $url = $GLOBALS['BOT_Server'].'/'.$url.'?access_token='.$GLOBALS['BOT_Token']; 55 | $ch = curl_init(); 56 | curl_setopt($ch, CURLOPT_POST, 1); 57 | curl_setopt($ch, CURLOPT_URL, $url); 58 | curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr); 59 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 60 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( 61 | 'Content-Type: application/json; charset=utf-8' 62 | ) 63 | ); 64 | $response = curl_exec($ch); 65 | curl_close($ch); 66 | //判断延时策略是否开启 67 | if($GLOBALS['BOT_Sleep'] == 'true'){ 68 | $code=file_get_contents('code.txt'); 69 | $code=$code-3; 70 | file_put_contents('code.txt',$code); 71 | } 72 | return $response; 73 | } 74 | 75 | //POST提交 76 | function Curl_Post($remote_server, $post_string) { 77 | $ch = curl_init(); 78 | curl_setopt($ch, CURLOPT_URL, $remote_server); 79 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); 80 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 81 | curl_setopt($ch, CURLOPT_USERAGENT, 'HxmBot beta'); 82 | $data = curl_exec($ch); 83 | curl_close($ch); 84 | return $data; 85 | } 86 | 87 | //用于间隔多久执行一次的函数 88 | function BOT_Time_Inr($Name,$Num){ 89 | //获取时间 90 | $Time=date('Y-m-d H:i',filemtime('./Data/Cron/Cron_'.$Name.'.log')); 91 | if(date('Y-m-d H:i') !== $Time){ 92 | $Time=(strtotime(date('Y-m-d H:i'))-strtotime($Time))/60; 93 | if($Time >= $Num){ 94 | //存入日志 95 | $Log='任务名:'.$Name.';执行时间:'.date('Y-m-d H:i')."\n"; 96 | file_put_contents('./Data/Cron/Cron_'.$Name.'.log',$Log); 97 | //输出结果 98 | return true; 99 | }else{ 100 | return false; 101 | } 102 | } 103 | 104 | } 105 | 106 | //用于每天几点执行一次的函数 107 | function BOT_Time_Day($Name,$Num){ 108 | //获取时间 109 | $Time=date('Y-m-d H:i',filemtime('./Data/Cron/Cron_'.$Name.'.log')); 110 | if(date('Y-m-d H:i') !== $Time){ 111 | if(is_array($Num)){ 112 | foreach ($Num as $value) { 113 | if(date('H:i') == $value){ 114 | //存入日志 115 | $Log='任务名:'.$Name.';执行时间:'.date('Y-m-d H:i')."\n"; 116 | file_put_contents('./Data/Cron/Cron_'.$Name.'.log',$Log); 117 | return true; 118 | } 119 | } 120 | }else{ 121 | if(date('H:i') == $Num){ 122 | //存入日志 123 | $Log='任务名:'.$Name.';执行时间:'.date('Y-m-d H:i')."\n"; 124 | file_put_contents('./Data/Cron/Cron_'.$Name.'.log',$Log); 125 | //输出结果 126 | return true; 127 | }else{ 128 | return false; 129 | } 130 | } 131 | } 132 | } 133 | 134 | //用于某一天的几点执行的函数 135 | function BOT_Time_One($Name,$Num){ 136 | //获取时间 137 | $Time=date('Y-m-d H:i',filemtime('./Data/Cron/Cron_'.$Name.'.log')); 138 | if(date('Y-m-d H:i') !== $Time){ 139 | if(date('Y-m-d H:i') == $Num){ 140 | //存入日志 141 | $Log='任务名:'.$Name.';执行时间:'.date('Y-m-d H:i')."\n"; 142 | file_put_contents('./Data/Cron/Cron_'.$Name.'.log',$Log); 143 | //输出结果 144 | return true; 145 | }else{ 146 | return false; 147 | } 148 | } 149 | } 150 | 151 | //用于整点执行的函数 152 | function BOT_Time_Hour($Name,$Num){ 153 | //获取时间 154 | $Time=date('Y-m-d H:i',filemtime('./Data/Cron/Cron_'.$Name.'.log')); 155 | if(date('Y-m-d H:i') !== $Time){ 156 | if(date('i') == $Num){ 157 | //存入日志 158 | $Log='任务名:'.$Name.';执行时间:'.date('Y-m-d H:i')."\n"; 159 | file_put_contents('./Data/Cron/Cron_'.$Name.'.log',$Log); 160 | //输出结果 161 | return true; 162 | }else{ 163 | return false; 164 | } 165 | } 166 | } -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/BaiDu_Wiki.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/BiliMusic.php: -------------------------------------------------------------------------------- 1 | 32 | -------------------------------------------------------------------------------- /plugins/Check_QQ.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/Group_Add.php: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /plugins/Group_Welcome.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/Hitokoto.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/HuLuXia_Pic.php: -------------------------------------------------------------------------------- 1 | (.*?.),(.*?.)(.*?.),(.*?.) -------------------------------------------------------------------------------- /plugins/KonaChan_Pic.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/Kuai_Video.php: -------------------------------------------------------------------------------- 1 | 19 | -------------------------------------------------------------------------------- /plugins/MiguMusic.php: -------------------------------------------------------------------------------- 1 | 29 | -------------------------------------------------------------------------------- /plugins/MisaKa_EQ.php: -------------------------------------------------------------------------------- 1 | 0); 52 | return $hex; 53 | } 54 | function param($n,$default='',$must = false) { 55 | $p=''; 56 | if(!empty($keyword)) { 57 | $p = urldecode($keyword); 58 | } 59 | if($p=='' && $must) { 60 | echo '缺少必要参数:'.$n.'
'; 61 | exit(); 62 | } 63 | if($p=='' && !$must) { 64 | return $default; 65 | } 66 | return $p; 67 | } 68 | function request($url,$d,$get_header=false) { 69 | $text = (json_encode($d)); 70 | if($text != '') { 71 | $modulus = '157794750267131502212476817800345498121872783333389747424011531025366277535262539913701806290766479189477533597854989606803194253978660329941980786072432806427833685472618792592200595694346872951301770580765135349259590167490536138082469680638514416594216629258349130257685001248172188325316586707301643237607'; 72 | $pubkey = '65537'; 73 | // 开始生成encSecKey 74 | $key2 = randomstr(16); 75 | $skey = strrev(utf8_encode($key2)); 76 | $skey = bchexdec(str2hex($skey)); 77 | $skey = bcpowmod($skey, $pubkey, $modulus); 78 | $skey = bcdechex($skey); 79 | $skey = str_pad($skey, 256, '0', STR_PAD_LEFT); 80 | $key = '0CoJUm6Qyw8W8jud'; 81 | $enStr = NetEaseMusicAES($text,$key); 82 | $params = NetEaseMusicAES($enStr,$key2); 83 | } 84 | $data['params'] = $params; 85 | $data['encSecKey'] = $skey; 86 | //print_r($data); 87 | return http_post($url,$data,$get_header); 88 | } 89 | $limit = param('limit',30); 90 | $type = param('type',1) ; 91 | $offset = param('offset',0); 92 | $arr = array( 93 | 's' => urldecode($Info[1]), 94 | 'type' => $type, 95 | 'limit' => $limit, 96 | 'offset' => $offset, 97 | ); 98 | /* 99 | * 请求头设置 100 | */ 101 | function set_header() { 102 | return array( 103 | 'Host: music.163.com', 104 | 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0', 105 | 'Origin: https://music.163.com', 106 | 'Referer: https://music.163.com', 107 | 'Content-Type: application/x-www-form-urlencoded', 108 | ); 109 | } 110 | function http_post($url, $post_data,$get_header=false) { 111 | $postdata = http_build_query($post_data); 112 | $options = array( 113 | 'http' => array( 114 | 'method' => 'POST', 115 | 'header' => set_header(), 116 | 'content' => $postdata, 117 | ) 118 | ); 119 | $context = stream_context_create($options); 120 | $result = file_get_contents($url, false, $context); 121 | return $result; 122 | } 123 | $Json=request('https://interface.music.163.com/weapi/search/get',$arr); 124 | $SongID=json_decode($Json,true)['result']['songs']['0']['id']; 125 | $Text='[CQ:music,type=163,id='.$SongID.']'; 126 | 127 | //判断是否存在group_id,若不存在则为私聊 128 | if(!empty($Data['group_id'])) { 129 | http_post_json('send_msg','{"group_id":"'.$Data['group_id'].'","message":"'.$Text.'"}'); 130 | } elseif(!empty($Data['guild_id'])) { 131 | http_post_json('send_guild_channel_msg','{"guild_id":"'.$Data['guild_id'].'","channel_id":"'.$Data['channel_id'].'","message":"'.$Text.'"}'); 132 | } else { 133 | http_post_json('send_msg','{"user_id":"'.$Data['user_id'].'","message":"'.$Text.'"}'); 134 | } 135 | } 136 | } 137 | ?> -------------------------------------------------------------------------------- /plugins/PoisonousChickenSoup.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/QQMusic.php: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /plugins/Rand.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/Time.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/Weather_List.php: -------------------------------------------------------------------------------- 1 | 基本设置中可修改机器人名称及其他信息 12 | */ 13 | 14 | //仅对#开头的消息进行处理,也可将#修改为“[CQ:at,qq=机器人QQ号] ”则仅对艾特机器人的消息进行处理,请勿粘贴“”及遗漏空格 15 | if (strpos($Data['message'], "#") !== false) { 16 | $Info = explode('#', $Data['message']); 17 | if ($Info[1] !== '' && $Info[0] == '') { 18 | $app_uid=''; 19 | if(!empty($app_uid)){ 20 | $XiaoI_Json = Curl_Post('http://open.xiaoi.com/apiDebug/apiDebug!ask.do', 'question=' . urlencode($Info[1]) . '&userId=qq_' . $Data['user_id'] . '&platform=web&type=1&app_uid='.$app_uid); 21 | $XiaoI_Arr = json_decode($XiaoI_Json, true); 22 | $XiaoI_Data = simplexml_load_string($XiaoI_Arr['result']); 23 | $Content = str_replace(array(PHP_EOL, "\r", "\n", "\n\r", "\r\n"), '\n', $XiaoI_Data->Content); 24 | //判断消息是否重复 25 | if ($Content !== '重复回复') { 26 | $Text = $Content; 27 | } else { 28 | //如需如需对重复消息进行自定义则取消下行处注释 29 | //$Text='重复消息的提示。'; 30 | //die 则不对同一个用户发送的重复消息进行处理,注释后将发送重复消息的提示 31 | die(); 32 | } 33 | }else{ 34 | $Text='未配置小i的app_uid,该插件暂时无法使用!'; 35 | } 36 | //判断是否存在group_id,若不存在则为私聊 37 | if (!empty($Data['group_id'])) { 38 | http_post_json('send_msg', '{"group_id":"' . $Data['group_id'] . '","message":"[CQ:reply,id=' . $Data['message_id'] . ']' . $Text . '"}'); 39 | } elseif (!empty($Data['guild_id'])) { 40 | http_post_json('send_guild_channel_msg', '{"guild_id":"' . $Data['guild_id'] . '","channel_id":"' . $Data['channel_id'] . '","message":"' . $Text . '"}'); 41 | } else { 42 | http_post_json('send_msg', '{"user_id":"' . $Data['user_id'] . '","message":"[CQ:reply,id=' . $Data['message_id'] . ']' . $Text . '"}'); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /themes/index.php: -------------------------------------------------------------------------------- 1 |