Skip to content

Commit 76f88a3

Browse files
authored
Merge pull request #80 from botuniverse/develop
0.5.0 release
2 parents e0a374b + a49f66d commit 76f88a3

File tree

137 files changed

+2688
-3758
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+2688
-3758
lines changed

.github/workflows/coding-style-analysis.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/coding-style.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Code Style
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
pre_job:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
13+
steps:
14+
- id: skip_check
15+
uses: fkirc/skip-duplicate-actions@v4
16+
with:
17+
concurrent_skipping: same_content_newer
18+
skip_after_successful_duplicate: true
19+
paths: '["src/**", "tests/**"]'
20+
do_not_skip: '["workflow_dispatch", "schedule"]'
21+
22+
cs-fix:
23+
needs: pre_job
24+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
25+
name: Code Style
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v2
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Setup PHP
34+
uses: sunxyw/workflows/setup-environment@main
35+
with:
36+
php-version: 8.0
37+
php-extensions: swoole, posix, json
38+
operating-system: ubuntu-latest
39+
use-cache: true
40+
41+
- name: Code Style
42+
uses: sunxyw/workflows/coding-style@main

.github/workflows/integration-test.yaml

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/workflows/static-analysis.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
pre_job:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
13+
steps:
14+
- id: skip_check
15+
uses: fkirc/skip-duplicate-actions@v4
16+
with:
17+
concurrent_skipping: same_content_newer
18+
skip_after_successful_duplicate: true
19+
paths: '["src/**", "tests/**"]'
20+
do_not_skip: '["workflow_dispatch", "schedule"]'
21+
22+
analyse:
23+
needs: pre_job
24+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
25+
name: Static Analysis
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v2
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Setup PHP
34+
uses: sunxyw/workflows/setup-environment@main
35+
with:
36+
php-version: 7.4
37+
php-extensions: swoole, posix, json
38+
operating-system: ubuntu-latest
39+
use-cache: true
40+
41+
- name: Static Analysis
42+
uses: sunxyw/workflows/static-analysis@main

.github/workflows/test.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
- '*-dev*'
9+
pull_request:
10+
types:
11+
- opened
12+
- reopened
13+
- review_requested
14+
workflow_dispatch:
15+
16+
jobs:
17+
pre_job:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
21+
steps:
22+
- id: skip_check
23+
uses: fkirc/skip-duplicate-actions@v4
24+
with:
25+
concurrent_skipping: same_content_newer
26+
skip_after_successful_duplicate: true
27+
paths: '["src/**", "tests/**", "bin/phpunit-zm"]'
28+
do_not_skip: '["workflow_dispatch", "schedule"]'
29+
30+
test:
31+
needs: pre_job
32+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
33+
strategy:
34+
matrix:
35+
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
36+
php-version: [ 7.4, 8.0, 8.1 ]
37+
name: PHP ${{ matrix.php-version }} Test (${{ matrix.operating-system }})
38+
runs-on: ${{ matrix.operating-system }}
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v2
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Setup PHP
46+
uses: sunxyw/workflows/setup-environment@main
47+
with:
48+
php-version: ${{ matrix.php-version }}
49+
php-extensions: swoole, posix, json
50+
operating-system: ${{ matrix.operating-system }}
51+
use-cache: true
52+
53+
- name: Test
54+
uses: sunxyw/workflows/test@main

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ cghooks.lock
4747
### Phive ###
4848
tools
4949
.phive
50+
51+
### pcov coverage report
52+
build/
53+
54+
data/

.php-cs-fixer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
'types_spaces' => false,
7171
'braces' => false,
7272
'blank_line_between_import_groups' => false,
73+
'phpdoc_order' => ['order' => ['param', 'throws', 'return']],
74+
'php_unit_test_class_requires_covers' => false,
7375
])
7476
->setFinder(
7577
PhpCsFixer\Finder::create()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $ob->setLogger(new \OneBot\Logger\Console\ConsoleLogger());
4343
$ob->setDriver(
4444
// 此处也可以在 Linux 系统下安装 swoole 扩展后使用 SwooleDriver() 拥有协程能力
4545
new \OneBot\Driver\Workerman\WorkermanDriver(),
46-
new \OneBot\V12\Config\Config('demo.json')
46+
new \OneBot\Config\Repository('demo.json')
4747
);
4848
$ob->setActionHandlerClass(\OneBot\V12\Action\ReplAction::class);
4949
$ob->run();

choir-test.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/** @noinspection PhpComposerExtensionStubsInspection */
4+
5+
declare(strict_types=1);
6+
7+
require_once 'vendor/autoload.php';
8+
9+
$server = new \Choir\Http\Server('0.0.0.0', 20001, false, [
10+
'worker-num' => 8,
11+
// 'logger-level' => 'debug',
12+
]);
13+
14+
$server->on('workerstart', function () {
15+
// xhprof_enable();
16+
});
17+
18+
$server->on('workerstop', function () {
19+
// $data = xhprof_disable();
20+
// $x = new XHProfRuns_Default();
21+
// $id = $x->save_run($data, 'xhprof_testing');
22+
// echo "http://127.0.0.1:8080/index.php?run={$id}&source=xhprof_testing\n";
23+
});
24+
25+
$server->on('request', function (Choir\Protocol\HttpConnection $connection) {
26+
$connection->end('hello world');
27+
});
28+
29+
require_once '/private/tmp/xhprof-2.3.8/xhprof_lib/utils/xhprof_lib.php';
30+
require_once '/private/tmp/xhprof-2.3.8/xhprof_lib/utils/xhprof_runs.php';
31+
32+
$server->start();

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
"wiki": "https://github.com/botuniverse/php-libonebot/wiki"
2626
},
2727
"require": {
28-
"php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1",
28+
"php": "^7.4 || ^8.0 || ^8.1 || ^8.2",
2929
"ext-json": "*",
3030
"psr/cache": "^1.0",
3131
"psr/event-dispatcher": "^1.0",
3232
"psr/http-client": "^1.0",
3333
"psr/log": "^1.1",
3434
"rybakit/msgpack": "^0.9.0",
35+
"choir/psr-http": "^1.0",
3536
"workerman/workerman": "^4.0",
3637
"zhamao/logger": "^1.0"
3738
},

demo/repl.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
use OneBot\Driver\Event\DriverInitEvent;
66
use OneBot\Util\Utils;
7-
use OneBot\V12\Action\ActionResponse;
87
use OneBot\V12\Object\Action;
9-
use OneBot\V12\Object\Event\Message\PrivateMessageEvent;
8+
use OneBot\V12\Object\ActionResponse;
109
use OneBot\V12\OneBot;
1110
use OneBot\V12\OneBotBuilder;
1211
use OneBot\V12\Validator;
@@ -82,7 +81,12 @@ function message_id(): string
8281
$event->getDriver()->getEventLoop()->delReadEvent($x);
8382
return;
8483
}
85-
$event = new PrivateMessageEvent('tty', trim($s));
84+
$event = (new \OneBot\V12\EventBuilder('message', 'private'))
85+
->feed('message', trim($s))
86+
->feed('alt_message', trim($s))
87+
->feed('message_id', message_id())
88+
->feed('user_id', 'tty')
89+
->build();
8690
OneBot::getInstance()->dispatchEvent($event);
8791
});
8892
}, 0);

0 commit comments

Comments
 (0)