Compare commits

...

No commits in common. "master" and "server" have entirely different histories.

30 changed files with 5572 additions and 392 deletions

5
.env
View File

@ -1,3 +1,2 @@
ENVIRONMENT=prod
DRIVER=~fastapi
FEISHU_BOTS=[{"app_id":"cli_a58e99809818d00c","app_secret":"4tY3KSlogZZ0qR6wxq5pTb05adfVcxJU","verification_token":"ZHdJF5ruJFOhVDgvsrfEMbNsil643caV","encrypt_key":"xiaoyan159","is_lark":false}]
ENVIRONMENT=prod
DRIVER=~fastapi

View File

@ -1,15 +1,15 @@
LOG_LEVEL=DEBUG
DRIVER=~fastapi
HOST=127.0.0.1
PORT=10088
LOG_LEVEL=INFO
# 管理员
SUPERUSERS=["xiaoyan159"]
# 管理员昵称
NICKNAME=["管理员"]
# 命令起始符号
COMMAND_START=["/", "!"]
# 命令分隔符
COMMAND_SEP=[".", "/"," "]
# 用户会话超时时间
LOG_LEVEL=DEBUG
DRIVER=~fastapi
HOST=127.0.0.1
PORT=10088
LOG_LEVEL=INFO
# 管理员
SUPERUSERS=["xiaoyan159"]
# 管理员昵称
NICKNAME=["管理员"]
# 命令起始符号
COMMAND_START=["/", "!"]
# 命令分隔符
COMMAND_SEP=[".", "/"," "]
# 用户会话超时时间
SESSION_EXPIRE_TIMEOUT=20

View File

@ -1,15 +1,15 @@
LOG_LEVEL=DEBUG
DRIVER=~fastapi
HOST=127.0.0.1
PORT=20000
LOG_LEVEL=INFO
# 管理员
SUPERUSERS=["xiaoyan159"]
# 管理员昵称
NICKNAME=["管理员"]
# 命令起始符号
COMMAND_START=["/", "!"]
# 命令分隔符
COMMAND_SEP=[".", "/"," "]
# 用户会话超时时间
LOG_LEVEL=DEBUG
DRIVER=~fastapi
HOST=127.0.0.1
PORT=20000
LOG_LEVEL=INFO
# 管理员
SUPERUSERS=["xiaoyan159"]
# 管理员昵称
NICKNAME=["管理员"]
# 命令起始符号
COMMAND_START=["/", "!"]
# 命令分隔符
COMMAND_SEP=[".", "/"," "]
# 用户会话超时时间
SESSION_EXPIRE_TIMEOUT=20

286
.gitignore vendored
View File

@ -1,142 +1,144 @@
# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytestdebug.log
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
doc/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# End of https://www.toptal.com/developers/gitignore/api/python
.idea
cqhttp/data
# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytestdebug.log
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
doc/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# End of https://www.toptal.com/developers/gitignore/api/python
.idea
cqhttp/data
cqhttp/device.json
cqhttp/session.token

3
.idea/.gitignore generated vendored
View File

@ -1,3 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml

11
.idea/NoneBot-Xiao.iml generated
View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml generated
View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated
View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/NoneBot-Xiao.iml" filepath="$PROJECT_DIR$/.idea/NoneBot-Xiao.iml" />
</modules>
</component>
</project>

View File

