feat: 初始化

This commit is contained in:
xiaoyan-5800X 2023-02-09 23:54:23 +08:00
parent fd7abf141c
commit 9a447daaca
21 changed files with 244 additions and 7 deletions

3
.gitignore vendored
View File

@ -138,4 +138,5 @@ dmypy.json
# pytype static type analyzer
.pytype/
# End of https://www.toptal.com/developers/gitignore/api/python
# End of https://www.toptal.com/developers/gitignore/api/python
.idea

107
config.yml Normal file
View File

@ -0,0 +1,107 @@
# go-cqhttp 默认配置文件
account: # 账号相关
uin: 1233456 # QQ账号
password: '' # 密码为空时使用扫码登录
encrypt: false # 是否开启密码加密
status: 0 # 在线状态 请参考 https://docs.go-cqhttp.org/guide/config.html#在线状态
relogin: # 重连设置
delay: 3 # 首次重连延迟, 单位秒
interval: 3 # 重连间隔
max-times: 0 # 最大重连次数, 0为无限制
# 是否使用服务器下发的新地址进行重连
# 注意, 此设置可能导致在海外服务器上连接情况更差
use-sso-address: true
# 是否允许发送临时会话消息
allow-temp-session: false
heartbeat:
# 心跳频率, 单位秒
# -1 为关闭心跳
interval: 5
message:
# 上报数据类型
# 可选: string,array
post-format: string
# 是否忽略无效的CQ码, 如果为假将原样发送
ignore-invalid-cqcode: false
# 是否强制分片发送消息
# 分片发送将会带来更快的速度
# 但是兼容性会有些问题
force-fragment: false
# 是否将url分片发送
fix-url: false
# 下载图片等请求网络代理
proxy-rewrite: ''
# 是否上报自身消息
report-self-message: false
# 移除服务端的Reply附带的At
remove-reply-at: false
# 为Reply附加更多信息
extra-reply-data: false
# 跳过 Mime 扫描, 忽略错误数据
skip-mime-scan: false
output:
# 日志等级 trace,debug,info,warn,error
log-level: warn
# 日志时效 单位天. 超过这个时间之前的日志将会被自动删除. 设置为 0 表示永久保留.
log-aging: 15
# 是否在每次启动时强制创建全新的文件储存日志. 为 false 的情况下将会在上次启动时创建的日志文件续写
log-force-new: true
# 是否启用日志颜色
log-colorful: true
# 是否启用 DEBUG
debug: false # 开启调试模式
# 默认中间件锚点
default-middlewares: &default
# 访问密钥, 强烈推荐在公网的服务器设置
access-token: ''
# 事件过滤器文件目录
filter: ''
# API限速设置
# 该设置为全局生效
# 原 cqhttp 虽然启用了 rate_limit 后缀, 但是基本没插件适配
# 目前该限速设置为令牌桶算法, 请参考:
# https://baike.baidu.com/item/%E4%BB%A4%E7%89%8C%E6%A1%B6%E7%AE%97%E6%B3%95/6597000?fr=aladdin
rate-limit:
enabled: false # 是否启用限速
frequency: 1 # 令牌回复频率, 单位秒
bucket: 1 # 令牌桶大小
database: # 数据库相关设置
leveldb:
# 是否启用内置leveldb数据库
# 启用将会增加10-20MB的内存占用和一定的磁盘空间
# 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能
enable: true
sqlite3:
# 是否启用内置sqlite3数据库
# 启用将会增加一定的内存占用和一定的磁盘空间
# 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能
enable: false
cachettl: 3600000000000 # 1h
# 连接服务列表
servers:
# 添加方式,同一连接方式可添加多个,具体配置说明请查看文档
#- http: # http 通信
#- ws: # 正向 Websocket
#- ws-reverse: # 反向 Websocket
#- pprof: #性能分析服务器
# 反向WS设置
- ws-reverse:
# 反向WS Universal 地址
# 注意 设置了此项地址后下面两项将会被忽略
universal: ws://your_websocket_universal.server
# 反向WS API 地址
api: ws://your_websocket_api.server
# 反向WS Event 地址
event: ws://your_websocket_event.server
# 重连间隔 单位毫秒
reconnect-interval: 3000
middlewares:
<<: *default # 引用默认中间件

View File

@ -1 +1 @@
MANIFEST-000005
MANIFEST-000009

View File

@ -1 +1 @@
MANIFEST-000003
MANIFEST-000007

View File

@ -22,3 +22,21 @@
23:59:25.632807 version@stat F·[] S·0B[] Sc·[]
23:59:25.634032 db@janitor F·2 G·0
23:59:25.634045 db@open done T·1.312002ms
=============== Feb 9, 2023 (CST) ===============
23:05:24.191519 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
23:05:24.191616 version@stat F·[] S·0B[] Sc·[]
23:05:24.191631 db@open opening
23:05:24.191655 journal@recovery F·1
23:05:24.191670 journal@recovery recovering @4
23:05:24.191732 version@stat F·[] S·0B[] Sc·[]
23:05:24.193095 db@janitor F·2 G·0
23:05:24.193105 db@open done T·1.468771ms
=============== Feb 9, 2023 (CST) ===============
23:06:02.854307 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
23:06:02.854392 version@stat F·[] S·0B[] Sc·[]
23:06:02.854403 db@open opening
23:06:02.854420 journal@recovery F·1
23:06:02.854433 journal@recovery recovering @6
23:06:02.854483 version@stat F·[] S·0B[] Sc·[]
23:06:02.855679 db@janitor F·2 G·0
23:06:02.855945 db@open done T·1.53667ms

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
MANIFEST-000005
MANIFEST-000010

