Compare commits

..
6 Commits
Author SHA1 Message Date
xiaoyan159 f84cd3cdfc fix: 合并代码 2023-09-28 16:09:26 +08:00
xiaoyan159 837593ab11 fix: 修改cqhttp的配置 2023-09-28 16:03:52 +08:00
xiaoyan159 b7c3a549dd fix: 修改git忽略文件 2023-09-28 16:02:42 +08:00
xiaoyan159 24b6d4ca44 feat: 尝试自动统计文章 2023-09-25 18:08:32 +08:00
xiaoyan159 5eb218cf65 feat: 完成微头条个数统计函数 2023-09-25 00:24:10 +08:00
xiaoyan159 2465e0b748 feat: 同步服务端代码 2023-09-22 14:08:16 +08:00
29 changed files with 5422 additions and 392 deletions
+2 -3
View File
@@ -1,3 +1,2 @@
ENVIRONMENT=prod ENVIRONMENT=prod
DRIVER=~fastapi DRIVER=~fastapi
FEISHU_BOTS=[{"app_id":"cli_a58e99809818d00c","app_secret":"4tY3KSlogZZ0qR6wxq5pTb05adfVcxJU","verification_token":"ZHdJF5ruJFOhVDgvsrfEMbNsil643caV","encrypt_key":"xiaoyan159","is_lark":false}]
+14 -14
View File
@@ -1,15 +1,15 @@
LOG_LEVEL=DEBUG LOG_LEVEL=DEBUG
DRIVER=~fastapi DRIVER=~fastapi
HOST=127.0.0.1 HOST=127.0.0.1
PORT=10088 PORT=10088
LOG_LEVEL=INFO LOG_LEVEL=INFO
# 管理员 # 管理员
SUPERUSERS=["xiaoyan159"] SUPERUSERS=["xiaoyan159"]
# 管理员昵称 # 管理员昵称
NICKNAME=["管理员"] NICKNAME=["管理员"]
# 命令起始符号 # 命令起始符号
COMMAND_START=["/", "!"] COMMAND_START=["/", "!"]
# 命令分隔符 # 命令分隔符
COMMAND_SEP=[".", "/"," "] COMMAND_SEP=[".", "/"," "]
# 用户会话超时时间 # 用户会话超时时间
SESSION_EXPIRE_TIMEOUT=20 SESSION_EXPIRE_TIMEOUT=20
+14 -14
View File
@@ -1,15 +1,15 @@
LOG_LEVEL=DEBUG LOG_LEVEL=DEBUG
DRIVER=~fastapi DRIVER=~fastapi
HOST=127.0.0.1 HOST=127.0.0.1
PORT=20000 PORT=20000
LOG_LEVEL=INFO LOG_LEVEL=INFO
# 管理员 # 管理员
SUPERUSERS=["xiaoyan159"] SUPERUSERS=["xiaoyan159"]
# 管理员昵称 # 管理员昵称
NICKNAME=["管理员"] NICKNAME=["管理员"]
# 命令起始符号 # 命令起始符号
COMMAND_START=["/", "!"] COMMAND_START=["/", "!"]
# 命令分隔符 # 命令分隔符
COMMAND_SEP=[".", "/"," "] COMMAND_SEP=[".", "/"," "]
# 用户会话超时时间 # 用户会话超时时间
SESSION_EXPIRE_TIMEOUT=20 SESSION_EXPIRE_TIMEOUT=20
+144 -142
View File
@@ -1,142 +1,144 @@
# Created by https://www.toptal.com/developers/gitignore/api/python # Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python # Edit at https://www.toptal.com/developers/gitignore?templates=python
### Python ### ### Python ###
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
*$py.class *$py.class
# C extensions # C extensions
*.so *.so
# Distribution / packaging # Distribution / packaging
.Python .Python
build/ build/
develop-eggs/ develop-eggs/
dist/ dist/
downloads/ downloads/
eggs/ eggs/
.eggs/ .eggs/
lib/ lib/
lib64/ lib64/
parts/ parts/
sdist/ sdist/
var/ var/
wheels/ wheels/
pip-wheel-metadata/ pip-wheel-metadata/
share/python-wheels/ share/python-wheels/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
MANIFEST MANIFEST
# PyInstaller # PyInstaller
# Usually these files are written by a python script from a template # 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. # before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest *.manifest
*.spec *.spec
# Installer logs # Installer logs
pip-log.txt pip-log.txt
pip-delete-this-directory.txt pip-delete-this-directory.txt
# Unit test / coverage reports # Unit test / coverage reports
htmlcov/ htmlcov/
.tox/ .tox/
.nox/ .nox/
.coverage .coverage
.coverage.* .coverage.*
.cache .cache
nosetests.xml nosetests.xml
coverage.xml coverage.xml
*.cover *.cover
*.py,cover *.py,cover
.hypothesis/ .hypothesis/
.pytest_cache/ .pytest_cache/
pytestdebug.log pytestdebug.log
# Translations # Translations
*.mo *.mo
*.pot *.pot
# Django stuff: # Django stuff:
*.log *.log
local_settings.py local_settings.py
db.sqlite3 db.sqlite3
db.sqlite3-journal db.sqlite3-journal
# Flask stuff: # Flask stuff:
instance/ instance/
.webassets-cache .webassets-cache
# Scrapy stuff: # Scrapy stuff:
.scrapy .scrapy
# Sphinx documentation # Sphinx documentation
docs/_build/ docs/_build/
doc/_build/ doc/_build/
# PyBuilder # PyBuilder
target/ target/
# Jupyter Notebook # Jupyter Notebook
.ipynb_checkpoints .ipynb_checkpoints
# IPython # IPython
profile_default/ profile_default/
ipython_config.py ipython_config.py
# pyenv # pyenv
.python-version .python-version
# pipenv # pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # 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 # 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 # having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies. # install all needed dependencies.
#Pipfile.lock #Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow # PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/ __pypackages__/
# Celery stuff # Celery stuff
celerybeat-schedule celerybeat-schedule
celerybeat.pid celerybeat.pid
# SageMath parsed files # SageMath parsed files
*.sage.py *.sage.py
# Environments # Environments
.venv .venv
env/ env/
venv/ venv/
ENV/ ENV/
env.bak/ env.bak/
venv.bak/ venv.bak/
# Spyder project settings # Spyder project settings
.spyderproject .spyderproject
.spyproject .spyproject
# Rope project settings # Rope project settings
.ropeproject .ropeproject
# mkdocs documentation # mkdocs documentation
/site /site
# mypy # mypy
.mypy_cache/ .mypy_cache/
.dmypy.json .dmypy.json
dmypy.json dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
# pytype static type analyzer # pytype static type analyzer
.pytype/ .pytype/
# End of https://www.toptal.com/developers/gitignore/api/python # End of https://www.toptal.com/developers/gitignore/api/python
.idea .idea
cqhttp/data cqhttp/data
session.token
device.json
-3
View File
@@ -1,3 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
-11
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>
-6
View File
@@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
-4
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
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>
+12 -12
View File
@@ -1,12 +1,12 @@
# NoneBot-Xiao # NoneBot-Xiao
## How to start ## How to start
1. generate project using `nb create` . 1. generate project using `nb create` .
2. create your plugin using `nb plugin create` . 2. create your plugin using `nb plugin create` .
3. writing your plugins under `src/plugins` folder. 3. writing your plugins under `src/plugins` folder.
4. run your bot using `nb run --reload` . 4. run your bot using `nb run --reload` .
## Documentation ## Documentation
See [Docs](https://v2.nonebot.dev/) See [Docs](https://v2.nonebot.dev/)
+24 -16
View File
@@ -1,17 +1,25 @@
import nonebot import nonebot
from nonebot.adapters.feishu import Adapter as FeishuAdapter from nonebot.adapters.onebot.v11 import Adapter as ONEBOT_V11Adapter
# from nonebot.adapters.feishu import Adapter as 飞书Adapter
#
nonebot.init() # from nonebot.adapters.ntchat import Adapter as NTCHATAdapter
driver = nonebot.get_driver()
driver.register_adapter(FeishuAdapter)
nonebot.init()
nonebot.load_builtin_plugins('echo')
driver = nonebot.get_driver()
driver.register_adapter(ONEBOT_V11Adapter)
nonebot.load_from_toml("pyproject.toml")
# driver.register_adapter(飞书Adapter)
if __name__ == "__main__": #
# driver.register_adapter(NTCHATAdapter)
nonebot.load_builtin_plugins('echo')
nonebot.load_from_toml("pyproject.toml")
if __name__ == "__main__":
nonebot.run() nonebot.run()
+107 -107
View File
@@ -1,107 +1,107 @@
# go-cqhttp 默认配置文件 # go-cqhttp 默认配置文件
account: # 账号相关 account: # 账号相关
uin: 1648107533 # QQ账号 uin: 1648107533 # QQ账号
password: 'xiaoyan159062' # 密码为空时使用扫码登录 password: 'xiaoyan159062' # 密码为空时使用扫码登录
encrypt: false # 是否开启密码加密 encrypt: false # 是否开启密码加密
status: 0 # 在线状态 请参考 https://docs.go-cqhttp.org/guide/config.html#在线状态 status: 0 # 在线状态 请参考 https://docs.go-cqhttp.org/guide/config.html#在线状态
relogin: # 重连设置 relogin: # 重连设置
delay: 3 # 首次重连延迟, 单位秒 delay: 3 # 首次重连延迟, 单位秒
interval: 3 # 重连间隔 interval: 3 # 重连间隔
max-times: 0 # 最大重连次数, 0为无限制 max-times: 0 # 最大重连次数, 0为无限制
# 是否使用服务器下发的新地址进行重连 # 是否使用服务器下发的新地址进行重连
# 注意, 此设置可能导致在海外服务器上连接情况更差 # 注意, 此设置可能导致在海外服务器上连接情况更差
use-sso-address: true use-sso-address: true
# 是否允许发送临时会话消息 # 是否允许发送临时会话消息
allow-temp-session: false allow-temp-session: false
heartbeat: heartbeat:
# 心跳频率, 单位秒 # 心跳频率, 单位秒
# -1 为关闭心跳 # -1 为关闭心跳
interval: 5 interval: 5
message: message:
# 上报数据类型 # 上报数据类型
# 可选: string,array # 可选: string,array
post-format: string post-format: string
# 是否忽略无效的CQ码, 如果为假将原样发送 # 是否忽略无效的CQ码, 如果为假将原样发送
ignore-invalid-cqcode: false ignore-invalid-cqcode: false
# 是否强制分片发送消息 # 是否强制分片发送消息
# 分片发送将会带来更快的速度 # 分片发送将会带来更快的速度
# 但是兼容性会有些问题 # 但是兼容性会有些问题
force-fragment: false force-fragment: false
# 是否将url分片发送 # 是否将url分片发送
fix-url: false fix-url: false
# 下载图片等请求网络代理 # 下载图片等请求网络代理
proxy-rewrite: '' proxy-rewrite: ''
# 是否上报自身消息 # 是否上报自身消息
report-self-message: false report-self-message: false
# 移除服务端的Reply附带的At # 移除服务端的Reply附带的At
remove-reply-at: false remove-reply-at: false
# 为Reply附加更多信息 # 为Reply附加更多信息
extra-reply-data: false extra-reply-data: false
# 跳过 Mime 扫描, 忽略错误数据 # 跳过 Mime 扫描, 忽略错误数据
skip-mime-scan: false skip-mime-scan: false
output: output:
# 日志等级 trace,debug,info,warn,error # 日志等级 trace,debug,info,warn,error
log-level: warn log-level: warn
# 日志时效 单位天. 超过这个时间之前的日志将会被自动删除. 设置为 0 表示永久保留. # 日志时效 单位天. 超过这个时间之前的日志将会被自动删除. 设置为 0 表示永久保留.
log-aging: 15 log-aging: 15
# 是否在每次启动时强制创建全新的文件储存日志. 为 false 的情况下将会在上次启动时创建的日志文件续写 # 是否在每次启动时强制创建全新的文件储存日志. 为 false 的情况下将会在上次启动时创建的日志文件续写
log-force-new: true log-force-new: true
# 是否启用日志颜色 # 是否启用日志颜色
log-colorful: true log-colorful: true
# 是否启用 DEBUG # 是否启用 DEBUG
debug: false # 开启调试模式 debug: false # 开启调试模式
# 默认中间件锚点 # 默认中间件锚点
default-middlewares: &default default-middlewares: &default
# 访问密钥, 强烈推荐在公网的服务器设置 # 访问密钥, 强烈推荐在公网的服务器设置
access-token: '' access-token: ''
# 事件过滤器文件目录 # 事件过滤器文件目录
filter: '' filter: ''
# API限速设置 # API限速设置
# 该设置为全局生效 # 该设置为全局生效
# 原 cqhttp 虽然启用了 rate_limit 后缀, 但是基本没插件适配 # 原 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 # 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: rate-limit:
enabled: false # 是否启用限速 enabled: false # 是否启用限速
frequency: 1 # 令牌回复频率, 单位秒 frequency: 1 # 令牌回复频率, 单位秒
bucket: 1 # 令牌桶大小 bucket: 1 # 令牌桶大小
database: # 数据库相关设置 database: # 数据库相关设置
leveldb: leveldb:
# 是否启用内置leveldb数据库 # 是否启用内置leveldb数据库
# 启用将会增加10-20MB的内存占用和一定的磁盘空间 # 启用将会增加10-20MB的内存占用和一定的磁盘空间
# 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能 # 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能
enable: true enable: true
sqlite3: sqlite3:
# 是否启用内置sqlite3数据库 # 是否启用内置sqlite3数据库
# 启用将会增加一定的内存占用和一定的磁盘空间 # 启用将会增加一定的内存占用和一定的磁盘空间
# 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能 # 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能
enable: false enable: false
cachettl: 3600000000000 # 1h cachettl: 3600000000000 # 1h
# 连接服务列表 # 连接服务列表
servers: servers:
# 添加方式,同一连接方式可添加多个,具体配置说明请查看文档 # 添加方式,同一连接方式可添加多个,具体配置说明请查看文档
#- http: # http 通信 #- http: # http 通信
#- ws: # 正向 Websocket #- ws: # 正向 Websocket
#- ws-reverse: # 反向 Websocket #- ws-reverse: # 反向 Websocket
#- pprof: #性能分析服务器 #- pprof: #性能分析服务器
# 反向WS设置 # 反向WS设置
- ws-reverse: - ws-reverse:
# 反向WS Universal 地址 # 反向WS Universal 地址
# 注意 设置了此项地址后下面两项将会被忽略 # 注意 设置了此项地址后下面两项将会被忽略
universal: ws://127.0.0.1:10088/onebot/v11/ws/ universal: ws://127.0.0.1:10088/onebot/v11/ws/
# # 反向WS API 地址 # # 反向WS API 地址
# api: ws://your_websocket_api.server # api: ws://your_websocket_api.server
# # 反向WS Event 地址 # # 反向WS Event 地址
# event: ws://your_websocket_event.server # event: ws://your_websocket_event.server
# 重连间隔 单位毫秒 # 重连间隔 单位毫秒
reconnect-interval: 3000 reconnect-interval: 3000
middlewares: middlewares:
<<: *default # 引用默认中间件 <<: *default # 引用默认中间件
Regular → Executable
View File
Regular → Executable
+1 -1
View File
@@ -1,6 +1,6 @@
<p align="center"> <p align="center">
<a href="https://ishkong.github.io/go-cqhttp-docs/"> <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> </a>
</p> </p>
+16 -1
View File
@@ -2,7 +2,7 @@
account: # 账号相关 account: # 账号相关
uin: 1648107533 # QQ账号 uin: 1648107533 # QQ账号
password: 'xiaoyan159062' # 密码为空时使用扫码登录 password: '' # 密码为空时使用扫码登录
encrypt: false # 是否开启密码加密 encrypt: false # 是否开启密码加密
status: 0 # 在线状态 请参考 https://docs.go-cqhttp.org/guide/config.html#在线状态 status: 0 # 在线状态 请参考 https://docs.go-cqhttp.org/guide/config.html#在线状态
relogin: # 重连设置 relogin: # 重连设置
@@ -16,6 +16,15 @@ account: # 账号相关
# 是否允许发送临时会话消息 # 是否允许发送临时会话消息
allow-temp-session: false 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://127.0.0.1:5709/'
heartbeat: heartbeat:
# 心跳频率, 单位秒 # 心跳频率, 单位秒
# -1 为关闭心跳 # -1 为关闭心跳
@@ -43,6 +52,10 @@ message:
extra-reply-data: false extra-reply-data: false
# 跳过 Mime 扫描, 忽略错误数据 # 跳过 Mime 扫描, 忽略错误数据
skip-mime-scan: false skip-mime-scan: false
# 是否自动转换 WebP 图片
convert-webp-image: false
# http超时时间
http-timeout: 0
output: output:
# 日志等级 trace,debug,info,warn,error # 日志等级 trace,debug,info,warn,error
@@ -105,3 +118,5 @@ servers:
reconnect-interval: 3000 reconnect-interval: 3000
middlewares: middlewares:
<<: *default # 引用默认中间件 <<: *default # 引用默认中间件
+1 -1
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"}
BIN
View File
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.
+16 -16
View File
@@ -1,16 +1,16 @@
[project] [project]
name = "NoneBot-Xiao" name = "NoneBot-Xiao"
version = "0.1.0" version = "0.1.0"
description = "NoneBot-Xiao" description = "NoneBot-Xiao"
readme = "README.md" readme = "README.md"
requires-python = ">=3.8, <4.0" requires-python = ">=3.8, <4.0"
[tool.nonebot] [tool.nonebot]
adapters = [ adapters = [
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" }, { name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" },
{ name = "飞书", module_name = "nonebot.adapters.feishu" }, { name = "飞书", module_name = "nonebot.adapters.feishu" },
{ name = "Ntchat", module_name = "nonebot.adapters.ntchat" } { name = "Ntchat", module_name = "nonebot.adapters.ntchat" }
] ]
plugins = [] plugins = []
plugin_dirs = ["src/plugins"] plugin_dirs = ["src/plugins"]
builtin_plugins = ["echo"] builtin_plugins = ["echo"]
+73
View File
@@ -0,0 +1,73 @@
aiocache==0.12.0
aiocqhttp==1.4.3
aiofiles==23.1.0
anyio==3.6.2
appdirs==1.4.4
beautifulsoup4==4.11.2
blinker==1.5
bs4==0.0.1
certifi==2022.12.7
charset-normalizer==3.0.1
click==8.1.3
colorama==0.4.6
cssselect==1.2.0
docopt==0.6.2
fake-useragent==1.1.1
fastapi==0.91.0
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
irc3==1.1.8
itsdangerous==2.1.2
Jinja2==3.1.2
lfmh==1.1.1
loguru==0.6.0
lxml==4.9.2
MarkupSafe==2.1.2
msgpack==1.0.4
multidict==6.0.4
musicbrainzngs==0.7.1
nonebot-adapter-onebot==2.2.1
nonebot2==2.0.0rc3
onebot==1.3.3
parse==1.19.0
priority==2.0.0
pydantic==1.10.4
pyee==8.2.2
pygtrie==2.5.0
pyppeteer==1.0.2
pyquery==2.0.0
python-dotenv==0.21.1
PyYAML==6.0
quart==0.18.3
requests==2.28.2
requests-html==0.10.0
rfc3986==1.5.0
six==1.16.0
sniffio==1.3.0
soupsieve==2.3.2.post1
starlette==0.24.0
toml==0.10.2
tomlkit==0.11.6
tqdm==4.64.1
typing_extensions==4.4.0
urllib3==1.26.14
uvicorn==0.20.0
venusian==3.0.0
w3lib==2.1.1
watchfiles==0.18.1
webencodings==0.5.1
websockets==10.4
Werkzeug==2.2.2
win32-setctime==1.1.0
wsproto==1.2.0
yarl==1.8.2
zipp==3.13.0
+33 -33
View File
@@ -1,34 +1,34 @@
from nonebot import on_command from nonebot import on_command
from nonebot.rule import to_me from nonebot.rule import to_me
from nonebot.matcher import Matcher from nonebot.matcher import Matcher
from nonebot.adapters import Message from nonebot.adapters import Message
from nonebot.params import Arg, CommandArg, ArgPlainText from nonebot.params import Arg, CommandArg, ArgPlainText
weather = on_command("weather", rule=to_me(), aliases={"天气", "天气预报"}, priority=5) weather = on_command("weather", rule=to_me(), aliases={"天气", "天气预报"}, priority=5)
@weather.handle() @weather.handle()
async def handle_first_receive(matcher: Matcher, args: Message = CommandArg()): async def handle_first_receive(matcher: Matcher, args: Message = CommandArg()):
plain_text = args.extract_plain_text() # 首次发送命令时跟随的参数,例:/天气 上海,则args为上海 plain_text = args.extract_plain_text() # 首次发送命令时跟随的参数,例:/天气 上海,则args为上海
if plain_text: if plain_text:
matcher.set_arg("city", args) # 如果用户发送了参数则直接赋值 matcher.set_arg("city", args) # 如果用户发送了参数则直接赋值
@weather.got("city", prompt="你想查询哪个城市的天气呢?") @weather.got("city", prompt="你想查询哪个城市的天气呢?")
async def handle_city(city: Message = Arg(), city_name: str = ArgPlainText("city")): async def handle_city(city: Message = Arg(), city_name: str = ArgPlainText("city")):
if city_name not in ["北京", "上海"]: # 如果参数不符合要求,则提示用户重新输入 if city_name not in ["北京", "上海"]: # 如果参数不符合要求,则提示用户重新输入
# 可以使用平台的 Message 类直接构造模板消息 # 可以使用平台的 Message 类直接构造模板消息
await weather.reject(city.template("你想查询的城市 {city} 暂不支持,请重新输入!")) await weather.reject(city.template("你想查询的城市 {city} 暂不支持,请重新输入!"))
city_weather = await get_weather(city_name) city_weather = await get_weather(city_name)
await weather.finish(city_weather) await weather.finish(city_weather)
# 在这里编写获取天气信息的函数 # 在这里编写获取天气信息的函数
async def get_weather(city: str) -> str: async def get_weather(city: str) -> str:
return f"{city}的天气是..." return f"{city}的天气是..."
+21
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())
)
+5
View File
@@ -0,0 +1,5 @@
from pydantic import BaseModel, Extra
class Config(BaseModel, extra=Extra.ignore):
"""Plugin Config Here"""
+80
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:
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
+134
View File
@@ -0,0 +1,134 @@
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 selenium.webdriver import Chrome, ChromeOptions
driver_path = '../../../../driver/cromedriver_win32'
max_behot_time = '0'
# 初始化map对象,分别记录每个人的微头条个数
weitoutiaoMap = {"太能喵": 0, "小小": 0, "大帝强": 0, "叶小欢": 0}
"""
获取微头条数据信息
"""
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_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:
# 请求文章正文内容
wenzhangGet = browser.get(url)
print(wenzhangGet.text)
# 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__':
getWenzhangInfo()
# print(weitoutiaoMap)
Executable
+1
View File
@@ -0,0 +1 @@
source /root/data/www/Nonebot2-Xiao/venv/bin/activate && cd /root/data/www/Nonebot2-Xiao/ && python bot.py