@ -1,12 +1,12 @@
# NoneBot-Xiao
## How to start
1. generate project using `nb create` .
2. create your plugin using `nb plugin create` .
3. writing your plugins under `src/plugins` folder.
4. run your bot using `nb run --reload` .
## Documentation
See [Docs](https://v2.nonebot.dev/)
# NoneBot-Xiao
## How to start
1. generate project using `nb create` .
2. create your plugin using `nb plugin create` .
3. writing your plugins under `src/plugins` folder.
4. run your bot using `nb run --reload` .
## Documentation
See [Docs](https://v2.nonebot.dev/)

40
bot.py
View File

@ -1,17 +1,25 @@
import nonebot
from nonebot.adapters.feishu import Adapter as FeishuAdapter
nonebot.init()
driver = nonebot.get_driver()
driver.register_adapter(FeishuAdapter)
nonebot.load_builtin_plugins('echo')
nonebot.load_from_toml("pyproject.toml")
if __name__ == "__main__":
import nonebot
from nonebot.adapters.onebot.v11 import Adapter as ONEBOT_V11Adapter
# from nonebot.adapters.feishu import Adapter as 飞书Adapter
#
# from nonebot.adapters.ntchat import Adapter as NTCHATAdapter
nonebot.init()
driver = nonebot.get_driver()
driver.register_adapter(ONEBOT_V11Adapter)
# driver.register_adapter(飞书Adapter)
#
# driver.register_adapter(NTCHATAdapter)
nonebot.load_builtin_plugins('echo')
nonebot.load_from_toml("pyproject.toml")
if __name__ == "__main__":
nonebot.run()

View File

@ -1,107 +1,107 @@
# go-cqhttp 默认配置文件
account: # 账号相关
uin: 1648107533 # QQ账号
password: 'xiaoyan159062' # 密码为空时使用扫码登录
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://127.0.0.1:10088/onebot/v11/ws/
# # 反向WS API 地址
# api: ws://your_websocket_api.server
# # 反向WS Event 地址
# event: ws://your_websocket_event.server
# 重连间隔 单位毫秒
reconnect-interval: 3000
middlewares:
<<: *default # 引用默认中间件
# go-cqhttp 默认配置文件
account: # 账号相关
uin: 1648107533 # QQ账号
password: 'xiaoyan159062' # 密码为空时使用扫码登录
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://127.0.0.1:10088/onebot/v11/ws/
# # 反向WS API 地址
# api: ws://your_websocket_api.server
# # 反向WS Event 地址
# event: ws://your_websocket_event.server
# 重连间隔 单位毫秒
reconnect-interval: 3000
middlewares:
<<: *default # 引用默认中间件

0
cqhttp/LICENSE Normal file → Executable file
View File

2
cqhttp/README.md Normal file → Executable file
View File

@ -1,6 +1,6 @@
<p align="center">
<a href="https://ishkong.github.io/go-cqhttp-docs/">
<img src="https://user-images.githubusercontent.com/25968335/120111974-8abef880-c139-11eb-99cd-fa928348b198.png" width="200" height="200" alt="go-cqhttp">
<img src="winres/icon.png" width="200" height="200" alt="go-cqhttp">
</a>
</p>

View File

@ -2,7 +2,7 @@
account: # 账号相关
uin: 1648107533 # QQ账号
password: 'xiaoyan159062' # 密码为空时使用扫码登录
password: '' # 密码为空时使用扫码登录
encrypt: false # 是否开启密码加密
status: 0 # 在线状态 请参考 https://docs.go-cqhttp.org/guide/config.html#在线状态
relogin: # 重连设置
@ -16,6 +16,15 @@ account: # 账号相关
# 是否允许发送临时会话消息
allow-temp-session: false
# 数据包的签名服务器
# 兼容 https://github.com/fuqiuluo/unidbg-fetch-qsign
# 如果遇到 登录 45 错误, 或者发送信息风控的话需要填入一个服务器
# 示例:
# sign-server: 'http://127.0.0.1:8080' # 本地签名服务器
# sign-server: 'https://signserver.example.com' # 线上签名服务器
# 服务器可使用docker在本地搭建或者使用他人开放的服务
sign-server: 'http://dawang.xiaoyan159.space:5709/'
heartbeat:
# 心跳频率, 单位秒
# -1 为关闭心跳
@ -43,6 +52,10 @@ message:
extra-reply-data: false
# 跳过 Mime 扫描, 忽略错误数据
skip-mime-scan: false
# 是否自动转换 WebP 图片
convert-webp-image: false
# http超时时间
http-timeout: 0
output:
# 日志等级 trace,debug,info,warn,error
@ -105,3 +118,5 @@ servers:
reconnect-interval: 3000
middlewares:
<<: *default # 引用默认中间件

View File

@ -1 +1 @@
{"display":"MIRAI.030468.001","product":"mirai","device":"mirai","board":"mirai","model":"mirai","finger_print":"mamoe/mirai/mirai:10/MIRAI.200122.001/4241523:user/release-keys","boot_id":"0624e782-cfa9-b123-f253-482e3695d1bf","proc_version":"Linux version 3.0.31-RwxaY2Wt (android-build@xxx.xxx.xxx.xxx.com)","protocol":5,"imei":"935895209282990","brand":"mamoe","bootloader":"unknown","base_band":"","version":{"incremental":"5891938","release":"10","codename":"REL","sdk":29},"sim_info":"T-Mobile","os_type":"android","mac_address":"00:50:56:C0:00:08","ip_address":[10,0,1,3],"wifi_bssid":"00:50:56:C0:00:08","wifi_ssid":"\u003cunknown ssid\u003e","imsi_md5":"b9424c49d46505d1f2c99e9bbadd340f","android_id":"cc1733e21c8ea405","apn":"wifi","vendor_name":"MIUI","vendor_os_name":"mirai"}
{"display":"MIRAI.495990.001","product":"mirai","device":"mirai","board":"mirai","model":"mirai","finger_print":"mamoe/mirai/mirai:10/MIRAI.200122.001/4144447:user/release-keys","boot_id":"46ffb647-de87-258d-bb07-eb08e3a29b33","proc_version":"Linux version 3.0.31-10kFFebM (android-build@xxx.xxx.xxx.xxx.com)","protocol":2,"imei":"435775380963712","brand":"mamoe","bootloader":"unknown","base_band":"","version":{"incremental":"5891938","release":"10","codename":"REL","sdk":29},"sim_info":"T-Mobile","os_type":"android","mac_address":"00:50:56:C0:00:08","ip_address":[10,0,1,3],"wifi_bssid":"00:50:56:C0:00:08","wifi_ssid":"\u003cunknown ssid\u003e","imsi_md5":"9bc76fd297d1536030d19c2ef497b691","android_id":"1eabadb09bae30c0","apn":"wifi","vendor_name":"MIUI","vendor_os_name":"mirai"}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,16 +1,16 @@
[project]
name = "NoneBot-Xiao"
version = "0.1.0"
description = "NoneBot-Xiao"
readme = "README.md"
requires-python = ">=3.8, <4.0"
[tool.nonebot]
adapters = [
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" },
{ name = "飞书", module_name = "nonebot.adapters.feishu" },
{ name = "Ntchat", module_name = "nonebot.adapters.ntchat" }
]
plugins = []
plugin_dirs = ["src/plugins"]
builtin_plugins = ["echo"]
[project]
name = "NoneBot-Xiao"
version = "0.1.0"
description = "NoneBot-Xiao"
readme = "README.md"
requires-python = ">=3.8, <4.0"
[tool.nonebot]
adapters = [
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" },
{ name = "飞书", module_name = "nonebot.adapters.feishu" },
{ name = "Ntchat", module_name = "nonebot.adapters.ntchat" }
]
plugins = []
plugin_dirs = ["src/plugins"]
builtin_plugins = ["echo"]

200
requirements.txt Normal file
View File

@ -0,0 +1,200 @@
adapter==0.1
aiocache==0.12.0
aiocqhttp==1.4.3
aiofiles==23.1.0
anyio==3.6.2
appdirs==1.4.4
argcomplete==2.0.0
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
asttokens==2.2.1
async-generator==1.10
attrs==22.2.0
backcall==0.2.0
beautifulsoup4==4.11.2
bleach==6.0.0
blinker==1.5
brotlipy==0.7.0
bs4==0.0.1
CacheControl==0.12.11
cashews==4.7.1
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.0.1
cleo==2.0.1
click==8.1.3
colorama==0.4.6
comm==0.1.2
crashtest==0.4.1
cryptography==40.0.2
cssselect==1.2.0
debugpy==1.6.6
decorator==5.1.1
defusedxml==0.7.1
distlib==0.3.6
docopt==0.6.2
dulwich==0.20.50
exceptiongroup==1.1.1
executing==1.2.0
fake-useragent==1.1.1
fastapi==0.91.0
fastjsonschema==2.16.2
filelock==3.9.0
fqdn==1.5.1
gitdb==4.0.9
GitPython==3.1.27
h11==0.14.0
h2==4.1.0
hpack==4.0.0
html5lib==1.1
httpcore==0.16.3
httptools==0.5.0
httpx==0.23.3
hypercorn==0.14.3
hyperframe==6.0.1
idna==3.4
importlib-metadata==6.0.0
ipykernel==6.20.2
ipython==8.9.0
ipython-genutils==0.2.0
ipywidgets==8.0.4
irc3==1.1.8
isoduration==20.11.0
itsdangerous==2.1.2
jaraco.classes==3.2.3
jedi==0.18.2
Jinja2==3.1.2
jsonpointer==2.3
jsonschema==4.17.3
jupyter==1.0.0
jupyter-console==6.4.4
jupyter-events==0.6.3
jupyter_client==8.0.1
jupyter_core==5.1.5
jupyter_server==2.1.0
jupyter_server_terminals==0.4.4
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.5
keyring==23.13.1
lfmh==1.1.1
lockfile==0.12.2
loguru==0.6.0
lxml==4.9.2
MarkupSafe==2.1.2
matplotlib-inline==0.1.6
mistune==2.0.4
more-itertools==9.0.0
msgpack==1.0.4
multidict==6.0.4
musicbrainzngs==0.7.1
mysql-connector-python==8.0.28
nbclassic==0.5.1
nbclient==0.7.2
nbconvert==7.2.9
nbformat==5.7.3
nest-asyncio==1.5.6
nonebot==1.9.1
nonebot-adapter-feishu==2.0.0b6
nonebot-adapter-onebot==2.2.1
nonebot2==2.0.0rc3
notebook==6.5.2
notebook_shim==0.2.2
numpy==1.24.3
onebot==1.3.3
outcome==1.2.0
packaging==23.0
pandas==2.0.1
pandocfilters==1.5.0
parse==1.19.0
parsimonious==0.10.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
pipx==1.1.0
pkginfo==1.9.6
platformdirs==2.6.2
poetry==1.3.2
poetry-core==1.4.0
poetry-plugin-export==1.3.0
priority==2.0.0
prometheus-client==0.16.0
prompt-toolkit==3.0.36
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
pycparser==2.21
pycryptodome==3.17
pydantic==1.10.4
pyee==8.2.2
Pygments==2.14.0
pygtrie==2.5.0
pyOpenSSL==23.1.1
pyppeteer==1.0.2
pyquery==2.0.0
pyrsistent==0.19.3
PySocks==1.7.1
python-dateutil==2.8.2
python-dotenv==0.21.1
python-json-logger==2.0.4
pytz==2023.3
pywin32==305
pywin32-ctypes==0.2.0
pywinpty==2.0.10
PyYAML==6.0
pyzmq==25.0.0
qtconsole==5.4.0
QtPy==2.3.0
quart==0.18.3
rapidfuzz==2.13.7
regex==2022.10.31
requests==2.28.2
requests-html==0.10.0
requests-toolbelt==0.10.1
rfc3339-validator==0.1.4
rfc3986==1.5.0
rfc3986-validator==0.1.1
selenium==4.9.1
Send2Trash==1.8.0
shellingham==1.5.0.post1
six==1.16.0
smmap==5.0.0
sniffio==1.3.0
sortedcontainers==2.4.0
soupsieve==2.3.2.post1
stack-data==0.6.2
starlette==0.24.0
terminado==0.17.1
tinycss2==1.2.1
toml==0.10.2
tomli==2.0.1
tomlkit==0.11.6
tornado==6.2
tqdm==4.64.1
traitlets==5.8.1
trio==0.22.0
trio-websocket==0.10.2
trove-classifiers==2023.1.20
typing_extensions==4.4.0
tzdata==2023.3
uri-template==1.2.0
urllib3==1.26.14
urllib3-secure-extra==0.1.0
userpath==1.8.0
uvicorn==0.20.0
venusian==3.0.0
virtualenv==20.16.5
w3lib==2.1.1
watchfiles==0.18.1
wcwidth==0.2.6
webcolors==1.12
webencodings==0.5.1
websocket-client==1.5.0
websockets==10.4
Werkzeug==2.2.2
widgetsnbextension==4.0.5
win32-setctime==1.1.0
wincertstore==0.2
wsproto==1.2.0
yarl==1.8.2
zipp==3.13.0

View File

@ -1,34 +1,34 @@
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
weather = on_command("weather", rule=to_me(), aliases={"天气", "天气预报"}, priority=5)
@weather.handle()
async def handle_first_receive(matcher: Matcher, args: Message = CommandArg()):
plain_text = args.extract_plain_text() # 首次发送命令时跟随的参数,例:/天气 上海则args为上海
if plain_text:
matcher.set_arg("city", args) # 如果用户发送了参数则直接赋值
@weather.got("city", prompt="你想查询哪个城市的天气呢?")
async def handle_city(city: Message = Arg(), city_name: str = ArgPlainText("city")):
if city_name not in ["北京", "上海"]: # 如果参数不符合要求,则提示用户重新输入
# 可以使用平台的 Message 类直接构造模板消息
await weather.reject(city.template("你想查询的城市 {city} 暂不支持,请重新输入!"))
city_weather = await get_weather(city_name)
await weather.finish(city_weather)
# 在这里编写获取天气信息的函数
async def get_weather(city: str) -> str:
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
weather = on_command("weather", rule=to_me(), aliases={"天气", "天气预报"}, priority=5)
@weather.handle()
async def handle_first_receive(matcher: Matcher, args: Message = CommandArg()):
plain_text = args.extract_plain_text() # 首次发送命令时跟随的参数,例:/天气 上海则args为上海
if plain_text:
matcher.set_arg("city", args) # 如果用户发送了参数则直接赋值
@weather.got("city", prompt="你想查询哪个城市的天气呢?")
async def handle_city(city: Message = Arg(), city_name: str = ArgPlainText("city")):
if city_name not in ["北京", "上海"]: # 如果参数不符合要求,则提示用户重新输入
# 可以使用平台的 Message 类直接构造模板消息
await weather.reject(city.template("你想查询的城市 {city} 暂不支持,请重新输入!"))
city_weather = await get_weather(city_name)
await weather.finish(city_weather)
# 在这里编写获取天气信息的函数
async def get_weather(city: str) -> str:
return f"{city}的天气是..."

View File

@ -0,0 +1,21 @@
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 nonebot.params import CommandArg
from nonebot.message import event_preprocessor
from .config import Config
from nonebot import on_command
from nonebot.rule import to_me
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())
)