View File

@ -1 +1 @@
MANIFEST-000003
MANIFEST-000008

View File

@ -22,3 +22,22 @@
23:59:25.635821 version@stat F·[] S·0B[] Sc·[]
23:59:25.637460 db@janitor F·2 G·0
23:59:25.637478 db@open done T·1.76466ms
=============== Feb 9, 2023 (CST) ===============
23:05:24.194505 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
23:05:24.194570 version@stat F·[] S·0B[] Sc·[]
23:05:24.194583 db@open opening
23:05:24.194617 journal@recovery F·1
23:05:24.194642 journal@recovery recovering @4
23:05:24.194955 memdb@flush created L0@6 N·1 S·230B "\xe8~/\b,v1":"\xe8~/\b,v1"
23:05:24.194994 version@stat F·[1] S·230B[230B] Sc·[0.25]
23:05:24.197191 db@janitor F·3 G·0
23:05:24.197198 db@open done T·2.610842ms
=============== Feb 9, 2023 (CST) ===============
23:06:02.857480 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
23:06:02.857555 version@stat F·[1] S·230B[230B] Sc·[0.25]
23:06:02.857567 db@open opening
23:06:02.857604 journal@recovery F·1
23:06:02.857627 journal@recovery recovering @7
23:06:02.857702 version@stat F·[1] S·230B[230B] Sc·[0.25]
23:06:02.858727 db@janitor F·3 G·0
23:06:02.858737 db@open done T·1.1659ms

Binary file not shown.

View File

@ -1 +1 @@
MANIFEST-000005
MANIFEST-000009

View File

@ -1 +1 @@
MANIFEST-000003
MANIFEST-000007

View File

@ -22,3 +22,21 @@
23:59:25.634297 version@stat F·[] S·0B[] Sc·[]
23:59:25.635536 db@janitor F·2 G·0
23:59:25.635547 db@open done T·1.371654ms
=============== Feb 9, 2023 (CST) ===============
23:05:24.193133 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
23:05:24.193176 version@stat F·[] S·0B[] Sc·[]
23:05:24.193184 db@open opening
23:05:24.193200 journal@recovery F·1
23:05:24.193213 journal@recovery recovering @4
23:05:24.193267 version@stat F·[] S·0B[] Sc·[]
23:05:24.194438 db@janitor F·2 G·0
23:05:24.194447 db@open done T·1.260231ms
=============== Feb 9, 2023 (CST) ===============
23:06:02.855979 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
23:06:02.856025 version@stat F·[] S·0B[] Sc·[]
23:06:02.856031 db@open opening
23:06:02.856047 journal@recovery F·1
23:06:02.856059 journal@recovery recovering @6
23:06:02.856114 version@stat F·[] S·0B[] Sc·[]
23:06:02.857409 db@janitor F·2 G·0
23:06:02.857420 db@open done T·1.386759ms

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,69 @@
from datetime import datetime
from pathlib import Path
import nonebot
from nonebot import get_driver, on_message
from nonebot.adapters.onebot.v11 import Bot, Event
from nonebot.typing import T_State
from .config import Config
from nonebot import on_command
from nonebot.rule import to_me
from nonebot.matcher import Matcher
from nonebot.adapters import Message
from nonebot.params import Arg, CommandArg, ArgPlainText
from requests_html import HTMLSession, HTML
global_config = get_driver().config
config = Config.parse_obj(global_config)
_sub_plugins = set()
_sub_plugins |= nonebot.load_plugins(
str((Path(__file__).parent / "plugins").resolve())
)
zhibo8Command = on_command("/zhibo8", rule=to_me(), aliases={'预测', '英超', 'zhibo'}, priority=10)
xiaobianStr = r"""
小编们预测比分
太能喵
叶小欢
大帝强
小小
"""
@zhibo8Command.handle()
async def handler_zhibo8(bot: Bot, event: Event, state: T_State):
session = HTMLSession()
zhibo8Get = session.get("http://www.zhibo8.cc")
print(zhibo8Get)
saishiContent = zhibo8Get.html.xpath("//ul/li[starts-with(@id, 'saishi')]")
vsMap = dict()
# 解析xpath
# 解析xpath
for item in saishiContent:
if item.html.find("英超") >= 0:
if item.html.find("阿森纳") >= 0 or item.html.find("曼城") >= 0 or item.html.find("曼联") >= 0 or item.html.find("利物浦") >= 0 or item.html.find("切尔西") >= 0:
rouneNum, vsStr = parserSaishiItem(item.html)
if rouneNum not in vsMap.keys():
vsMap[rouneNum] = []
vsMap[rouneNum].append(vsStr)
resultStr = ""
for roudNum in vsMap:
resultStr += "" + roudNum.replace("", "联赛 第") + " 比分预测】\r\n"
for vs in vsMap[roudNum]:
resultStr += vs + "\r\n"
resultStr += xiaobianStr
await zhibo8Command.finish(resultStr)
def parserSaishiItem(saishiStr):
html = HTML(html=saishiStr)
listItem = html.xpath("//b//text()")
roundNum = listItem[0].split(" ")[0].strip()
homeName = listItem[0].split(" ")[1].strip()
awayName = listItem[-1].strip()
timeStr = html.xpath("//li/@data-time")
time = datetime.strptime(timeStr[0], "%Y-%m-%d %H:%M")
return (roundNum, time.strftime("%m月%d%H:%M") + " " + homeName + " vs " + awayName)

View File

@ -0,0 +1,5 @@
from pydantic import BaseModel, Extra
class Config(BaseModel, extra=Extra.ignore):
"""Plugin Config Here"""