Skip to content

Commit dd755ed

Browse files
committed
Initial commit
0 parents  commit dd755ed

21 files changed

+1016
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
composer.json
2+
composer.lock
3+
4+
modules/
5+
storage/
6+
vendor/
7+
config.ini
8+
plugins.php
9+
modules.php
10+
test.http
11+
test.php

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 kjBot-Dev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# kjBot Framework
2+
3+
kjBot 开发框架
4+
5+
## Framework `composer.json`
6+
7+
```json
8+
{
9+
"license": "MIT",
10+
"type": "project",
11+
"autoload": {
12+
"psr-4": {
13+
"kjBot\\SDK\\": "SDK/",
14+
"kjBot\\Framework\\": "framework/"
15+
"kjBotModule\\": "modules/"
16+
},
17+
"files": ["framework/helpers.php"]
18+
},
19+
"require": {
20+
"php": "^7.2",
21+
"ext-sqlite3": "^7.2"
22+
},
23+
"require-dev": {
24+
},
25+
"suggest": {
26+
},
27+
"scripts": {
28+
},
29+
"config": {
30+
"sort-packages": true,
31+
"optimize-autoloader": true
32+
}
33+
}
34+
```

SDK/API.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
namespace kjBot\SDK;
3+
4+
class API{
5+
const send_private_msg = '/send_private_msg';
6+
const send_private_msg_async = '/send_private_msg_async';
7+
const send_group_msg = '/send_group_msg';
8+
const send_group_msg_async = '/send_group_msg_async';
9+
const send_discuss_msg = '/send_discuss_msg';
10+
const send_discuss_msg_async = '/send_discuss_msg_async';
11+
const send_msg = '/send_msg';
12+
const send_msg_async = '/send_msg_async';
13+
const delete_msg = '/delete_msg';
14+
const send_like = '/send_like';
15+
const set_group_kick = '/set_group_kick';
16+
const set_group_ban = '/set_group_ban';
17+
const set_group_anonymous_ban = '/set_group_anonymous_ban';
18+
const set_group_whole_ban = '/set_group_whole_ban';
19+
const set_group_admin = '/set_group_admin';
20+
const set_group_anonymous = '/set_group_anonymous';
21+
const set_group_card = '/set_group_card';
22+
const set_group_leave = '/set_group_leave';
23+
const set_group_special_title = '/set_group_special_title';
24+
const set_discuss_leave = '/set_discuss_leave';
25+
const set_friend_add_request = '/set_friend_add_request';
26+
const set_group_add_request = '/set_group_add_request';
27+
const get_login_info = '/get_login_info';
28+
const get_stranger_info = '/get_stranger_info';
29+
const get_group_list = '/get_group_list';
30+
const get_group_member_info = '/get_group_member_info';
31+
const get_group_member_list = '/get_group_member_list';
32+
const get_cookies = '/get_cookies';
33+
const get_csrf_token = '/get_csrf_token';
34+
const get_credentials = '/get_credentials';
35+
const get_record = '/get_record';
36+
const get_status = '/get_status';
37+
const get_version_info = '/get_version_info';
38+
const set_restart = '/set_restart';
39+
const set_restart_plugin = '/set_restart_plugin';
40+
const clean_data_dir = '/clean_data_dir';
41+
const clean_plugin_log = '/clean_plugin_log';
42+
const _get_friend_list = '/_get_friend_list';
43+
const _get_group_info = '/_get_group_info';
44+
const _get_vip_info = '/_get_vip_info';
45+
const __check_update = '/.check_update';
46+
const __handle_quick_operation = '/.handle_quick_operation';
47+
}

SDK/CQCode.php

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
namespace kjBot\SDK;
3+
4+
class CQCode{
5+
6+
public static function CQ($type, $argArray = NULL){
7+
$code='[CQ:'.$type;
8+
if(NULL !== $argArray) foreach($argArray as $key => $value){
9+
$code.= (','.$key.'='.self::EncodeCQCode($value));
10+
}
11+
$code.=']';
12+
return $code;
13+
}
14+
15+
public static function At($qq){
16+
return self::CQ('at', ['qq' => $qq]);
17+
}
18+
19+
public static function Face($id){
20+
return self::CQ('face', ['id' => $id]);
21+
}
22+
23+
public static function BFace($id){
24+
return self::CQ('bface', ['id' => $id]);
25+
}
26+
27+
public static function SFace($id){
28+
return self::CQ('sface', ['id' => $id]);
29+
}
30+
31+
public static function Emoji($id){
32+
return self::CQ('emoji', ['id' => $id]);
33+
}
34+
35+
public static function Image($file){
36+
return self::CQ('image', ['file' => $file]);
37+
}
38+
39+
public static function Record($file){
40+
return self::CQ('record', ['file' => $file]);
41+
}
42+
43+
public static function Rps($type){
44+
return self::CQ('rps', ['type' => $type]);
45+
}
46+
47+
public static function Dice($type){
48+
return self::CQ('dice', ['type' => $type]);
49+
}
50+
51+
public static function Shake(){
52+
return self::CQ('shake');
53+
}
54+
55+
public static function Anonymous($ignore){
56+
return $ignore?self::CQ('anonymous', ['ignore' => 'true']):self::CQ('anonymous');
57+
}
58+
59+
public static function Music($type, $id){
60+
return self::CQ('music', [
61+
'type' => $type,
62+
'id' => $id,
63+
]);
64+
}
65+
66+
public static function CustomMusic($audio, $url, $title, $content, $image){
67+
return self::CQ('music', [
68+
'type' => 'custom',
69+
'audio' => $audio,
70+
'url' => $url,
71+
'title' => $title,
72+
'content' => $content,
73+
'image' => $image
74+
]);
75+
}
76+
77+
public static function Share($url, $title, $content, $image){
78+
return self::CQ('share', [
79+
'url' => $url,
80+
'title' => $title,
81+
'content' => $content,
82+
'image' => $image,
83+
]);
84+
}
85+
86+
public static function EncodeCQCode($str){
87+
return str_replace([
88+
'&',
89+
'[',
90+
']',
91+
',',
92+
], [
93+
'&amp;',
94+
'&#91;',
95+
'&#93;',
96+
'&#44;',
97+
], $str);
98+
}
99+
100+
public static function DecodeCQCode($str){
101+
return str_replace([
102+
'&amp;',
103+
'&#91;',
104+
'&#93;',
105+
'&#44;',
106+
],[
107+
'&',
108+
'[',
109+
']',
110+
',',
111+
], $str);
112+
}
113+
114+
}
115+
116+
?>

0 commit comments

Comments
 (0)