diff --git a/Open Source Licenses/kilingzhang/coolq-php-sdk/LICENSE b/Open Source Licenses/kilingzhang/coolq-php-sdk/LICENSE deleted file mode 100644 index fb5423d..0000000 --- a/Open Source Licenses/kilingzhang/coolq-php-sdk/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 kilingzhang - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index 2123acf..652ad1f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ kjBot 是一个轻量级多功能的酷Q机器人框架。 ``` / -|--Open Source Licenses/ #存放开源许可证 |--SDK/ #kjBot\SDK |--public/ |--tools/ #各类开放函数的文件 @@ -82,6 +81,20 @@ if(!fromGroup()){ //如果消息不是来自群聊 ![](https://user-images.githubusercontent.com/18349191/42219471-99b181e4-7efe-11e8-92a8-20535f40d126.png) +## 感谢 + +- [richardchien/coolq-http-api](https://github.com/richardchien/coolq-http-api) + - 酷Q 与许多 Bot 之间的桥梁 +- [kilingzhang/coolq-php-sdk](https://github.com/kilingzhang/coolq-php-sdk) + - 本项目的起源 +- [kj415j45/jkBot](https://github.com/kj415j45/jkBot) + - 本项目的零代 +- 贡献者 + - [Cyanoxygen](https://github.com/Cyanoxygen) + - [Baka-D](https://github.com/Baka-D) + - [lslqtz](https://github.com/lslqtz) + - [LovelyA72](https://github.com/LovelyA72) + ## LICENSE kjBot 框架及 SDK 均为 MIT 协议。但是模块与中间件均为 AGPL 协议,如果您希望闭源开发,请不要使用该项目提供的模块和中间件。 diff --git a/SDK/API.php b/SDK/API.php index 690d6be..f41a31d 100644 --- a/SDK/API.php +++ b/SDK/API.php @@ -1,7 +1,6 @@ token = $token; } - ///以下源码部分来自kilingzhang/coolq-php-sdk : src/CoolQ.php public function sendPrivateMsg($user_id, $message, $auto_escape = false){ $api = API::send_private_msg; $param = [ @@ -280,6 +279,12 @@ public function getCsrfToken(){ return $this->query($api, $param); } + public function get_credentials(){ + $api = API::get_credentials; + $param = []; + return $this->query($api, $param); + } + public function getRecord($file, $out_format){ $api = API::get_record; $param = [ @@ -337,9 +342,11 @@ public function _getFriendList(){ return $this->query($api, $param); } - public function _getGroupInfo(){ + public function _getGroupInfo($flat = false){ $api = API::_get_group_info; - $param = []; + $param = [ + 'flat' => $flat, + ]; return $this->query($api, $param); } @@ -359,8 +366,6 @@ public function __handleQuickOperation($context, $operation){ ]; return $this->query($api, $param); } - ///以上源码部分来自kilingzhang/coolq-php-sdk : src/CoolQ.php - ///许可证:Open Source Licenses/kilingzhang/coolq-php-sdk/LICENSE private function query($api, $param){ $queryStr = '?'; diff --git a/config.ini.example b/config.ini.example index 917d0cf..28754b9 100644 --- a/config.ini.example +++ b/config.ini.example @@ -9,6 +9,7 @@ WelcomeMsg=感谢您添加 kjBot 为好友,发送 !help 查看帮助列表 ;DEBUG=true DebugListen=919815238 ;Listen= +recordStat=true ;这里往下是模块定义的 config,以后可能会改为使用 data Github_Integration_ID= Github_Installation_ID= diff --git a/module/recordStat/global.php b/module/recordStat/global.php new file mode 100644 index 0000000..7d3b6f1 --- /dev/null +++ b/module/recordStat/global.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/module/recordStat/me.php b/module/recordStat/me.php new file mode 100644 index 0000000..ccfea99 --- /dev/null +++ b/module/recordStat/me.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/module/unsleep/main.php b/module/unsleep/main.php index 434b32f..ca48fb7 100644 --- a/module/unsleep/main.php +++ b/module/unsleep/main.php @@ -7,6 +7,6 @@ $group = nextArg(); $CQ->setGroupBan($group, $Event['user_id'], 0); -$Queue[]= '已在 '.$group.' 解除禁言'; +$Queue[]= sendBack('已在 '.$group.' 解除禁言'); ?> \ No newline at end of file diff --git a/public/tools/Autoload.php b/public/tools/Autoload.php index 0eb7501..945f3f8 100644 --- a/public/tools/Autoload.php +++ b/public/tools/Autoload.php @@ -3,6 +3,6 @@ require('frame.php'); require('convert.php'); require('text.php'); -require('statDB.php'); +if(config('recordStat', 'true')=='true')require('statDB.php'); ?> diff --git a/public/tools/frame.php b/public/tools/frame.php index 9a3f517..a3bc0c2 100644 --- a/public/tools/frame.php +++ b/public/tools/frame.php @@ -144,9 +144,11 @@ function loadModule(string $module){ } if(file_exists('../module/'.$moduleFile)){ - if(strpos($module, '.tools')===false){ //防止记录工具类模块 - global $Event; - addCommandCount($Event['user_id'], $module); + if(config('recordStat', 'true')=='true'){ + if(strpos($module, '.tools')===false){ //防止记录工具类模块 + global $Event; + addCommandCount($Event['user_id'], $module); + } } require('../module/'.$moduleFile); }else{ diff --git a/public/tools/statDB.php b/public/tools/statDB.php index 4e41a44..36d7257 100644 --- a/public/tools/statDB.php +++ b/public/tools/statDB.php @@ -1,7 +1,11 @@ query("INSERT INTO record VALUES ({$user_id}, '{$command}', 1)"); @@ -11,7 +15,7 @@ function addCommandCount($user_id, $command){ } } - $row = getCommandCount($user_id, $command); + $row = getCommandCount(0, $command); if($row === false){ $StatDB->query("INSERT INTO record VALUES (0, '{$command}', 1)"); }else{ @@ -28,9 +32,9 @@ function getCommandCount($user_id, $command){ function getUserCommandCount($user_id){ global $StatDB; - $result = $StatDB->query("SELECT command, count FROM record WHERE user_id={$user_id}"); - while($row = $result->fetchArray() && $row !== false){ - $text.="{$row['command']} {$row['count']}"; + $result = $StatDB->query("SELECT command, count FROM record WHERE user_id={$user_id} ORDER BY count DESC"); + while(($row = $result->fetchArray()) && ($row !== false)){ + $text.="{$row['command']} {$row['count']}\n"; } return $text; }