mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-17 20:54:52 +08:00
update to build 406 version
This commit is contained in:
parent
60619dbffc
commit
c2d3b5f92a
6
.gitignore
vendored
6
.gitignore
vendored
@ -13,3 +13,9 @@ composer.lock
|
|||||||
.daemon_pid
|
.daemon_pid
|
||||||
/runtime/
|
/runtime/
|
||||||
/tmp/
|
/tmp/
|
||||||
|
/ext/go-cqhttp/data/
|
||||||
|
/ext/go-cqhttp/logs/
|
||||||
|
/ext/go-cqhttp/config.hjson
|
||||||
|
/ext/go-cqhttp/device.json
|
||||||
|
/ext/go-cqhttp/go-cqhttp
|
||||||
|
/ext/go-cqhttp/session.token
|
||||||
|
|||||||
159
build-runtime.sh
159
build-runtime.sh
@ -1,29 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
_php_ver="7.4.16"
|
|
||||||
_libiconv_ver="1.15"
|
|
||||||
_openssl_ver="1.1.1j"
|
|
||||||
_swoole_ver="4.6.3"
|
|
||||||
_home_dir=$(pwd)"/"
|
|
||||||
|
|
||||||
function checkEnv() {
|
|
||||||
echo -n "检测核心组件... "
|
|
||||||
_msg="请通过包管理安装此依赖!"
|
|
||||||
type git >/dev/null 2>&1 || { echo "失败,git 不存在!"$_msg; return 1; }
|
|
||||||
type gcc >/dev/null 2>&1 || { echo "失败,gcc 不存在!"$_msg; return 1; }
|
|
||||||
type g++ >/dev/null 2>&1 || { echo "失败,g++ 不存在!"$_msg; return 1; }
|
|
||||||
type unzip >/dev/null 2>&1 || { echo "失败,unzip 不存在!"$_msg; return 1; }
|
|
||||||
type autoconf >/dev/null 2>&1 || { echo "失败,autoconf 不存在!"; return 1; }
|
|
||||||
type pkg-config >/dev/null 2>&1 || { echo "失败,pkg-config 不存在!"$_msg; return 1; }
|
|
||||||
type wget >/dev/null 2>&1 || type curl >/dev/null 2>&1 || { echo "失败,curl/wget 不存在!"$_msg; return 1; }
|
|
||||||
echo "完成!"
|
|
||||||
echo "如果下载过程中出现错误,请删除 runtime/ 文件夹重试!"
|
|
||||||
echo "此脚本安装的php/swoole均为最小版本,不含其他扩展(如zip、xml、gd)等!"
|
|
||||||
echo -n "如果编译过程缺少依赖,请通过包管理安装对应的依赖![按回车继续] "
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
read ents
|
|
||||||
}
|
|
||||||
|
|
||||||
function downloadIt() {
|
function downloadIt() {
|
||||||
downloader="wget"
|
downloader="wget"
|
||||||
type wget >/dev/null 2>&1 || { downloader="curl"; }
|
type wget >/dev/null 2>&1 || { downloader="curl"; }
|
||||||
@ -34,6 +10,7 @@ function downloadIt() {
|
|||||||
fi
|
fi
|
||||||
_down_symbol=0
|
_down_symbol=0
|
||||||
if [ ! -f "$2" ]; then
|
if [ ! -f "$2" ]; then
|
||||||
|
echo $1
|
||||||
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
|
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
|
||||||
echo "完成!" && _down_symbol=1
|
echo "完成!" && _down_symbol=1
|
||||||
else
|
else
|
||||||
@ -47,6 +24,34 @@ function downloadIt() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadIt https://mirrors.cloud.tencent.com/openssl/source/ /tmp/openssl_ver.html
|
||||||
|
|
||||||
|
_php_ver="7.1.33"
|
||||||
|
_libiconv_ver="1.15"
|
||||||
|
_openssl_ver=$(cat /tmp/openssl_ver.html | grep "openssl-1.1.1.*.tar.gz<" | awk -F\" '{print $2}' | awk -F- '{print $2}' | awk -F".tar.gz" '{print $1}')
|
||||||
|
_swoole_ver="4.6.3"
|
||||||
|
_home_dir=$(pwd)"/"
|
||||||
|
|
||||||
|
function checkEnv() {
|
||||||
|
echo -n "检测核心组件... "
|
||||||
|
_msg="请通过包管理安装此依赖!"
|
||||||
|
type git >/dev/null 2>&1 || { echo "失败,git 不存在!"$_msg; return 1; }
|
||||||
|
type gcc >/dev/null 2>&1 || { echo "失败,gcc 不存在!"$_msg; return 1; }
|
||||||
|
type g++ >/dev/null 2>&1 || { echo "失败,g++ 不存在!"$_msg; return 1; }
|
||||||
|
type unzip >/dev/null 2>&1 || { echo "失败,unzip 不存在!"$_msg; return 1; }
|
||||||
|
type autoconf >/dev/null 2>&1 || { echo "失败,autoconf 不存在!"; return 1; }
|
||||||
|
#type pkg-config >/dev/null 2>&1 || { echo "失败,pkg-config 不存在!"$_msg; return 1; }
|
||||||
|
type wget >/dev/null 2>&1 || type curl >/dev/null 2>&1 || { echo "失败,curl/wget 不存在!"$_msg; return 1; }
|
||||||
|
echo "完成!"
|
||||||
|
echo "如果下载过程中出现错误,请删除 runtime/ 文件夹重试!"
|
||||||
|
echo "此脚本安装的php/swoole均为最小版本,不含其他扩展(如zip、xml、gd)等!"
|
||||||
|
echo -n "如果编译过程缺少依赖,请通过包管理安装对应的依赖![按回车继续] "
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
read ents
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function downloadAll() {
|
function downloadAll() {
|
||||||
# 创建文件夹
|
# 创建文件夹
|
||||||
mkdir "$_home_dir""runtime" >/dev/null 2>&1
|
mkdir "$_home_dir""runtime" >/dev/null 2>&1
|
||||||
@ -56,20 +61,34 @@ function downloadAll() {
|
|||||||
|
|
||||||
# 下载PHP
|
# 下载PHP
|
||||||
echo -n "正在下载 php 源码... "
|
echo -n "正在下载 php 源码... "
|
||||||
downloadIt "http://mirrors.sohu.com/php/php-$_php_ver.tar.gz" "$_down_dir""php.tar.gz" || { exit; }
|
downloadIt "http://mirrors.sohu.com/php/php-$_php_ver.tar.gz" "$_down_dir""php.tar.gz" || { exit; } &
|
||||||
|
|
||||||
# 下载libiconv
|
# 下载libiconv
|
||||||
echo -n "正在下载 libiconv 源码... "
|
echo -n "正在下载 libiconv 源码... "
|
||||||
downloadIt "https://mirrors.tuna.tsinghua.edu.cn/gnu/libiconv/libiconv-$_libiconv_ver.tar.gz" "$_down_dir""libiconv.tar.gz" || { exit; }
|
downloadIt "https://mirrors.tuna.tsinghua.edu.cn/gnu/libiconv/libiconv-$_libiconv_ver.tar.gz" "$_down_dir""libiconv.tar.gz" || { exit; } &
|
||||||
|
|
||||||
echo -n "正在下载 openssl 源码... "
|
echo -n "正在下载 openssl 源码... "
|
||||||
downloadIt "http://mirrors.cloud.tencent.com/openssl/source/openssl-$_openssl_ver.tar.gz" "$_down_dir""openssl.tar.gz" || { exit; }
|
downloadIt "http://mirrors.cloud.tencent.com/openssl/source/openssl-$_openssl_ver.tar.gz" "$_down_dir""openssl.tar.gz" || { exit; } &
|
||||||
|
|
||||||
echo -n "正在下载 swoole 源码... "
|
echo -n "正在下载 swoole 源码... "
|
||||||
downloadIt "https://dl.zhamao.me/swoole/swoole-$_swoole_ver.tgz" "$_down_dir""swoole.tar.gz" || { exit; }
|
downloadIt "https://dl.zhamao.me/swoole/swoole-$_swoole_ver.tgz" "$_down_dir""swoole.tar.gz" || { exit; } &
|
||||||
|
|
||||||
echo -n "正在下载 composer ... "
|
echo -n "正在下载 composer ... "
|
||||||
downloadIt "https://mirrors.aliyun.com/composer/composer.phar" "$_home_dir""runtime/cellar/composer" || { exit; }
|
downloadIt "https://mirrors.aliyun.com/composer/composer.phar" "$_home_dir""runtime/cellar/composer" || { exit; } &
|
||||||
|
|
||||||
|
echo -n "正在下载 zlib ... "
|
||||||
|
downloadIt "https://zlib.net/fossils/zlib-1.2.5.tar.gz" "$_down_dir""zlib.tar.gz" || { exit; } &
|
||||||
|
|
||||||
|
echo -n "正在下载 libxml2 ... "
|
||||||
|
downloadIt "https://dl.zhamao.me/libxml2/libxml2-2.9.8.tar.gz" "$_down_dir""libxml2.tar.gz" || { exit; } &
|
||||||
|
|
||||||
|
echo -n "正在下载 libpng ... "
|
||||||
|
downloadIt "https://dl.zhamao.me/libpng/libpng-1.6.37.tar.gz" "$_down_dir""libpng.tar.gz" || { exit; } &
|
||||||
|
|
||||||
|
echo -n "正在下载 oniguruma ... "
|
||||||
|
downloadIt "https://dl.zhamao.me/oniguruma/onig-6.9.6.tar.gz" "$_down_dir""onig.tar.gz" || { exit; } &
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
#echo -n "正在下载 libcurl 源码... "
|
#echo -n "正在下载 libcurl 源码... "
|
||||||
#downloadIt "https://curl.se/download/curl-7.75.0.tar.gz" "$_down_dir""libcurl.tar.gz" || { exit; }
|
#downloadIt "https://curl.se/download/curl-7.75.0.tar.gz" "$_down_dir""libcurl.tar.gz" || { exit; }
|
||||||
@ -80,6 +99,50 @@ function compileIt() {
|
|||||||
_source_dir="$_home_dir""runtime/tmp_source/"
|
_source_dir="$_home_dir""runtime/tmp_source/"
|
||||||
_cellar_dir="$_home_dir""runtime/cellar/"
|
_cellar_dir="$_home_dir""runtime/cellar/"
|
||||||
case $1 in
|
case $1 in
|
||||||
|
"onig")
|
||||||
|
if [ -f "$_cellar_dir""onig/bin/onig-config" ]; then
|
||||||
|
echo "已编译!" && return
|
||||||
|
fi
|
||||||
|
tar -xf "$_down_dir""onig.tar.gz" -C "$_source_dir" && \
|
||||||
|
cd "$_source_dir""onig-6.9.6" && \
|
||||||
|
./configure --prefix="$_cellar_dir""onig" && \
|
||||||
|
make -j4 && \
|
||||||
|
make install && \
|
||||||
|
echo "完成!"
|
||||||
|
;;
|
||||||
|
"libxml2")
|
||||||
|
if [ -f "$_cellar_dir""libxml2/lib/libxml2.so" ]; then
|
||||||
|
echo "已编译!" && return
|
||||||
|
fi
|
||||||
|
tar -xf "$_down_dir""libxml2.tar.gz" -C "$_source_dir" && \
|
||||||
|
cd "$_source_dir""libxml2-2.9.8" && \
|
||||||
|
./configure --prefix="$_cellar_dir""libxml2" --exec-prefix="$_cellar_dir""libxml2" --without-python && \
|
||||||
|
make -j4 && \
|
||||||
|
make install && \
|
||||||
|
echo "完成!"
|
||||||
|
;;
|
||||||
|
"libpng")
|
||||||
|
if [ -f "$_cellar_dir""libpng/bin/libpng-config" ]; then
|
||||||
|
echo "已编译!" && return
|
||||||
|
fi
|
||||||
|
tar -xf "$_down_dir""libpng.tar.gz" -C "$_source_dir" && \
|
||||||
|
cd "$_source_dir""libpng-1.6.37" && \
|
||||||
|
LDFLAGS="-L$_cellar_dir""zlib/lib" CPPFLAGS="-I$_cellar_dir""zlib/include" ./configure --prefix="$_cellar_dir""libpng" && \
|
||||||
|
make -j4 && \
|
||||||
|
make install && \
|
||||||
|
echo "完成!"
|
||||||
|
;;
|
||||||
|
"zlib")
|
||||||
|
if [ -f "$_cellar_dir""zlib/lib/libz.so" ]; then
|
||||||
|
echo "已编译!" && return
|
||||||
|
fi
|
||||||
|
tar -xf "$_down_dir""zlib.tar.gz" -C "$_source_dir" && \
|
||||||
|
cd "$_source_dir""zlib-1.2.5" && \
|
||||||
|
./configure --prefix="$_cellar_dir""zlib" && \
|
||||||
|
make -j4 && \
|
||||||
|
make install && \
|
||||||
|
echo "完成!"
|
||||||
|
;;
|
||||||
"libiconv")
|
"libiconv")
|
||||||
if [ -f "$_cellar_dir""libiconv/bin/iconv" ]; then
|
if [ -f "$_cellar_dir""libiconv/bin/iconv" ]; then
|
||||||
echo "已编译!" && return
|
echo "已编译!" && return
|
||||||
@ -117,30 +180,31 @@ function compileIt() {
|
|||||||
if [ -f "$_cellar_dir""php/bin/php" ]; then
|
if [ -f "$_cellar_dir""php/bin/php" ]; then
|
||||||
echo "已编译!" && return
|
echo "已编译!" && return
|
||||||
fi
|
fi
|
||||||
|
PKG_CONFIG_PATH="$_cellar_dir""openssl/lib/pkgconfig"
|
||||||
|
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$_cellar_dir""zlib/lib/pkgconfig"
|
||||||
|
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$_cellar_dir""libxml2/lib/pkgconfig"
|
||||||
|
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$_cellar_dir""libpng/lib/pkgconfig"
|
||||||
|
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$_cellar_dir""onig/lib/pkgconfig"
|
||||||
tar -xf "$_down_dir""php.tar.gz" -C "$_source_dir" && \
|
tar -xf "$_down_dir""php.tar.gz" -C "$_source_dir" && \
|
||||||
cd "$_source_dir""php-"$_php_ver && \
|
cd "$_source_dir""php-"$_php_ver && \
|
||||||
./buildconf --force && \
|
./buildconf --force && \
|
||||||
PKG_CONFIG_PATH="$_cellar_dir""openssl/lib/pkgconfig" ./configure --prefix="$_cellar_dir""php" \
|
PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure --prefix="$_cellar_dir""php" \
|
||||||
--with-config-file-path="$_home_dir""runtime/etc" \
|
--with-config-file-path="$_home_dir""runtime/etc" \
|
||||||
--disable-fpm \
|
--disable-fpm \
|
||||||
--enable-cli \
|
--enable-cli \
|
||||||
--enable-posix \
|
--enable-posix \
|
||||||
--enable-ctype \
|
--enable-ctype \
|
||||||
--enable-mysqlnd \
|
--enable-mysqlnd \
|
||||||
|
--enable-mbstring \
|
||||||
|
--enable-gd \
|
||||||
--enable-pdo \
|
--enable-pdo \
|
||||||
--enable-pcntl \
|
--enable-pcntl \
|
||||||
--with-openssl="$_cellar_dir""openssl" \
|
--with-openssl="$_cellar_dir""openssl" \
|
||||||
--enable-sockets \
|
--enable-sockets \
|
||||||
--disable-xml \
|
|
||||||
--disable-xmlreader \
|
|
||||||
--disable-xmlwriter \
|
|
||||||
--without-libxml \
|
|
||||||
--disable-dom \
|
|
||||||
--without-sqlite3 \
|
--without-sqlite3 \
|
||||||
--without-pdo-sqlite \
|
--without-pdo-sqlite \
|
||||||
--disable-simplexml \
|
|
||||||
--with-pdo-mysql=mysqlnd \
|
--with-pdo-mysql=mysqlnd \
|
||||||
--with-zlib \
|
--with-zlib="$_cellar_dir""zlib" \
|
||||||
--with-iconv="$_cellar_dir""libiconv" \
|
--with-iconv="$_cellar_dir""libiconv" \
|
||||||
--enable-phar && \
|
--enable-phar && \
|
||||||
make -j4 && \
|
make -j4 && \
|
||||||
@ -197,6 +261,18 @@ function compileAll() {
|
|||||||
echo -n "正在编译 openssl ... "
|
echo -n "正在编译 openssl ... "
|
||||||
compileIt openssl || { return 1; }
|
compileIt openssl || { return 1; }
|
||||||
|
|
||||||
|
echo -n "正在编译 zlib ... "
|
||||||
|
compileIt zlib || { return 1; }
|
||||||
|
|
||||||
|
echo -n "正在编译 libxml2 ... "
|
||||||
|
compileIt libxml2 || { return 1; }
|
||||||
|
|
||||||
|
echo -n "正在编译 libpng ... "
|
||||||
|
compileIt libpng || { return 1; }
|
||||||
|
|
||||||
|
echo -n "正在编译 oniguruma ... "
|
||||||
|
compileIt onig || { return 1; }
|
||||||
|
|
||||||
#echo -n "正在编译 libzip ... "
|
#echo -n "正在编译 libzip ... "
|
||||||
#compileIt libzip || { exit; }
|
#compileIt libzip || { exit; }
|
||||||
|
|
||||||
@ -205,6 +281,7 @@ function compileAll() {
|
|||||||
|
|
||||||
echo -n "正在编译 swoole ... "
|
echo -n "正在编译 swoole ... "
|
||||||
compileIt swoole || { return 1; }
|
compileIt swoole || { return 1; }
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +290,7 @@ function linkBin(){
|
|||||||
ln -s "$_home_dir""runtime/cellar/php/bin/php" "$_home_dir""runtime/bin/php" >/dev/null 2>&1
|
ln -s "$_home_dir""runtime/cellar/php/bin/php" "$_home_dir""runtime/bin/php" >/dev/null 2>&1
|
||||||
echo "runtime/cellar/php/bin/php runtime/cellar/composer \$@" > "$_home_dir""runtime/bin/composer" && chmod +x "$_home_dir""runtime/bin/composer"
|
echo "runtime/cellar/php/bin/php runtime/cellar/composer \$@" > "$_home_dir""runtime/bin/composer" && chmod +x "$_home_dir""runtime/bin/composer"
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
runtime/bin/composer config repo.packagist composer https://mirrors.aliyun.com/composer/
|
"$_home_dir"runtime/bin/composer config repo.packagist composer https://mirrors.aliyun.com/composer/
|
||||||
}
|
}
|
||||||
|
|
||||||
checkEnv && \
|
checkEnv && \
|
||||||
@ -222,5 +299,7 @@ compileAll && \
|
|||||||
linkBin && \
|
linkBin && \
|
||||||
echo "成功部署所有环境!" && \
|
echo "成功部署所有环境!" && \
|
||||||
echo -e "composer更新依赖:\t\"runtime/bin/composer update\"" && \
|
echo -e "composer更新依赖:\t\"runtime/bin/composer update\"" && \
|
||||||
echo -e "启动框架(源码模式):\t\"runtime/bin/php bin/start server\"" && \
|
echo -e "启动框架(源码模式):\t\"runtime/bin/php bin/start server\"" && \
|
||||||
echo -e "启动框架(普通模式):\t\"runtime/bin/php vendor/bin/start server\""
|
echo -e "启动框架(普通模式):\t\"runtime/bin/php vendor/bin/start server\""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -24,25 +24,30 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-posix": "*",
|
"ext-posix": "*",
|
||||||
"ext-pcntl": "*",
|
"ext-pcntl": "*",
|
||||||
"doctrine/annotations": "~1.10",
|
"doctrine/annotations": "~1.12 || ~1.4.0",
|
||||||
"psy/psysh": "@stable",
|
"psy/psysh": "@stable",
|
||||||
"symfony/polyfill-ctype": "^1.20",
|
"symfony/polyfill-ctype": "^1.19",
|
||||||
"symfony/polyfill-mbstring": "^1.20",
|
"symfony/polyfill-mbstring": "^1.19",
|
||||||
"symfony/console": "^5.1",
|
"symfony/console": "~5.0 || ~4.0 || ~3.0",
|
||||||
"symfony/routing": "^5.1",
|
"symfony/routing": "~5.0 || ~4.0 || ~3.0",
|
||||||
"zhamao/console": "^1.0.10",
|
"zhamao/console": "^1.0.10",
|
||||||
"zhamao/config": "^1.0",
|
"zhamao/config": "^1.0",
|
||||||
"zhamao/request": "^1.1",
|
"zhamao/request": "^1.1",
|
||||||
"zhamao/connection-manager": "^1.0"
|
"zhamao/connection-manager": "^1.0",
|
||||||
|
"league/climate": "^3.7"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-ctype": "Use C/C++ extension instead of polyfill will be more efficient",
|
"ext-ctype": "Use C/C++ extension instead of polyfill will be more efficient",
|
||||||
"ext-mbstring": "Use C/C++ extension instead of polyfill will be more efficient",
|
"ext-mbstring": "Use C/C++ extension instead of polyfill will be more efficient",
|
||||||
|
"ext-pdo_mysql": "If you use mysql in framework, you will need this extension",
|
||||||
|
"ext-redis": "If you use Redis in framework, you will need this extension",
|
||||||
"league/climate": "Display columns and status in terminal"
|
"league/climate": "Display columns and status in terminal"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"ZM\\": "src/ZM"
|
"ZM\\": "src/ZM",
|
||||||
|
"Module\\": "src/Module",
|
||||||
|
"Custom\\": "src/Custom"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src/ZM/global_functions.php"
|
"src/ZM/global_functions.php"
|
||||||
|
|||||||
29
ext/go-cqhttp/go-cqhttp-down.sh
Executable file
29
ext/go-cqhttp/go-cqhttp-down.sh
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "正在检查最新版本的go-cqhttp..."
|
||||||
|
|
||||||
|
if [ "$(uname -m)" = "x86_64" ]; then
|
||||||
|
arch_type="amd64"
|
||||||
|
elif [ "$(uname -m)" = "i386" ]; then
|
||||||
|
arch_type="386"
|
||||||
|
fi
|
||||||
|
|
||||||
|
aas=$(uname -s | tr 'A-Z' 'a-z')
|
||||||
|
|
||||||
|
ver=$(wget -qO- -t1 -T2 "https://fgit-api.zhamao.me/repos/Mrs4s/go-cqhttp/releases" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||||
|
|
||||||
|
if [ "$ver" != "" ]; then
|
||||||
|
echo "最新版本:"$ver
|
||||||
|
echo -n "是否下载到本地?[y/N] "
|
||||||
|
read option
|
||||||
|
if [ "$option" = "y" ]; then
|
||||||
|
wget https://fgit.zhamao.me/Mrs4s/go-cqhttp/releases/download/$ver/go-cqhttp-$ver-$aas-$arch_type.tar.gz -O temp.tar.gz
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
wget https://fgit.zhamao.me/Mrs4s/go-cqhttp/releases/download/$ver/go-cqhttp_"$aas""_""$arch_type"".tar.gz" -O temp.tar.gz
|
||||||
|
fi
|
||||||
|
tar -zxvf temp.tar.gz go-cqhttp
|
||||||
|
rm temp.tar.gz
|
||||||
|
echo "下载完成,启动命令:./go-cqhttp"
|
||||||
|
echo "首次启动后先编辑config.hjson文件!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@ -12,7 +12,7 @@ abstract class AnnotationBase
|
|||||||
|
|
||||||
public $class;
|
public $class;
|
||||||
|
|
||||||
public function __toString(): string {
|
public function __toString() {
|
||||||
$str = __CLASS__ . ": ";
|
$str = __CLASS__ . ": ";
|
||||||
foreach ($this as $k => $v) {
|
foreach ($this as $k => $v) {
|
||||||
$str .= "\n\t" . $k . " => ";
|
$str .= "\n\t" . $k . " => ";
|
||||||
|
|||||||
@ -9,7 +9,12 @@ use ZM\Console\Console;
|
|||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use ReflectionMethod;
|
use ReflectionMethod;
|
||||||
use ZM\Annotation\Http\{HandleAfter, HandleBefore, HandleException, Middleware, MiddlewareClass, RequestMapping};
|
use ZM\Annotation\Http\HandleAfter;
|
||||||
|
use ZM\Annotation\Http\HandleBefore;
|
||||||
|
use ZM\Annotation\Http\HandleException;
|
||||||
|
use ZM\Annotation\Http\Middleware;
|
||||||
|
use ZM\Annotation\Http\MiddlewareClass;
|
||||||
|
use ZM\Annotation\Http\RequestMapping;
|
||||||
use ZM\Annotation\Interfaces\Level;
|
use ZM\Annotation\Interfaces\Level;
|
||||||
use ZM\Annotation\Module\Closed;
|
use ZM\Annotation\Module\Closed;
|
||||||
use ZM\Http\RouteManager;
|
use ZM\Http\RouteManager;
|
||||||
@ -125,7 +130,7 @@ class AnnotationParser
|
|||||||
Console::debug("解析注解完毕!");
|
Console::debug("解析注解完毕!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateAnnotationEvents(): array {
|
public function generateAnnotationEvents() {
|
||||||
$o = [];
|
$o = [];
|
||||||
foreach ($this->annotation_map as $module => $obj) {
|
foreach ($this->annotation_map as $module => $obj) {
|
||||||
foreach (($obj["class_annotations"] ?? []) as $class_annotation) {
|
foreach (($obj["class_annotations"] ?? []) as $class_annotation) {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class CQAfter extends AnnotationBase implements Level
|
|||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getLevel(): int {
|
public function getLevel() {
|
||||||
return $this->level;
|
return $this->level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,6 +48,6 @@ class CQCommand extends AnnotationBase implements Level
|
|||||||
/**
|
/**
|
||||||
* @param int $level
|
* @param int $level
|
||||||
*/
|
*/
|
||||||
public function setLevel(int $level) { $this->level = $level; }
|
public function setLevel($level) { $this->level = $level; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class CQMessage extends AnnotationBase implements Level
|
|||||||
|
|
||||||
public function getLevel(): int { return $this->level; }
|
public function getLevel(): int { return $this->level; }
|
||||||
|
|
||||||
public function setLevel(int $level) {
|
public function setLevel($level) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ class CQMetaEvent extends AnnotationBase implements Level
|
|||||||
/**
|
/**
|
||||||
* @param int $level
|
* @param int $level
|
||||||
*/
|
*/
|
||||||
public function setLevel(int $level) {
|
public function setLevel($level) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ class CQNotice extends AnnotationBase implements Level
|
|||||||
/**
|
/**
|
||||||
* @param int $level
|
* @param int $level
|
||||||
*/
|
*/
|
||||||
public function setLevel(int $level) {
|
public function setLevel($level) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ class CQRequest extends AnnotationBase implements Level
|
|||||||
/**
|
/**
|
||||||
* @param int $level
|
* @param int $level
|
||||||
*/
|
*/
|
||||||
public function setLevel(int $level) {
|
public function setLevel($level) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,5 +8,5 @@ interface Level
|
|||||||
{
|
{
|
||||||
public function getLevel();
|
public function getLevel();
|
||||||
|
|
||||||
public function setLevel(int $level);
|
public function setLevel($level);
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ abstract class OnSwooleEventBase extends AnnotationBase implements Level, Rule
|
|||||||
/**
|
/**
|
||||||
* @param int $level
|
* @param int $level
|
||||||
*/
|
*/
|
||||||
public function setLevel(int $level) {
|
public function setLevel($level) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,23 +32,23 @@ class BuildCommand extends Command
|
|||||||
if (mb_strpos($target_dir, "../")) $target_dir = realpath($target_dir);
|
if (mb_strpos($target_dir, "../")) $target_dir = realpath($target_dir);
|
||||||
if ($target_dir === false) {
|
if ($target_dir === false) {
|
||||||
$output->writeln(TermColor::color8(31) . "Error: No such file or directory (" . __DIR__ . '/../../../resources/' . ")" . TermColor::RESET);
|
$output->writeln(TermColor::color8(31) . "Error: No such file or directory (" . __DIR__ . '/../../../resources/' . ")" . TermColor::RESET);
|
||||||
return Command::FAILURE;
|
return 1;
|
||||||
}
|
}
|
||||||
$output->writeln("Target: " . $target_dir . " , Version: " . ($version = json_decode(file_get_contents(__DIR__ . "/../../../composer.json"), true)["version"]));
|
$output->writeln("Target: " . $target_dir . " , Version: " . ($version = json_decode(file_get_contents(__DIR__ . "/../../../composer.json"), true)["version"]));
|
||||||
if (mb_substr($target_dir, -1, 1) !== '/') $target_dir .= "/";
|
if (mb_substr($target_dir, -1, 1) !== '/') $target_dir .= "/";
|
||||||
if (ini_get('phar.readonly') == 1) {
|
if (ini_get('phar.readonly') == 1) {
|
||||||
$output->writeln(TermColor::color8(31) . "You need to set \"phar.readonly\" to \"Off\"!");
|
$output->writeln(TermColor::color8(31) . "You need to set \"phar.readonly\" to \"Off\"!");
|
||||||
$output->writeln(TermColor::color8(31) . "See: https://stackoverflow.com/questions/34667606/cant-enable-phar-writing");
|
$output->writeln(TermColor::color8(31) . "See: https://stackoverflow.com/questions/34667606/cant-enable-phar-writing");
|
||||||
return Command::FAILURE;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!is_dir($target_dir)) {
|
if (!is_dir($target_dir)) {
|
||||||
$output->writeln(TermColor::color8(31) . "Error: No such file or directory ($target_dir)" . TermColor::RESET);
|
$output->writeln(TermColor::color8(31) . "Error: No such file or directory ($target_dir)" . TermColor::RESET);
|
||||||
return Command::FAILURE;
|
return 1;
|
||||||
}
|
}
|
||||||
$filename = "server.phar";
|
$filename = "server.phar";
|
||||||
$this->build($target_dir, $filename);
|
$this->build($target_dir, $filename);
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function build($target_dir, $filename) {
|
private function build($target_dir, $filename) {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class CheckConfigCommand extends Command
|
|||||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||||
if (LOAD_MODE !== 1) {
|
if (LOAD_MODE !== 1) {
|
||||||
$output->writeln("<error>仅限在Composer依赖模式中使用此命令!</error>");
|
$output->writeln("<error>仅限在Composer依赖模式中使用此命令!</error>");
|
||||||
return Command::FAILURE;
|
return 1;
|
||||||
}
|
}
|
||||||
$current_cfg = getcwd() . "/config/";
|
$current_cfg = getcwd() . "/config/";
|
||||||
$remote_cfg = include_once FRAMEWORK_ROOT_DIR . "/config/global.php";
|
$remote_cfg = include_once FRAMEWORK_ROOT_DIR . "/config/global.php";
|
||||||
@ -42,7 +42,7 @@ class CheckConfigCommand extends Command
|
|||||||
$output->writeln("<info>配置文件暂无更新!</info>");
|
$output->writeln("<info>配置文件暂无更新!</info>");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -26,6 +26,6 @@ abstract class DaemonCommand extends Command
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
$this->daemon_file = $file;
|
$this->daemon_file = $file;
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -19,6 +19,6 @@ class DaemonReloadCommand extends DaemonCommand
|
|||||||
parent::execute($input, $output);
|
parent::execute($input, $output);
|
||||||
system("kill -USR1 " . intval($this->daemon_file["pid"]));
|
system("kill -USR1 " . intval($this->daemon_file["pid"]));
|
||||||
$output->writeln("<info>成功重载!</info>");
|
$output->writeln("<info>成功重载!</info>");
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,6 @@ class DaemonStatusCommand extends DaemonCommand
|
|||||||
if (isset($stdout[count($stdout) - $i]))
|
if (isset($stdout[count($stdout) - $i]))
|
||||||
echo $stdout[count($stdout) - $i] . PHP_EOL;
|
echo $stdout[count($stdout) - $i] . PHP_EOL;
|
||||||
}
|
}
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,6 @@ class DaemonStopCommand extends DaemonCommand
|
|||||||
system("kill -INT " . intval($this->daemon_file["pid"]));
|
system("kill -INT " . intval($this->daemon_file["pid"]));
|
||||||
unlink(DataProvider::getWorkingDir() . "/.daemon_pid");
|
unlink(DataProvider::getWorkingDir() . "/.daemon_pid");
|
||||||
$output->writeln("<info>成功停止!</info>");
|
$output->writeln("<info>成功停止!</info>");
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,10 +83,10 @@ class InitCommand extends Command
|
|||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
echo("Error occurred. Please check your updates.\n");
|
echo("Error occurred. Please check your updates.\n");
|
||||||
return Command::FAILURE;
|
return 1;
|
||||||
}
|
}
|
||||||
$output->writeln("<info>Done!</info>");
|
$output->writeln("<info>Done!</info>");
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
} elseif (LOAD_MODE === 2) { //从phar启动的框架包,初始化的模式
|
} elseif (LOAD_MODE === 2) { //从phar启动的框架包,初始化的模式
|
||||||
$phar_link = new Phar(__DIR__);
|
$phar_link = new Phar(__DIR__);
|
||||||
$current_dir = pathinfo($phar_link->getPath())["dirname"];
|
$current_dir = pathinfo($phar_link->getPath())["dirname"];
|
||||||
@ -104,7 +104,7 @@ class InitCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$output->writeln("initialization must be started with composer-project mode!");
|
$output->writeln("initialization must be started with composer-project mode!");
|
||||||
return Command::FAILURE;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getExtractFiles(): array {
|
private function getExtractFiles(): array {
|
||||||
|
|||||||
@ -89,10 +89,10 @@ class PureHttpCommand extends Command
|
|||||||
$server->start();
|
$server->start();
|
||||||
// return this if there was no problem running the command
|
// return this if there was no problem running the command
|
||||||
// (it's equivalent to returning int(0))
|
// (it's equivalent to returning int(0))
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
|
|
||||||
// or return this if some error happened during the execution
|
// or return this if some error happened during the execution
|
||||||
// (it's equivalent to returning int(1))
|
// (it's equivalent to returning int(1))
|
||||||
// return Command::FAILURE;
|
// return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,10 +40,10 @@ class RunServerCommand extends Command
|
|||||||
if (($opt = $input->getOption("env")) !== null) {
|
if (($opt = $input->getOption("env")) !== null) {
|
||||||
if (!in_array($opt, ["production", "staging", "development", ""])) {
|
if (!in_array($opt, ["production", "staging", "development", ""])) {
|
||||||
$output->writeln("<error> \"--env\" option only accept production, development, staging and [empty] ! </error>");
|
$output->writeln("<error> \"--env\" option only accept production, development, staging and [empty] ! </error>");
|
||||||
return Command::FAILURE;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(new Framework($input->getOptions()))->start();
|
(new Framework($input->getOptions()))->start();
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class SystemdCommand extends Command
|
|||||||
$path = $this->generate();
|
$path = $this->generate();
|
||||||
$output->writeln("<info>成功生成 systemd 文件,位置:".$path."</info>");
|
$output->writeln("<info>成功生成 systemd 文件,位置:".$path."</info>");
|
||||||
$output->writeln("<info>有关如何使用 systemd 配置文件,请访问 `https://github.com/zhamao-robot/zhamao-framework/issues/36`</info>");
|
$output->writeln("<info>有关如何使用 systemd 配置文件,请访问 `https://github.com/zhamao-robot/zhamao-framework/issues/36`</info>");
|
||||||
return Command::SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate() {
|
private function generate() {
|
||||||
|
|||||||
@ -19,8 +19,8 @@ use ZM\Command\SystemdCommand;
|
|||||||
|
|
||||||
class ConsoleApplication extends Application
|
class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
const VERSION_ID = 405;
|
const VERSION_ID = 406;
|
||||||
const VERSION = "2.4.4";
|
const VERSION = "2.4.5";
|
||||||
|
|
||||||
public function __construct(string $name = 'UNKNOWN') {
|
public function __construct(string $name = 'UNKNOWN') {
|
||||||
define("ZM_VERSION_ID", self::VERSION_ID);
|
define("ZM_VERSION_ID", self::VERSION_ID);
|
||||||
|
|||||||
@ -28,9 +28,9 @@ class OnClose implements SwooleEvent
|
|||||||
/** @noinspection PhpUnreachableStatementInspection */
|
/** @noinspection PhpUnreachableStatementInspection */
|
||||||
public function onCall($server, $fd) {
|
public function onCall($server, $fd) {
|
||||||
unset(Context::$context[Co::getCid()]);
|
unset(Context::$context[Co::getCid()]);
|
||||||
|
Console::debug("Calling Swoole \"close\" event from fd=" . $fd);
|
||||||
$conn = ManagerGM::get($fd);
|
$conn = ManagerGM::get($fd);
|
||||||
if ($conn === null) return;
|
if ($conn === null) return;
|
||||||
Console::debug("Calling Swoole \"close\" event from fd=" . $fd);
|
|
||||||
set_coroutine_params(["server" => $server, "connection" => $conn, "fd" => $fd]);
|
set_coroutine_params(["server" => $server, "connection" => $conn, "fd" => $fd]);
|
||||||
|
|
||||||
$dispatcher1 = new EventDispatcher(OnCloseEvent::class);
|
$dispatcher1 = new EventDispatcher(OnCloseEvent::class);
|
||||||
|
|||||||
@ -59,7 +59,7 @@ class OnWorkerStart implements SwooleEvent
|
|||||||
try {
|
try {
|
||||||
register_shutdown_function(function () use ($server) {
|
register_shutdown_function(function () use ($server) {
|
||||||
$error = error_get_last();
|
$error = error_get_last();
|
||||||
if ($error["type"] != 0) {
|
if (($error["type"] ?? -1) != 0) {
|
||||||
Console::error("Internal fatal error: " . $error["message"] . " at " . $error["file"] . "({$error["line"]})");
|
Console::error("Internal fatal error: " . $error["message"] . " at " . $error["file"] . "({$error["line"]})");
|
||||||
}
|
}
|
||||||
//DataProvider::saveBuffer();
|
//DataProvider::saveBuffer();
|
||||||
|
|||||||
@ -8,8 +8,8 @@ define("ZM_DATA", ZMConfig::get("global", "zm_data"));
|
|||||||
define("APP_VERSION", LOAD_MODE == 1 ? (json_decode(file_get_contents(DataProvider::getWorkingDir() . "/composer.json"), true)["version"] ?? "unknown") : "unknown");
|
define("APP_VERSION", LOAD_MODE == 1 ? (json_decode(file_get_contents(DataProvider::getWorkingDir() . "/composer.json"), true)["version"] ?? "unknown") : "unknown");
|
||||||
define("CRASH_DIR", ZMConfig::get("global", "crash_dir"));
|
define("CRASH_DIR", ZMConfig::get("global", "crash_dir"));
|
||||||
define("MAIN_WORKER", ZMConfig::get("global", "worker_cache")["worker"] ?? 0);
|
define("MAIN_WORKER", ZMConfig::get("global", "worker_cache")["worker"] ?? 0);
|
||||||
@mkdir(ZM_DATA);
|
if (!is_dir(ZM_DATA)) @mkdir(ZM_DATA);
|
||||||
@mkdir(CRASH_DIR);
|
if (!is_dir(CRASH_DIR)) @mkdir(CRASH_DIR);
|
||||||
|
|
||||||
define("CONN_WEBSOCKET", 0);
|
define("CONN_WEBSOCKET", 0);
|
||||||
define("CONN_HTTP", 1);
|
define("CONN_HTTP", 1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user