你好呀!这是我的Github首页,它好看吗(
不是)
欢迎访问我的个人主页哦:轻音时雨
这里会存一些个人写的低水平垃圾代码
我非常的菜,已经菜的不能再菜了
本页面欢迎小伙伴拿去修改使用哦~⭐
滥竽充数的标签:
从 21-08-14 开始统计的访问量:
一个适用hoshinobot 的 github仓库commits更新推送 插件
你好呀!这是我的Github首页,它好看吗(
不是)
欢迎访问我的个人主页哦:轻音时雨
这里会存一些个人写的低水平垃圾代码
我非常的菜,已经菜的不能再菜了
本页面欢迎小伙伴拿去修改使用哦~⭐
滥竽充数的标签:
从 21-08-14 开始统计的访问量:
在查仓库时,出现ERROR: 'NoneType' object has no attribute 'startswith'
错误
[2021-09-14 13:00:28,522 github_reminder] ERROR: 'NoneType' object has no attribute 'startswith'
Traceback (most recent call last):
File "/root/HoshinoBot/hoshino/msghandler.py", line 28, in handle_message
await service_func.func(bot, event)
File "/root/HoshinoBot/hoshino/modules/github_reminder/__init__.py", line 38, in search_depo
msg = create_msg(url)
File "/root/HoshinoBot/hoshino/modules/github_reminder/get_com.py", line 75, in create_msg
link_list, n = get_commits(html)
File "/root/HoshinoBot/hoshino/modules/github_reminder/get_com.py", line 32, in get_commits
if a_lable.string.startswith('from '):
AttributeError: 'NoneType' object has no attribute 'startswith'
[2021-09-14 13:00:28,523 nonebot] INFO: Message 341764145 is ignored: Handled by Hoshino
get_com.py 里20行最后url_tmp.replace
应该是url.replace
吧,会报're.Match' object has no attribute 'replace'
最近又开始报错了(不清楚是不是个例)
报错内容如下
[2024-01-17 01:50:01,298 github_reminder_poller] ERROR: list index out of range
Traceback (most recent call last):
File "~\hoshino\service.py", line 344, in wrapper
ret = await func()
File "~\hoshino\modules\github_reminder\__init__.py", line 74, in depo_commit_poller
await poller_update(bot)
File "~\hoshino\modules\github_reminder\com_poller.py", line 21, in poller_update
new_time = data_list[0]['time']
IndexError: list index out of range
然后捣鼓了下发现soup.text
返回的刚好是json形式的commit历史信息,
整个soup里就只有<html><body><p>commit历史信息的json文本</p/></body></html>
,
然后便有如下可能不太靠谱的修复
get_com.py
29-41行替换为如下
raw_info = json.loads(soup.text)
commit_infos_by_timeline = raw_info['payload']['commitGroups']
commit_counter = 0 # 记录commit数
for commit_info_by_timeline in commit_infos_by_timeline:
commit_infos = commit_info_by_timeline['commits']
for commit_info in commit_infos:
commit_message = commit_info['shortMessage']
authors_info = commit_info['authors']
authors_name = ','.join([info['displayName'] for info in authors_info])
raw_time = commit_info['committedDate']
time = await change_time(raw_time)
data_list.append({'title': commit_message, 'author': authors_name, 'time': time})
commit_counter += 1
if commit_counter >= 5: # 如果要只取最近5次commit
return data_list
简单测试了下应该没有什么大问题
因为对bs4不太熟悉不清楚为啥只返回了个json文本,但感觉怪怪的,可能用段时间就用不了了
更正经的修复就得重新找页面元素或者直接用github的官方api了
config/_ bot _.py已经加了,也没有任何报错,发命令没有回应
开启 github_reminder_poller
提示:未找到服务:github_reminder_poller
其他命令也没反应
使用requests可能造成主线程卡死、无法响应其他指令
再不济另开一个线程可以解决(会额外占用资源)
loop = asyncio.get_event_loop()
executor = ThreadPoolExecutor()
res = await loop.run_in_executor(executor, function, args, ...)
[2023-07-20 14:10:05,821 hoshino] INFO: 检测到群95**的监控的仓库https://github.com/pcrbot/HoshinoBot-plugins-index有更新
[2023-07-20 14:10:05,821 github_reminder_poller] INFO: 检测commits更新失败,错误:
[2023-07-20 14:10:05,821 github_reminder_poller] INFO: Scheduled job depo_commit_poller completed.
对于https://github.com/pcrbot/HoshinoBot-plugins-index 有如下报错
INFO: 检测commits更新失败,错误:list index out of range
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.