View File

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

View File

@ -0,0 +1,80 @@
from datetime import datetime
from nonebot.adapters.onebot.v11 import Bot, Event
from nonebot.typing import T_State
from nonebot.params import CommandArg, Command
from nonebot import on_command
from nonebot.rule import to_me
from requests_html import HTMLSession, HTML
zhibo8Command = on_command("zhibo8", rule=to_me(), aliases={'预测', '英超', 'zhibo8'}, priority=10)
xiaobianStr = r"""
小编们预测比分
太能喵
叶小欢
大帝强
小小
"""
vsMap = {}
@zhibo8Command.handle()
async def handle_first_receive(bot: Bot, event: Event, state: T_State, args= CommandArg()):
# 事件预处理,获取对应的赛程数据
vsMap.clear()
session = HTMLSession()
zhibo8Get = session.get("https://www.zhibo8.cc/")
print(zhibo8Get)
saishiContent = zhibo8Get.html.xpath("//div[@class='vct-box']/div[@class='_content']/ul/li")
# 解析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 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)
plain_text = args.extract_plain_text()
if plain_text:
state.set_arg("round", plain_text)
else:
await zhibo8Command.send(message=""""选择要查看的轮次,当前支持查看的轮次为:\r\n{} \r\n""".format(getRoundPrompt(vsMap)))
@zhibo8Command.got(key="round", prompt="""请输入编号:""")
async def getRoundNum(event: Event):
round = str(event.get_message())
if round.isdigit() == False:
await zhibo8Command.reject(prompt="请输入编号(数字)")
if len(vsMap.keys())>=int(round):
resultStr = ""
roudNum = list(vsMap.keys())[int(round)-1]
# for roudNum in vsMap:
resultStr += "" + roudNum.replace("", "联赛 第") + " 比分预测】\r\n"
for vs in vsMap[roudNum]:
resultStr += vs + xiaobianStr + "\r\n"
await zhibo8Command.finish(resultStr)
else:
await zhibo8Command.reject_arg(key="round", prompt="输入的编号错误,请重新输入!")
def parserSaishiItem(saishiStr):
html = HTML(html=saishiStr)
# listItem = html.xpath("//b//text()")
roundNum = html.xpath("//span[@class='_league']//text()")[0]
homeName = html.xpath("//span[@class='_teams']//text()")[0].strip()
awayName = html.xpath("//span[@class='_teams']//text()")[-1].strip()
timeStr = html.xpath("./li/@data-time")[0]
time = datetime.strptime(timeStr, "%Y-%m-%d %H:%M")
timeTuple = time.timetuple()
return (roundNum, "{}{}".format(timeTuple.tm_mon, timeTuple.tm_mday)+time.strftime("%H:%M") + " " + homeName + " vs " + awayName)
def getRoundPrompt(roundMap):
str = ""
i = 1
for key in roundMap:
print(key)
str += "{}: {} \r\n".format(i, key)
i = i+1
return str

