Skip to content
This repository has been archived by the owner on May 22, 2022. It is now read-only.

Commit

Permalink
feat: deviation analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
yuudi committed Oct 2, 2020
1 parent 270f4a6 commit 2fbfc3b
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 176 deletions.
8 changes: 0 additions & 8 deletions .env.example

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: docker-build

on: [push]

jobs:
build:
runs-on: ubuntu-latest
name: auto build

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Build image
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESSTOKEN }}
repository: yobot/yobot
tags: latest,slim
48 changes: 14 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,23 @@
FROM python:3.7-slim-buster
LABEL maintainer="AzurCrystal"
LABEL maintainer="yobot"

ARG PUID=1000
ENV PYTHONIOENCODING=utf-8
RUN set -x \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo 'Asia/Shanghai' >/etc/timezone \
&& { \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free"; \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free"; \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free"; \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free"; \
} > /etc/apt/sources.list \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean \
&& apt-get update \
&& apt-get install git -y --no-install-recommends --no-install-suggests \
&& useradd -u $PUID -m yobot \
&& su yobot -c \
"mkdir -p /home/yobot \
&& cd /home/yobot \
&& git clone https://gitee.com/yobot/yobot.git \
&& { \
echo '#!/bin/sh'; \
echo 'cd /home/yobot/yobot/src/client && python3 /home/yobot/yobot/src/client/main.py && sh /home/yobot/yobot/src/client/yobotg.sh'; \
} > /home/yobot/entry.sh \
&& chmod 755 /home/yobot/entry.sh \
&& chmod +x /home/yobot/entry.sh" \
&& pip3 install --no-cache-dir -r /home/yobot/yobot/src/client/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*

USER yobot
ADD src/client/ /yobot

WORKDIR /home/yobot
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo 'Asia/Shanghai' >/etc/timezone \
&& cd /yobot \
&& useradd yobot \
&& pip3 install aiocqhttp==0.6.8 Quart==0.6.15 --no-cache-dir \
&& pip3 install -r requirements.txt --no-cache-dir \
&& python3 main.py \
&& chmod +x yobotg.sh

WORKDIR /yobot

EXPOSE 9222

VOLUME /home/yobot/yobot
VOLUME /yobot/yobot_data

ENTRYPOINT /home/yobot/entry.sh
ENTRYPOINT /yobot/yobotg.sh
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# yobot

当前大版本已归档(archive),不再更新。项目整体重构中。基于 QQ 的部分已不再支持,重构后将基于其他平台。