View File

@ -0,0 +1,157 @@
import datetime
import warnings
from datetime import timedelta
from nonebot.adapters.onebot.v11 import Bot, Event
from nonebot.typing import T_State
from nonebot.params import CommandArg, Command
from nonebot import on_command
from nonebot.rule import to_me
from requests_html import HTMLSession, HTML
import json
from nonebot import logger
# from selenium.webdriver import Chrome, ChromeOptions
tongjiCommand = on_command("统计", rule=to_me(), aliases={'微头条', 'tongji', 'tj'}, priority=10)
# driver_path = '../../../../driver/cromedriver_win32'
max_behot_time = '0'
# 初始化map对象分别记录每个人的微头条个数
weitoutiaoMap = {"太能喵": 0, "小小": 0, "大帝强": 0, "叶小欢": 0}
"""
接收QQ消息根据消息统计微头条结果
"""
@tongjiCommand.handle()
async def handle_first_receive(bot: Bot, event: Event, state: T_State, args= CommandArg()):
from nonebot.exception import MatcherException
try:
# 清空原有的weitoutiaoMap中的统计结果
for k,v in weitoutiaoMap.items():
weitoutiaoMap[k] = 0
getWeiToutiaoInfo()
# 将上周的微头条考核结果发送给用户
await tongjiCommand.finish(str(weitoutiaoMap))
except MatcherException:
raise
except Exception as e:
logger.error(e)
print(e)
"""
获取微头条数据信息
"""
def getWeiToutiaoInfo():
global max_behot_time
# 获取上一周的第一天和最后一天的时间戳
lastWeekStartTime, lastWeekEndTime = getLastWeekFirstDayTimeStamp()
session = HTMLSession()
weitoutiaoGet = session.get(f"https://www.toutiao.com/api/pc/list/user/feed?category=pc_profile_ugc&token=MS4wLjABAAAA7lHc4sBPuZaQ85qdIrwVvWm8Ps5O1kPMpuh5lTJAwII&max_behot_time={max_behot_time}&aid=24&app_name=toutiao_web", verify=False, proxies=None)
# print(weitoutiaoGet.text)
# 使用Json解析返回的数据
resultJson = json.loads(weitoutiaoGet.text)
# 先获取下个max_behot_time时间戳如果需要翻页查询需要使用该参数
max_behot_time = resultJson['next']['max_behot_time']
# 开始循环解析data数据获取微头条的内容和发布人员
dataList = resultJson['data']
# 获取每一条消息的发布时间戳如果发布时间出现早于上周一0点的数据结束统计函数返回否则递归调用当前函数
for data in dataList:
# 获取本条新闻的发布时间
publishTime = data["publish_time"]
if int(publishTime) > int(lastWeekEndTime):
continue
elif int(publishTime) < int(lastWeekStartTime):
return
else:
# 如果是比分预测类的微头条,则跳过
content = str(data['content'])
if content.find("比分预测】")>0:
continue
else:
# 获取该微头条的发布人和发布日期
author = None
contentSubString = content[-8:]
if contentSubString.find("太能喵")>0:
weitoutiaoMap["太能喵"] = weitoutiaoMap["太能喵"]+1
elif contentSubString.find("小小")>0:
weitoutiaoMap["小小"] = weitoutiaoMap["小小"]+1
elif contentSubString.find("大帝强") > 0:
weitoutiaoMap["大帝强"] = weitoutiaoMap["大帝强"] + 1
elif contentSubString.find("叶小欢") > 0:
weitoutiaoMap["叶小欢"] = weitoutiaoMap["叶小欢"] + 1
getWeiToutiaoInfo()
# """
# 获取文章数据信息
# """
# def getWenzhangInfo():
# global max_behot_time
#
# # 第一步输入这个:去除开头警告
# warnings.simplefilter('ignore', ResourceWarning)
#
# chrome_option = ChromeOptions()
# chrome_option.headless = True
# chrome_option.add_argument('--no-sandbox') # 解决DevToolsActivePort文件不存在的报错
# chrome_option.add_argument('--disable-gpu') # 谷歌文档提到需要加上这个属性来规避bug
# chrome_option.add_argument('--hide-scrollbars') # 隐藏滚动条, 应对一些特殊页面
# chrome_option.add_experimental_option('excludeSwitches', ['enable-automation'])
# chrome_option.add_argument('--headless')
#
# browser = Chrome(executable_path=driver_path, options=chrome_option)
#
# # 获取上一周的第一天和最后一天的时间戳
# lastWeekStartTime, lastWeekEndTime = getLastWeekFirstDayTimeStamp()
# session = HTMLSession()
# wenzhangGet = session.get(f"https://www.toutiao.com/api/pc/list/user/feed?category=pc_profile_article&token=MS4wLjABAAAA7lHc4sBPuZaQ85qdIrwVvWm8Ps5O1kPMpuh5lTJAwII&max_behot_time={max_behot_time}&aid=24&app_name=toutiao_web", verify=False, proxies=None)
# # print(weitoutiaoGet.text)
# # 使用Json解析返回的数据
# resultJson = json.loads(wenzhangGet.text)
# # 先获取下个max_behot_time时间戳如果需要翻页查询需要使用该参数
# max_behot_time = resultJson['next']['max_behot_time']
# # 开始循环解析data数据获取微头条的内容和发布人员
# dataList = resultJson['data']
# # 获取每一条消息的发布时间戳如果发布时间出现早于上周一0点的数据结束统计函数返回否则递归调用当前函数
# for data in dataList:
# # 获取本条新闻的发布时间
# publishTime = data["publish_time"]
# if int(publishTime) > int(lastWeekEndTime):
# continue
# elif int(publishTime) < int(lastWeekStartTime):
# return
# else:
# # 获取该文章的标题和对应的url需要再通过url获取文章正文解析作者是谁
# title = data["title"]
# url = data["url"]
# if url:
# # 请求文章正文内容
# browser.get(url)
# element = browser.find_element(by='XPATH', value="//article")
# print(element)
# # author = None
# # if data.find("太能喵")>0:
# # weitoutiaoMap["太能喵"] = weitoutiaoMap["太能喵"]+1
# # elif content.find("小小")>0:
# # weitoutiaoMap["小小"] = weitoutiaoMap["小小"]+1
# # elif content.find("大帝强") > 0:
# # weitoutiaoMap["大帝强"] = weitoutiaoMap["大帝强"] + 1
# # elif content.find("叶小欢") > 0:
# # weitoutiaoMap["叶小欢"] = weitoutiaoMap["叶小欢"] + 1
# # 如果没有被return掉继续请求下一页内容
# getWeiToutiaoInfo()
"""
获取当前日期上一周的第一天和最后一天的时间戳
"""
def getLastWeekFirstDayTimeStamp():
now = datetime.datetime.now()
# 上周第一天和最后一天
last_week_start = now - timedelta(days=now.weekday() + 7, hours=now.hour, minutes=now.minute, seconds=now.second, microseconds=now.microsecond)
last_week_end = last_week_start - timedelta(days=-7)
print(f"上周第一天的日期是:{last_week_start},最后一天的日期是:{last_week_end}")
print(f"上周第一天的时间戳是:{last_week_start.timestamp()},最后一天的时间戳是:{last_week_end.timestamp()}")
return last_week_start.timestamp(), last_week_end.timestamp()
if __name__ == '__main__':
getWeiToutiaoInfo()
# print(weitoutiaoMap)

1
start.sh Executable file
View File

@ -0,0 +1 @@
source /root/data/www/Nonebot2-Xiao/venv/bin/activate && cd /root/data/www/Nonebot2-Xiao/ && python bot.py