[yobot](./about.md) 是为[公主连接](https://game.bilibili.com/pcr/)公会战设计的辅助机器人,能够帮助公会战管理者提供自动化管理服务。

yobot 提供了群聊、web 页面两套用户交互方式,具有操作便捷、通知及时、数据详细的特点。
Expand Down
48 changes: 0 additions & 48 deletions docker-compose.yml

This file was deleted.

111 changes: 73 additions & 38 deletions scripts/yobot-mirai-auto.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this file should be saved as "UTF-8 with BOM"
$ErrorActionPreference = "Inquire"
$ErrorActionPreference = "Stop"

# 检查运行环境
if ($Host.Version.Major -lt 5) {
Expand All @@ -10,67 +10,102 @@ if ((Get-ChildItem -Path Env:OS).Value -ine 'Windows_NT') {
Write-Output '当前操作系统不支持一键安装'
exit
}
if ([Environment]::Is64BitProcess) {
}
else {
if (![Environment]::Is64BitProcess) {
Write-Output '暂时不支持32位系统'
exit
}
if (Test-Path .\qqbot) {
Write-Output '发现重复,是否删除旧文件并重新安装?'
$reinstall = Read-Host '请输入 y 或 n (y/n)'
Switch ($reinstall) {
Y { Remove-Item .\qqbot -Recurse -Force }
N { exit }
Default { exit }
}
Switch ($reinstall) {
Y { Remove-Item .\qqbot -Recurse -Force }
N { exit }
Default { exit }
}
}

# 用户输入
$qqid = Read-Host '请输入作为机器人的QQ号:'
$qqpassword = Read-Host '请输入作为机器人的QQ密码:'
$qqpassword = Read-Host -AsSecureString '请输入作为机器人的QQ密码:'
Write-Output '是否使用YoCool皮肤(测试版):'
$yocool = Read-Host '请输入 y 或 n (y/n)'
Switch ($yocool) {
Y { $yocool = $true }
N { $yocool = $false }
Default { $yocool = $false }
}
Write-Output '是否监听80端口(如果此服务器没有其他网站,建议选 y):'
$listen_80 = Read-Host '请输入 y 或 n (y/n)'
Switch ($listen_80) {
Y { $port = 80 }
N { $port = 9222 }
Default { $port = 9222 }
}
Switch ($listen_80) {
Y { $port = 80 }
N { $port = 9222 }
Default { $port = 9222 }
}

# 创建运行目录
New-Item -Path .\qqbot -ItemType Directory
Set-Location qqbot
New-Item -ItemType Directory -Path .\yobot, .\yobot\yobot_data, .\mirai, .\mirai\plugins, .\mirai\plugins\CQHTTPMirai

# 下载程序
Invoke-WebRequest https://get.yobot.win/scyb/miraiOK_win_amd64.exe -OutFile .\mirai\miraiOK.exe
if ((Get-FileHash -Path .\mirai\miraiOK.exe -Algorithm SHA256).Hash -ne "60B4B16AC401ADD7D75FADA83344B50EBA9F0976F73113FF6D95E5C09E79941F") { Write-Output '下载失败'; exit }
Invoke-WebRequest https://get.yobot.win/scyb/cqhttp-mirai-0.1.9-all.jar -OutFile .\mirai\plugins\cqhttp-mirai-0.1.9-all.jar
if ((Get-FileHash -Path .\mirai\plugins\cqhttp-mirai-0.1.9-all.jar -Algorithm SHA256).Hash -ne "6A93DB2B422D93B1632A92C8E0AC25FE51050A5474B36B252BB2E1A8D22B5B0D") { Write-Output '下载失败'; exit }
Invoke-WebRequest https://get.yobot.win/scyb/yobot208.zip -OutFile .\yobot.zip
if ((Get-FileHash -Path .\yobot.zip -Algorithm SHA256).Hash -ne "5D5FE0CBEEA746D4C50303794C4E01C0A7EAA54D805873CA3269BBEF35BEA643") { Write-Output '下载失败'; exit }
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest https://pan.yobot.win/yobot/wget.exe -OutFile .\wget.exe
.\wget.exe https://download.fastgit.org/Mrs4s/go-cqhttp/releases/download/v0.9.25-fix3/go-cqhttp-v0.9.25-fix3-windows-amd64.zip -O .\go-cqhttp.zip
Expand-Archive go-cqhttp.zip -DestinationPath .\mirai\
Remove-Item go-cqhttp.zip
if ($yocool) {
.\wget.exe https://pan.yobot.win/yobot/yocool.zip -O .\yobot.zip
}
else {
.\wget.exe https://pan.yobot.win/yobot/yobot.zip -O .\yobot.zip
}
Expand-Archive yobot.zip -DestinationPath .\yobot\
if ($yocool) { Move-Item .\yobot\yobot--with-yocool.exe .\yobot\yobot.exe }
Remove-Item yobot.zip

# 生成随机 access_token
$token = -join ((65..90) + (97..122) | Get-Random -Count 16 | ForEach-Object { [char]$_ })

# 写入 cqmiraihttp 配置文件
New-Item -Path .\mirai\plugins\CQHTTPMirai\setting.yml -ItemType File -Value @"
"${qqid}":
ws_reverse:
- enable: true
postMessageFormat: string
reverseHost: 127.0.0.1
reversePort: ${port}
reversePath: /ws/
accessToken: ${token}
reconnectInterval: 3000
# 写入 go-cqhttp 配置文件
$realpassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($qqpassword))
New-Item -Path .\mirai\config.json -ItemType File -Value @"
{
"uin": ${qqid},
"password": "${realpassword}",
"encrypt_password": false,
"password_encrypted": `"`",
"enable_db": false,
"access_token": "${token}",
"relogin": {
"enabled": true,
"relogin_delay": 3,
"max_relogin_times": 0
},
"_rate_limit": {
"enabled": false,
"frequency": 1,
"bucket_size": 1
},
"post_message_format": "string",
"ignore_invalid_cqcode": false,
"force_fragmented": true,
"heartbeat_interval": 5,
"http_config": {
"enabled": false
},
"ws_config": {
"enabled": false
},
"ws_reverse_servers": [
{
"enabled": true,
"reverse_url": "ws://localhost:${port}/ws/",
"reverse_reconnect_interval": 3000
}
]
}
"@

# 写入 miraiOK 配置文件
New-Item -Path .\mirai\config.txt -ItemType File -Value "----------`nlogin ${qqid} ${qqpassword}`n"

# 写入 yobot 配置文件
New-Item -Path .\yobot\yobot_data\yobot_config.json -ItemType File -Value @"
{
Expand All @@ -82,14 +117,14 @@ New-Item -Path .\yobot\yobot_data\yobot_config.json -ItemType File -Value @"

# 启动程序
Start-Process -FilePath .\yobot\yobot.exe -WorkingDirectory .\yobot
Start-Process -FilePath .\mirai\miraiOK.exe -WorkingDirectory .\mirai
Start-Process -FilePath cmd.exe -WorkingDirectory .\mirai -ArgumentList "/C `"go-cqhttp & pause`""

# 创建快捷方式
$desktop = [Environment]::GetFolderPath("Desktop")

$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("${desktop}\mirai.lnk")
$Shortcut.TargetPath = "${pwd}\mirai\miraiOK.exe"
$Shortcut = $WshShell.CreateShortcut("${desktop}\mirai-go.lnk")
$Shortcut.TargetPath = "${pwd}\mirai\go-cqhttp.exe"
$Shortcut.WorkingDirectory = "${pwd}\mirai\"
$Shortcut.Save()

Expand Down
6 changes: 6 additions & 0 deletions src/client/nonebot_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def makefile(path, content="# doing nothing"):
from .yobot import Yobot
import asyncio

# print(
# "|===========================================|"
# "| yobot 插件版即将停止支持,请尽快更换为独立版 |"
# "|===========================================|"
# )

if "nonebot" in sys.modules:
from nonebot import get_bot, scheduler
else:
Expand Down
3 changes: 2 additions & 1 deletion src/client/packedfiles/default_boss.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"tw": [
[6000000, 8000000, 10000000, 12000000, 15000000],
[6000000, 8000000, 10000000, 12000000, 15000000],
[6000000, 8000000, 10000000, 12000000, 15000000]
[7000000, 9000000, 13000000, 15000000, 20000000],
[15000000, 16000000, 18000000, 19000000, 20000000]
],
"eff": [
[1.2, 1.2, 1.3, 1.4, 1.5],
Expand Down
2 changes: 1 addition & 1 deletion src/client/packedfiles/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"access_token": "",
"client_salt": null,
"public_address": null,
"public_basepath": "/yobot/",
"public_basepath": "/",
"web_mode_hint": true,
"super-admin": [],
"black-list": [],
Expand Down

0 comments on commit 2fbfc3b

Please sign in to comment.